5

In this answer I have to use the character # as it is part of SASS. But that formats the code as a comment.

How do I escape that character?

0

2 Answers 2

12

This is a failure of the Stack Exchange syntax highlighting. Because you haven't specified, it seems to be falling back on the default highlighting, which tries to be pretty general to any programming language. Since SASS isn't on the list of supported languages, you may have to either go with

<-- language: lang-css -->

for basic CSS formatting, or

<-- language: lang-none -->

to just turn off the highlighting entirely.

4
  • <-- language: lang-css --> worked like a charm! Commented Aug 31, 2016 at 12:36
  • 1
    It is not a failure. The CSS tag is using lang-default. See my answer here, skip to the end.
    – rene Mod
    Commented Aug 31, 2016 at 13:29
  • 2
    @rene The css tag using lang-default seems like a failure to me, given that it's supposed to pick a better default based on tags, whenever possible. Though, I do recall that the devs have had a lot of issues around html/js/css, since all three tend to pop up together in the same posts. Commented Aug 31, 2016 at 13:51
  • 1
    That is the reason they decided to fall-back to lang-default.
    – rene Mod
    Commented Aug 31, 2016 at 13:55
1

You can also suppress syntax highlighting for an entire code block by making it a <pre> block.  Just put <pre> at the beginning, </pre> at the end, and don't indent four spaces.

So, if you type:

<!-- I had to put this here in order to reproduce the OP's problem. -->

<!-- language: lang-default -->

    @for $ii from 1 through $range {
        .h-#{$property}-#{$item}-#{$ii * 10} { #{$property}-#{$item}: #{$ii * 10}px; }
    }

<pre>@for $ii from 1 through $range {
    .h-#{$property}-#{$item}-#{$ii * 10} { #{$property}-#{$item}: #{$ii * 10}px; }
}</pre>

You will get:

@for $ii from 1 through $range {
    .h-#{$property}-#{$item}-#{$ii * 10} { #{$property}-#{$item}: #{$ii * 10}px; }
}
@for $ii from 1 through $range {
    .h-#{$property}-#{$item}-#{$ii * 10} { #{$property}-#{$item}: #{$ii * 10}px; }
}

Beware that limited HTML tags work within a <pre>...</pre> block, so, if you have any < characters in your code (which is common for things like C, Java, and shell scripts), you must escape them as &lt; (Less Than).  Under some circumstances, it may be necessary to encode > as &gt; and & as &amp.

So, if you type:

    for (i=0; i<n; i++) printf("Hello world.\n")

<pre>for (i=0; i<n; i++) printf("Hello world.\n")</pre>

<pre>for (i=0; i&lt;n; i++) printf("Hello world.\n")</pre>

You will get:

for (i=0; i<n; i++) printf("Hello world.\n")
for (i=0; i

for (i=0; i<n; i++) printf("Hello world.\n")

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .