4

I've edited this answer, adding text that I copied from a FAQ and then block quoted:

> 3.1)  How do I find the creation time of a file?
> 
>       You can't - it isn't stored anywhere.  Files have a last-modified
>       time (shown by "ls -l"), a last-accessed time (shown by "ls -lu")
>       and an inode change time (shown by "ls -lc"). The latter is often
>       referred to as the "creation time" - even in some man pages -
>       but that's wrong; it's also set by such operations as mv, ln,
>       chmod, chown and chgrp.
> 
>       The man page for "stat(2)" discusses this.

I was surprised to find that the block-quoted text was being syntax highlighted:

enter image description here

The workaround that didn't work

I tried adding the special markup before the block quote:

<!-- language: lang-none -->
> 3.1)  How do I find the creation time of a file?
> 
>       You can't - it isn't stored anywhere.  Files have a last-modified

but that didn't turn off the syntax highlighting.

The workaround that worked

I was able to work around this by reducing the indentation in the quoted text:

> 3.1)  How do I find the creation time of a file?
> 
>   You can't - it isn't stored anywhere.  Files have a last-modified
>   time (shown by "ls -l"), a last-accessed time (shown by "ls -lu")
>   and an inode change time (shown by "ls -lc"). The latter is often
>   referred to as the "creation time" - even in some man pages -
>   but that's wrong; it's also set by such operations as mv, ln,
>   chmod, chown and chgrp.
> 
>   The man page for "stat(2)" discusses this.

That turned off the syntax highlighting:

enter image description here

The question

Is there an easier way to turn off syntax highlighting in block quoted text than by undenting the indented portion of the quoted text?

3

Code fences with a directive not to format the text appears to be exactly what you're looking for:

> ```lang-none
> 3.1)  How do I find the creation time of a file?
> 
>       You can't - it isn't stored anywhere.  Files have a last-modified
>       time (shown by "ls -l"), a last-accessed time (shown by "ls -lu")
>       and an inode change time (shown by "ls -lc"). The latter is often
>       referred to as the "creation time" - even in some man pages -
>       but that's wrong; it's also set by such operations as mv, ln,
>       chmod, chown and chgrp.
> 
>       The man page for "stat(2)" discusses this.
> ```

Output (live rendering):

3.1)  How do I find the creation time of a file?

      You can't - it isn't stored anywhere.  Files have a last-modified
      time (shown by "ls -l"), a last-accessed time (shown by "ls -lu")
      and an inode change time (shown by "ls -lc"). The latter is often
      referred to as the "creation time" - even in some man pages -
      but that's wrong; it's also set by such operations as mv, ln,
      chmod, chown and chgrp.

      The man page for "stat(2)" discusses this.

Code fences are also now the preferred approach for creating code blocks, as the <!-- language: lang-none --> approach was deprecated in the 2020 switch to CommonMark:

In a nutshell: If you want to declare the language for syntax highlighting in your code block, use the code-fence notation and not indented code blocks. You can still use indented code blocks, but declaring the preferred language explicitly for them is no longer supported moving forward.

Until now, you could do this to declare the language for an indented code block:

<!-- language: python -->

    def hello():
        print("Hello, World");

Moving forward, this style is considered deprecated. Ever since we’ve introduced code fences, you can explicitly declare the language of a code block using the code fence notation:

``` python
def hello():
    print("Hello, World");
```
1

Using the code like this the misuse of the code option - because indenting by four spaces makes any text be the code; and the coloring engine can't know that you suddenly decided to make use of the code option as of the alternative of block quotes (instead of this, you can also use the double block quotes, i.e. >>). I'd leave the text in the block quotes. However, it's your choice, and here's how to fix it.

Put right before the text you want to code; skip the line before and after the <!-- language: lang-none -->

> 3.1)  How do I find the creation time of a file?

><!-- language: lang-none -->

>      You can't - it isn't stored anywhere.  Files have a last-modified
>      time (shown by "ls -l"), a last-accessed time (shown by "ls -lu")
3
  • I don't believe I've misused the code option: I didn't use code formatting in the answer that I was having trouble with. In this question however, I've formatted the block-quote with code because I wanted to show the markdown I was having trouble with. Is that what you're referring to? – Wayne Conrad Jul 6 '15 at 14:33
  • Alright, so I needed to put the "turn off the highlighting" tag before the indented portion of the block-quoted text (not before the entire block-quote). That seems obvious now that you pointed it out. Thanks. – Wayne Conrad Jul 6 '15 at 14:37
  • 1
    @Way I was referring only the answer you linked. I've said nothing about this question. To show the markdown, it's the very acceptable way to use the code formatting. – nicael Jul 6 '15 at 14:37

You must log in to answer this question.

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