0

I am trying out CommonMark at http://spec.commonmark.org/dingus/

I want the following HTML output, i.e. Foo and Baz are emphasized but Bar is not emphasized.

<p><em>Foo</em> *Bar* <em>Baz</em></p>

I tried various inputs, but none of them works. I am providing a list of various CommonMark input and HTML output below for attempts that did not work.

  1. Input:

    *Foo* *Bar* *Baz*
    

    Output:

    <p><em>Foo</em> <em>Bar</em> <em>Baz</em></p>
    

    Result: Of course, this does not work!

  2. Input:

    *Foo* <span>*Bar*</span> *Baz*
    

    Output:

    <p><em>Foo</em> <span><em>Bar</em></span> <em>Baz</em></p>
    

    Result: Bar is still emphasized. This is in agreement with point 7 of the spec regarding HTML blocks where it is clearly mentioned that the <span> must occur on its own line.

  3. Input:

    *Foo*
    <span>
    *Bar*
    </span>
    *Baz*
    

    Output:

    <p><em>Foo</em>
    <span>
    <em>Bar</em>
    </span>
    <em>Baz</em></p>
    

    Result: Baz is still emphasized. This time <span> occurred on its own line. Why did it still not work?

How can I achieve the desired result while conforming to CommonMark?

Lone Learner
  • 18,088
  • 20
  • 102
  • 200
  • @Chris Oops! You are right. I have fixed the desired output now in the question. The desired output is: `

    Foo *Bar* Baz

    `.
    – Lone Learner Aug 16 '17 at 16:47

1 Answers1

1

The documentation explains that

Escaped characters are treated as regular characters and do not have their usual Markdown meanings

This should give the output you want:

*Foo* \*Bar* *Baz*
ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257