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

This question already has an answer here:

How can I make a word in a code sample bold? I only see asterisks around the expected bold text.

sample **sample** sample
share|improve this question

marked as duplicate by Shadow Wizard support Nov 24 at 9:20

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

You are not quoting, you are formatting the text as code / preformatted. – Martijn Pieters Jun 8 '13 at 9:07
Re: your edit, there is no way to use markdown formatting inside code samples. By definition, content in code samples is rendered verbatim. – Frédéric Hamidi Jun 8 '13 at 9:20

4 Answers 4

up vote 25 down vote accepted

Use <pre> formatting and HTML tags.

sample <b>sample</b> sample


sample sample sample

Since you can use other HTML tags as well, this is nice for including inline documentation for commands or classes, etc.:

<i><a href="http://manpages.ubuntu.com/manpages/dapper/man1/prename.1.html">rename</a></i> ’s/\.bak$//’ *.bak


rename 's/\.bak$//' *.bak

But, with any formatting tricks, please don't overdo it.

share|improve this answer
I'm noticing that if the underlying code would overfill the page, instead of automatically making a horizontally scrolling box, the <pre> approach just pushes to a second line and ruins the formatting. Is there a way around this? – MichaelChirico Nov 16 at 21:06
Not that I am aware of. I think that still, if you're copypasting that code, the line breaks would be correct. – slhck Nov 16 at 21:55
well, the line breaks are respected.. just that there's too many of them – MichaelChirico Nov 17 at 1:13

Disclaimer: I do not condone this, I'm just pointing out a possibility (for the sake of completion)

Markdown-only hack

The basic idea is to apply bold/italic formatting to backtick-enclosed string (instead of applying within the backticks), then put the code spans side by side so that they render as a single code span.

Formatting (bold and italic) in emulated code block

Huge drawback: no syntax highlighting

  1. Bold formatting

    > `sample`**`sample`**`sample`

    outputs as:


  2. Italics formatting

    > *`rename`*`'s/\.bak$//' *.bak`

    outputs as:

    rename's/\.bak$//' *.bak

Formatting in code span

  1. Bold formatting


    outputs as


  2. Bold and italics side by side


    outputs as


    You need a non-printing character or a zero-width character (e.g. zero width space &#8203;) to separate the markdown for bold and markdown for italics.


  1. Hackish, clumsy and unsightly (way less readable than its HTML counterpart)
  2. The emulated code block cannot be syntax highlighted compared to a real code block
  3. When you line up two code spans (with different formatting) side by side, there is always a space in between.

    So it's not possible to apply say bold formatting to a string within double quotes like print "Hello world"; without a space between the string and quotes.

    `print "`**`Hello world`**`";`

    would render as

    print "Hello world";

  4. Others (left as exercise to the reader)

share|improve this answer

Make it an actual quote instead of a code fragment, by prefixing the text with > instead of four spaces.

The following markdown:

> sample **sample** sample


sample sample sample

share|improve this answer
But then it's not code anymore… – slhck Jun 8 '13 at 9:21
Yup, the question was originally about quotes, not code samples. – Frédéric Hamidi Jun 8 '13 at 9:22

This is quoted an Bold

Select your word, make it bold.

Select Full string and make it quoted.

Which is > This is quoted an **Bold**

share|improve this answer
This is not what the question is about. Quote is NOT code. – Shadow Wizard Sep 17 at 10:33

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