Feature Request: underline text

It would indeed be a breaking a change. Since CommonMark aims to be highly compatible, it is unlikely that this option would be adopted.

Interestingly, in Markua _ represents emphasis but renders _my emphasised text_ as my emphasised text by default, with the type of emphasis configurable as a global setting. You can write something like this to make it explicit and toggle the italicize-underlines options on and off:

{
italicize-underlines: true
}

# Chapter One

stuff

foo _bar_ baz

lorem *ipsum* dolor

stuff

This is another language though, one which doesnā€™t have the compatibility constraints of CommonMark. If CommonMark were to override the _ syntax it would need to be turned off by default, creating divergence between documents that render emphasis one way and documents that render it another. This would create confusion for writers switching between different CommonMark documents. You could have an associated override specification for defining what class additions should map to what syntax variations, but thatā€™s starting to get messy.

I do think there is a legitimate use case for presenting text as underlined, for example by rendering emphasis as <em class="underline">. As a global setting, this can be done via a preprocessor. For particular variations, you could use the proposed class syntax extension, e.g.

*my text*{.underline}

The question is whether we need a specific syntax for this. Perhaps the class syntax is sufficent?

The mostly backwards compatible and visually intuitive solution for underlined text is still using four underscores on both sides.

_i_ *em*
__b__ **strong**
___b i___ ***strong em***
____u____ ****?****

Markua does confirm what I said before:

This is unfortunate, since underline is not always just a typewriter version of italics. In some languages and in some contexts, underlining serves a distinct, legitimate purpose.

Underlined text is indeed a legitimate purpose, and CommonMark has to consider that.

If CommonMark were to override the _ syntax it would need to be turned off by default, creating divergence between documents that render emphasis one way and documents that render it another.

@chrisalley It is a breaking change, but the question is how bad this change would be?

  1. The inventors of markdown decided to render emphasized text in italic and strong-emphasized text in bold, and I consider that unfair because we already have 2 different ways to write emphasized/strong emphasized text, but despite that, they didnā€™t specify anything to be rendered as underlined, and thatā€™s probably due to their Anglophonic backgrounds, and I totally understand that underlined text isnā€™t a common/recommended way to write emphasized text in English.

  2. Underlined text is still considered to be emphasized text, at the end we will just change the way some emphasized text in old documents is rendered, but it will remain emphasized, so this is not a big deal, remember that!

  3. Itā€™s rare for anybody to use __text__ instead of **text**.

I think I made my point.

Edit: Yes Iā€™m aware that browsers render <strong> in bold and <em> in italic by default.

1 Like