Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create <span> element with markdown (kramdown)

Tags:

html

markdown

Is it possible to create a span element with markdown? I'm using the Kramdown converter.

Thanks!

like image 262
marchello Avatar asked Jan 14 '23 20:01

marchello


1 Answers

According to the Markdown syntax spec/documentation, you should be able to use a plain HTML <span> element. Additionally, the Kramdown documentation has an entire section on using HTML elements in general, and <span> in particular.

From Kramdown's docs:

HTML tags cannot only be used on the block-level but also on the span-level. Span-level HTML tags can only be used inside one block-level element, it is not possible to use a start tag in one block level element and the end tag in another. Note that only correct XHTML is supported! This means that you have to use, for example, <br/> instead of <br> (although kramdown tries to fix such errors if possible).

By default, kramdown parses kramdown syntax inside span HTML tags. However, this behaviour can be configured with the parse_span_html option. If this is set to true, then syntax parsing in HTML spans is enabled, if it is set to false, parsing is disabled. It is also possible to enable/disable syntax parsing on a tag per tag basis using the markdown attribute:

  • If an HTML tag has an attribute markdown="0", then no parsing (except parsing of HTML span tags) is done inside that HTML tag.

  • If an HTML tag has an attribute markdown="1", then the content of the tag is parsed as span level elements.

  • If an HTML tag has an attribute markdown="block", then a warning is issued because HTML spans cannot contain block-level elements and the attribute is ignored.

  • If an HTML tag has an attribute markdown="span", then the content of the tag is parsed as span level elements.

like image 61
Shauna Avatar answered Jan 17 '23 17:01

Shauna