4

After banging my head against the wall on this question, I resorted to simply using lots of BR HTML tags so that I could markup the answer to highlight certain parts.

Surely, however, I'm not the only one that has needed to do this. Is there a way to indicate a particular set of text as preformated and/or monospace, but still allow text formating?

If the META site isn't the right place for this question, please move as necessary. Thanks!

4

If the META site isn't the right place for this question, please move as necessary.

You've come to the right place :-)

After banging my head against the wall on this question, I resorted to simply using lots of BR HTML tags so that I could markup the answer to highlight certain parts.

Underlined text is not supported by Stack Exchange Markdown; however, the other formatting choices are...

At the moment, you're inserting <br> tags in your answer; you wouldn't need to do that if you used Markdown preformatted text. However, you're also asking for underlines / bold, which aren't supported by Markdown preformatted text. I normally resort to ASCII email techniques to emphasize preformatted text... for instance:

$ dig example1.com +noall +answer +identify
example1.com.           86062   IN      A       69.94.109.156
                        ^^^^^
;; Received 46 bytes from 72.3.128.241#53(72.3.128.241) in 2 ms
                          ^^^^^^^^^^^^^^^

This is clunky, but Markdown is not likely to ever give us the combination of pre-formatted text and bold, as you originally posted. Preformatted markdown text seems to exclude other Markdown formatting (such as bold) because you don't want to put restrictions on what can be pre-formatted.

For instance, if I write an Stack Exchange answer about HTML, I need to be able to escape from the default html rendering to write <br> or <img src="http://upload.wikimedia.org/wikipedia/commons/5/5d/Guacamole.jpg">. I certainly don't want random line breaks or photos in the answer :-).

So, you either need to:

  • Add html tags to non-preformatted text, which is what you did
  • Use Preformatted (monospace font) Markdown, combined with ASCII highlight techniques as I illustrated above.

FYI, I made the mistake of removing your feature request tag from the question... I will add it back upon re-reading the question.

1
  • Fair enough. I see how Markdown and Preformating are two entire worlds that almost oppose each other. But I do think it would be useful for a second way of indicating a block of text is Monospace font, but still allows markdown. Maybe leave four spaces for preformated working as is, and add another 'markdown option' of underscore+3 spaces to indicate a monospace font that allows Bold/Italic. – Eddie Nov 20 '14 at 17:06
2

Our help/editing-help page probably has what you're looking for.


Edit to add: The trick is to use ><code></code> tags and <br> instead of newlines. Source from the answer comments

$ dig example1.com +noall +answer +identify example1.com. 86062 IN A 69.94.109.156
;; Received 46 bytes from 72.3.128.241#53(72.3.128.241) in 2 ms

3
  • I see how to make something preformated. But not how to highlight/bold/italic/underline preformatted text. Unless I'm missing something, in which case, could you please provide an example? – Eddie Nov 18 '14 at 17:27
  • And if you look at it now, the html has <strong> around it, but the font-weight: bold has no visual effect. (in chrome anyway.) – Ricky Apr 24 '15 at 4:38
  • I've only checked with Firefox and the text does show up bolded. There's a reason I don't do web-programming... – cpt_fink Apr 27 '15 at 2:43

You must log in to answer this question.

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