Literal asterisks in markdown

I’m not sure if this is a brainfart of mine, or a bug, but I can’t get a literal asterisk in my markdown. The following:

md`I want a *literal \*asterisk*`

shows as " I want a literal asterisk* " instead of “I want a literal *asterisk” (here in the forum is does work as expected).

The quick fix employed, btw:

md`I want a *literal ${html`*`}asterisk*`

Hmm. This looks like a bug in our Markdown library:

Glad you found a workaround. I would expect a double backslash to work, also, but I think we need to patch Marked to fix that.

Possibly related?

Is it possible to include a code snippet within a markdown block?

I would like to express something like:
Please use the myObjectType for this purpose,
but the markdown interpreter fails for this.
image

Sure thing - that’s a different issue, with thankfully a simpler fix :slight_smile:

md is a tagged template literal - it’s a function (md) and a new JavaScript feature (those backticks). So, like other strings in JavaScript - if you were to create a double-quoted string, and you wanted to put double quotes in that string, you need to escape them:

x = "They said "hi" I think" // an error

// Instead you want to escape those:
x = "They said \"hi\" I think" // works

Since template strings use the backtick as their start & stop symbols, to use them inside of a markdown string, you’ll need to escape them the same, with \. For your example, it’d be like

md`
Please use \`myObjectType\` for this purpose
`
2 Likes

You may also use <code>myObjectType</code>.

1 Like