What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 134 Stack Exchange communities.

In this post I tried to add language hints for syntax formatting to code blocks quoted from the question. However, it seems they won't be honoured if I write them as a comment in my own part of the post, and if I include the hint in the qutotation as well then I have some ugly empty space before the code block. There should be a way to write these things properly.

share|improve this question

1 Answer 1

up vote 8 down vote accepted

Wrapping a codeblock (and only a codeblock) in a blockquote seems, at most, a rare edge case; to be honest I personally find it quite useless. There is however a way to achieve what you want.

<!-- language: ... --> hints only apply to the immediately following code block, which is the reason it doesn't work when the thing immediately following the language hint is a blockquote. There's however a second kind of language hint: The global override <!-- language-all: ... -->. This will apply the language to all subsequent code blocks (unless they have their own language hint, and until superseded by a new global override).

Thus adding <!-- language-all: lang-none --> to the top of your post (and removing both <!-- language: lang-none -->) will do exactly what you expect.

share|improve this answer
    
Does it mean that if on Drupal Answers I want to quote both the JS source and PHP source when facing a problem with AJAX, I'm by design unable to do it properly? –  Mołot Sep 23 '13 at 7:54
    
@Mołot You'd need to give one or both of those a syntax highlighter hint, which is exactly why those hints exist - using them is doing it properly. –  doppelgreener Sep 23 '13 at 7:59
    
@JonathanHobbs for consistency when quoting API docs, and to be as clear with copyright issues as possible. And the point is I wasn't able to do what you say and my report was closed as a duplicate of this one, so I assume it's impossible. If you know a proper way, please flag my question for reopen and answer it when possible. –  Mołot Sep 23 '13 at 8:02
    
@Mołot I fixed your syntax highlighting hints, which you had actually made a mistake with. –  doppelgreener Sep 23 '13 at 8:07
    
@Mołot a) As I said in the answer, you can override global language hints, either with a new global hint, or a specifc hint for a particular code block. b) This is only an issue if the code block is the very first thing that appears in the blockquote. In all other cases, the "ugly empty space" thing isn't a problem, and thus you can post normal language hints anyway. –  balpha Sep 23 '13 at 8:08

You must log in to answer this question.

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