TiddlyWiki / TiddlyWiki5

A self-contained JavaScript wiki for the browser, Node.js, AWS Lambda etc.
https://tiddlywiki.com/
Other
8.07k stars 1.19k forks source link

[BUG] Markdown plugin won't render footnote marks #5993

Open david-bakin opened 3 years ago

david-bakin commented 3 years ago

Markdown plugin does not render footnote markers[^1] - the superscripts at the footnote reference and the footnote definition

[^1]: This is footnote 1, missing its markers.

remarkable.js is supposed to be able to do this (as well as superscript/subscript, if configured) even though GitHub-flavored Markdown does not support it (so you can't actually see it here, sadly).

In fact, it is trying to render it, which you can see if you add the footnote definition first - the [^1]: foo part - it won't render until you add the footnote reference (the [^1] part) (and then it will suddenly show up, without its marker).

Same for superscript and subscript (which I enabled by directly editing $:/plugins/tiddlywiki/markdown/wrapper.js as described here in the remarkable.js documentation, and then saving and reopening the tw.)

To Reproduce:

  1. Enable markdown plugin of course.
  2. Create a markdown tiddler.
  3. Enter the following:

    This is a test of footnotes[^1] - is a little superscript `1` rendered just after the `s` of footnotes?`
    
    ---
    
    [^1]: This footnote definition is missing its marker too.
  4. Observe that the markers are missing.

This is how it looks on a randomly-chosen online Markdown editor (happens to be dillinger.io):

image

TiddlyWiki Configuration:

Desktop:

Works same (i.e., fails same) on both Windows 11 Preview and Windows 2012 R2 Datacenter running both Chrome 91.0.4472.101 and Brave 1.4.96. (Anyway, the way the renderer "eats" the footnote definition until the footnote reference is defined (and also eats superscript/subscripts entirely) shows this 99.9% surely isn't a OS or browser issue.)

Additional context:

It would be nice if a couple of other remarkable.js options were either enabled permanently of via the usual TW plugin options, specifically: superscripts, subscripts, and deleted text. Can't really use KaTeX math mode for the superscripts/subscripts because it doesn't work directly in Markdown tiddlers AFAIK (you have to create a separate wikitext tiddler for it and transclude it, right? Update: Actually I see that KaTeX support in Markdown was added recently which is sweet, but post 5.1.23, guess I'll just wait for it.)

Yet more context:

I mentioned above how excellent the GitLab saver is. Let me mention it again. Gives me automatic sync between computers for all my TWs. Boy does that beat the heck out of what we used to do in the TW4 days ...

pmario commented 3 years ago

Here is the CommonMark Spec: https://spec.commonmark.org/0.30/ There is no "footnote". .. So which markdown dialect do you use.

pmario commented 3 years ago

Boy does that beat the heck out of what we used to do in the TW4 days ...

q:) the jump was actually bigger. TW2 -> TW5

david-bakin commented 3 years ago

@pmario - yes, footnotes are not CommonMark - but they're frequently implemented (in exactly this way) as an extension to Markdown, and the remarkable.js README specifically mentions it is supported (along with superscripts and subscripts) and points to the Pandoc documentation here to tell you how to do it.

(Tables, supported very nicely by the Markdown plugin, aren't in CommonMark - astonishingly! - and that spec you linked has quite a few examples showing how to use HTML in Markdown to define them - and how annoying that would be if we had to use them! So I'm glad the Markdown plugin isn't restricted to CommonMark ...)

(I don't know how definitive the site https://markdownguide.org is but they have a page that describes common "Extended Syntax" elements and footnotes are there (along with tables and other things).)

(And, oh yeah - I did forget "classic" TW wasn't v4!)

pmario commented 3 years ago

@pmario - yes, footnotes are not CommonMark - but they're frequently implemented (in exactly this way) as an extension to Markdown, and the remarkable.js README specifically mentions it is supported (along with superscripts and subscripts) and points to the Pandoc documentation here to tell you how to do it.

Yea, sorry. I thought, there would be a configuration option. ... But that was the "old" library that had one.

pmario commented 3 years ago

I think the issue is valid. We should have some more configuration options, to enable that stuff. "sub" and "sup" should be default.