hoedown/hoedown

Super- and sub-scripts

Opened this issue · 13 comments

I see that there's already support for superscripts as e^2 but nothing for subscript.

I'm wondering whether there's been consideration given to mimicking what pandoc does and supporting

e^2^ and H~2~O?

I'm not familiar with those Pandoc extensions. The problem here is that both syntaxes collide, so if we wanted to embrace Pandoc syntax, we'd have to abandon the current one.

I personally don't see that happening in a near future. Unlike i.e. tables, this is a minor feature with little consensus... Leaving that open for discussion anyway.

Well, there's nothing for subscript now, or is there?

I'd note that the pandoc method has the advantage of having opening and closing "tags" like the other in-line formatting methods. Seems odd to me to abandon that basic concept.

The syntax for superscript right now in Hoedown is ^(contents), while Pandoc is, as you mentioned, ^contents^.

Adopting Pandoc's syntax for subscript would mean adopting Pandoc syntax for superscript as well, which would mean abandoning our current syntax for superscript.

Since superscript is opt-in anyway, couldn’t we just create a new extension (superscript-pandoc) that uses Pandoc’s syntax? Checks can be added to the parser so that they are mutually exclusive.

What do you mean by "mutually exclusive"? We assert that not both are enabled?

Yes.

It's always an option, yeah. AFAIK we've never implemented colliding extensions in Hoedown, though.

Are there other kinds of in-line formatting that don't have a closing tag right now?

It makes sense to me that in-line markup would require one. That's an overall argument for pandoc's approach.

I note that haroopress extends markdown in this way for super/subscripts too:

http://talk.commonmark.org/t/how-haroopress-extends-markdown-reference/757

Current superscript syntax does have a closing tag, it's the ) at the end that closes:

This is ^(in superscript).

But if it's just a word, you can omit the parentheses like so:

There is ^superscript here.

It doesn't quite behave like a closing tag for the "opening tag" ^:

  1. It's optional, as you point out: one^1 = one1
  2. It only works when there's a matching ( right after the ^: one^1) = one1), not one1; one^1() = one1()

And then that leaves the ^ as what exactly?

Are there other places where () are used?

What I'm getting at is that the syntax for superscripts is anomalous.

Look at it that way: ^( is the opening tag, ) is the closing tag. On that line, "asymmetrical" tags like these, with an extra character, aren't that rare: inline footnote ^[content] image ![content] math \(content\)

But I see your point. Using the same delimiter for closing and opening (as Pandoc does) resembles emphasis, stikethrough, highlight and a lot more so I'd agree that ^content^ is more consistent with Markdown syntax in general. I wouldn't care much anyway. I care more about consensus when picking syntaxes.

Right, I see what you mean, though the other asymmetrical examples aren't quite parallel since they're more like macros, creating tags with attributes or, in the case of footnotes, much more than that.

In any case, I've made my position clear, so I'll simply say that in pandoc we have an existing implementation that's consistent with other in-line formatting tags, and it seems sensible to me to support that, even if through an extension.

I'd love to revive this issue as markdown has been gaining traction for scientific texts over the past few years. Subscripts are quite frequent in many fields (e.g., chemistry and physics, obviously). It would be nice to have at least some version of subscripts. FWIW I personally prefer H~2~O to H~(2)O and ^14^C to ^(14)C for reasons of consistency with other delimiters, but anything functional would be great, frankly.