Repository: oppia/oppia

Issue:
Add a lint check to ensure content of style tags are indented by 2 spaces.
<!--
  - Thanks for taking the time to propose a new feature for the Oppia project.
  - Before filing a new issue, please do a quick search to check that it hasn't
  - already been filed on the [issue tracker](https://github.com/oppia/oppia/issues)._
  -->
Add a check in pre_commit_linter.py, such that content of the style tag is indented by 2.
```
<style>
  .p{}
<style>
```
Please check the comment [here](https://github.com/oppia/oppia/pull/6665#discussion_r279296414).

Add a lint check to ensure content of style tags are indented by 2 spaces.
<!--
  - Thanks for taking the time to propose a new feature for the Oppia project.
  - Before filing a new issue, please do a quick search to check that it hasn't
  - already been filed on the [issue tracker](https://github.com/oppia/oppia/issues)._
  -->
Add a check in pre_commit_linter.py, such that content of the style tag is indented by 2.
```
<style>
  .p{}
<style>
```
Please check the comment [here](https://github.com/oppia/oppia/pull/6665#discussion_r279296414).



Discussion:
Hi, I think changing `indent-width: 2` and introducing `indent-delta: true` for level indentation to .htmllintrc file will solve this issue. [Here](https://github.com/oppia/oppia/blob/develop/.htmllintrc#L22)
htmllint-cli doc:  [Here](https://github.com/htmllint/htmllint/wiki/Options)
still I think above suggestion wont work for [this](https://github.com/oppia/oppia/pull/6665#discussion_r279296414) case if we start from level 0 indentation after style tag
what do you suggest? @seanlip @anubhavsinha98 @DubeySandeep 
Hi @sauravpratihar, can you explain more what you mean by "still I think above suggestion wont work for this case if we start from level 0 indentation after style tag"? (Maybe with a code snippet to show what you mean by "level 0 indentation"?)
Hi, I think changing `indent-width: 2` and introducing `indent-delta: true` for level indentation to .htmllintrc file will solve this issue. [Here](https://github.com/oppia/oppia/blob/develop/.htmllintrc#L22)
htmllint-cli doc:  [Here](https://github.com/htmllint/htmllint/wiki/Options)
still I think above suggestion wont work for [this](https://github.com/oppia/oppia/pull/6665#discussion_r279296414) case if we start from level 0 indentation after style tag
what do you suggest? @seanlip @anubhavsinha98 @DubeySandeep 
Hi @sauravpratihar, can you explain more what you mean by "still I think above suggestion wont work for this case if we start from level 0 indentation after style tag"? (Maybe with a code snippet to show what you mean by "level 0 indentation"?)

Resolving patch:
diff --git a/scripts/pre_commit_linter.py b/scripts/pre_commit_linter.py
--- a/scripts/pre_commit_linter.py
+++ b/scripts/pre_commit_linter.py
@@ -788,6 +788,25 @@ def handle_starttag(self, tag, attrs):
         expected_indentation = self.indentation_level * self.indentation_width
         tag_line = self.file_lines[line_number - 1].lstrip()
         opening_tag = '<' + tag
+
+        # Check the indentation for content of style tag.
+        if tag_line.startswith(opening_tag) and tag == 'style':
+            # Getting next line after style tag.
+            next_line = self.file_lines[line_number]
+            next_line_expected_indentation = (
+                self.indentation_level + 1) * self.indentation_width
+            next_line_column_number = len(next_line) - len(next_line.lstrip())
+
+            if next_line_column_number != next_line_expected_indentation:
+                print (
+                    '%s --> Expected indentation '
+                    'of %s, found indentation of %s '
+                    'for content of %s tag on line %s ' % (
+                        self.filepath, next_line_expected_indentation,
+                        next_line_column_number, tag, line_number + 1))
+                print ''
+                self.failed = True
+
         if tag_line.startswith(opening_tag) and (
                 column_number != expected_indentation):
             print (


Test patch: