Formatting in comments

The comments to the posts here are generally very helpful. I appreciate your contributions to the site.

I wanted to offer a tip for those who leave comments and are frustrated by the way the comments appear, especially those who write nicely formatted snippet of code only to see the formatting lost. There is a way to post formatted code.

Comments can use basic HTML markup. In particular, you can wrap a section of code with <pre> and </pre> and the levels of indentation will be retained.

Sometimes I see that someone has left a block of code wrapped between <code> and </code> tags, but this doesn’t do what they expected. That’s because <code> is an inline element and <pre> is a block element. The former can be used in the middle of a sentence, such as referring to the qsort function, but for multiple lines of code you need the latter.

The comment editor does not accept LaTeX markup, but you can write a fair amount of mathematics with plain HTML.

Thanks again for your comments.

3 thoughts on “Formatting in comments

  1. Thanks for the tips. And since we’re on the subject, I’ve been wondering if/how comments are held for moderation. Often when I leave a reply it won’t show up immediately and I wonder whether or not it “went through”, but when I come back the next day it will have shown up.

    I do use a browser with lots of Javascript disabled, so that might be interfering with the posting mechanism somehow. If that’s the case then it’s clearly down to me.

    If replies are held for moderation, maybe you could add a note (like “Comments are moderated and may not show up immediately”) next to the “Post Comments” button. I do agree that you get high-quality comments, but people can get discouraged from creating if they think they’ll go for naught (cf. math.stackexchange).

  2. (As two data points, my comment on your sum of squares post had the delay described, but my comment just above here showed up immediately. So weird???)

  3. Jonathan, yes comments are held for moderation, and so it may take a while for a comment to appear. I approve the large majority of comments, but not all.

    I also have my spam filters turned up high. Unfortunately that results in some legitimate comments being blocked, but it’s necessary.

Leave a Reply

Your email address will not be published.