Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline CSS Highlight Patch #4646

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

dev-talha-akbar
Copy link

Introduces an option inlineCssMode which when set to true enable highlighting of CSS in the style attribute. Can be extended to highlight JavaScript in attributes such as onclick, onmouseup e.t.c.

Introduces an option inlineCssMode which when set to true enable highlighting of CSS in the style attribute. Can be extended to highlight JavaScript in attributes such as onclick, onmouseup e.t.c.
@marijnh
Copy link
Member

marijnh commented Mar 20, 2017

Hi. You're messing with the indentation and semicolons of lines that aren't affected by your patch. Please don't do that. Also please try to follow the coding style of the surrounding code with regards to spaces after if, not putting else on a new line, etc.

What is isDefault for? And why are you setting inTag, which so far is either a string or null, to true there?

@dev-talha-akbar
Copy link
Author

Ah, sorry for the code indentation e.t.c.

If we are in any HTML tag,
set isDefault to false, set inTag to true.

isDefault is boolean & false because, I want to run my added behavior which further checks the attributes for a specific attribute and switch the mode.
inTag is boolean because, I don't wanna know what tag it is (we need any truth value).

If we are in an HTML tag but it is that specific tag which was provided in tags option from CodeMirror instance,
set isDefault to true, set inTag to the tag we're in (a string, again, truth value, valuable for conditions)

isDefault is boolean & true because, this time, we will run the code that was originally written by you to switch mode.

inTag is a string so, we can find associated mode to switch to from tags option.

I came across this problem for Codemirror because where I work at, the developers used to work alot in the style attribute tweaking styles. I thought it might help. I ain't good and it's posted so, someone can improve on this and integrate it into CM.

Copy link
Contributor

@danth danth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! This would be very useful for editing HTML with style and script tags.

Copy link

@phuongkt phuongkt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

@phuongkt
Copy link

.

@marijnh
Copy link
Member

marijnh commented Sep 11, 2017

Hey @phuongkt, stop adding empty reviews or I'll have to block you from the project.

@danth
Copy link
Contributor

danth commented Sep 17, 2017

Reviewed 1 of 1 files at r1.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


mode/htmlmixed/htmlmixed.js, line 79 at r1 (raw file):

      multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag
    });

Why has this blank line been removed? I think it makes the code easier to read.


Comments from Reviewable

Improved the formatting of the code.
@danth
Copy link
Contributor

danth commented Sep 18, 2017

Review status: all files reviewed at latest revision, 3 unresolved discussions.


mode/htmlmixed/htmlmixed.js, line 137 at r1 (raw file):

      }
      else if (state.isDefault && state.inTag && tag && />$/.test(stream.current())) {
          var inTag = /^([\S]+) (.*)/.exec(state.inTag);

BTW these few lines have the incorrect indent.


mode/htmlmixed/htmlmixed.js, line 140 at r1 (raw file):

          state.inTag = null;
          state.isDefault = null;
          var modeSpec = stream.current() == ">" && findMatchingMode(tags[inTag[1]], inTag[2])

BTW these three lines are indented incorrectly too


Comments from Reviewable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants