11

When one writes code in a question or answer, the live preview treats the # character as a comment.

Compare

alt text

with

alt text

The first is screenshot taken while asking a new question. The second is a screenshot taken of an existing answer.

And on meta, there is no formatting at all.

alt text

\def\foo#1{xxx}

4 Answers 4

4

This can be fixed by added the CSS classes prettyprint lang-tex to all pre tags in the preview. This should be configurable in some template. The lang-tex class is normally added by the following tag:

 <div style="display:none" id="prettify-lang">lang-tex</div>

At the moment it is still set to default:

 <div style="display:none" id="prettify-lang">default</div>
6

I believe preview uses "generic inferred" syntax highlighting, whereas the final posts should use "we assume all code posted to this site is Tex" syntax highlighting.

(yes, this also means if you use a code block that does not contain TeX you will get bad results. I recommend using <pre> instead, but be aware that you have to escape any < or > within.)

0
6

It seems to me this behavior doesn't happen anymore. Entering \def\foo#1{xxx} on the main site gives me the following preview (zoomed in heavily):

#1{xxx} isn't gray anymore, so I believe this question is "solved".

1
  • Good to know. Thanks!
    – TH.
    Commented Nov 2, 2011 at 22:11
4

The preview of code blocks is completely messed up as it doesn't know that you're typing some version of TeX. Please have a look at Geoff's comment to his answer about syntax highlighting. If you want to know what I mean by "completely messed up", have a look at my comment to Geoff's answer and follow the link I put there. This is what I got in a preview:

1
  • Ah, okay. So this is a known issue.
    – TH.
    Commented Jan 18, 2011 at 15:46

You must log in to answer this question.

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