devongovett / atom-jade

Jade TextMate bundle converted for Atom
51 stars 26 forks source link

Improper colors applied to "Block in a tag" plain text if applied to a mixin #58

Closed nathanbuchar closed 4 years ago

nathanbuchar commented 9 years ago

Issue: This is probably super low priority, but I figured I'd flag it anyway. The first word in any line of "Block in a tag" plain text applied to a mixin will have the wrong coloring applied. I understand that this is likely not best practice, but it is still valid!

Correct Coloring

If you add a period after an element, any text within that element will be interpreted as plain text instead of Jade. This is called "Block in tag" plain text. For example:

p.
  Sed posuere consectetur est at lobortis. Vivamus sagittis lacus vel augue
  laoreet rutrum faucibus dolor auctor. Integer posuere erat a ante venenatis
  dapibus posuere velit aliquet. Vivamus sagittis lacus vel augue lapreet
  rutrum faucibus dolor auctor.
Incorrect Coloring

However, if instead of a parent element, you instead use a mixin which defines a block, such as the following, you'll get incorrect coloring, even though it is still valid Jade and will be rendered properly. The Jade interpreter appears to believe that these are elements, although I could be wrong.

mixin paragraph()
  p
    block

+paragraph().
  Sed posuere consectetur est at lobortis. Vivamus sagittis lacus vel augue
  laoreet rutrum faucibus dolor auctor. Integer posuere erat a ante venenatis
  dapibus posuere velit aliquet. Vivamus sagittis lacus vel augue lapreet
  rutrum faucibus dolor auctor.

(It looks like even the service GitHub is using to display code doesn't render this properly either!)

Of course you could instead use pipes, but that's besides the point :-). Plus using pips becomes more difficult with large, complicated blocks of text (like possibly content contained within a <script> tag)

mixin paragraph()
  p
    block

+paragraph()
  | Sed posuere consectetur est at lobortis. Vivamus sagittis lacus vel augue
  | laoreet rutrum faucibus dolor auctor. Integer posuere erat a ante venenatis
  | dapibus posuere velit aliquet. Vivamus sagittis lacus vel augue lapreet
  | rutrum faucibus dolor auctor.

Screenshot taken from Atom:

screen shot 2015-08-18 at 5 24 01 pm

More information about plain text rendering in Jade: http://jade-lang.com/reference/plain-text/