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

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
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 13 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

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

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

You must log in to answer this question.

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