CommonMark testing started here!

(Sam Saffron) #49

And with this commit I am done with core!

There are no open issues any more, so I am moving on to fixing up plugins.

(Valentin Churavy) #50

It would be great if we could use this transition as an opportunity to add correct rendering of mathematical equations. There is a common mark plugin to handle this GitHub - classeur/markdown-it-mathjax: Markdown-it plugin to bypass LaTeX math for mathjax processing.

(Evgeny) #51

I don’t know here to write. In this topic. The problem with Russian tags. If the category slug is normally displayed as a link, then the Russian characters in tags - links are not.

(cpradio) #52

That isn’t actually related to markdown-it, it is an existing issue


I enabled the typographer here

Note, smartquotes can be done better. Ideally - with autoselecting proper characters, depending on used language. Existing implementation is a trade off between simplicity and value.

Correct implemenattion in JS will require a lot of unicode constants for language detect. That will make client code too big (read as “can be done on server side only”).

(Jay Pfaffman) #54

There is a mathjax plugin, though if you’re hosted here, that doesn’t help you.

(Sam Saffron) #55

We probably plan to add mathjax to business and up, just need to figure out how to make it light weight enough. After I am done implementing the bbcode plugin I will move to mathjax. Also katex is a reasonable middle-ground which I will explore.


In 99.9% such issues are caused by poor languages support by native JS regexps.

linkify-it/re.js at master · markdown-it/linkify-it · GitHub - this can be used as example of how to replace “ordinary” javascript regexps with proper black magic.

Since all required unicode constants already available via markdown-it / linkify-it, it should not be difficult to fix hashtag plugin.


Kick me, when you find good concept for math expressions. When i investigated this topic, i found 3 problems and postponed everything until better times:

  1. No inline syntax (only block one) for math in commonmark
  2. What dialect to use, how to select?
    • TeX is cool, but asciimath much more simple for ordinary users
    • How can user switch the dialect when asciimath is not enougth?
  3. Custom fonts required. How to load those only when necessary.

(Sam Saffron) #58

Somelink - just another link on the internet :arrow_backward: fails cause of the tag category plugin

(Sam Saffron) #59

OK, I took a shot at the plugin.

For now:

  1. I used $ and the jgm suggested heuristic as to handle cases like 100$ + 200$

  2. I selected TeX cause that is what seem to use so there is lots of prior art.

  3. I embedded the fonts in the plugin, and load on demand.

(Sam Saffron) #60

On Monday we (I) plan to deploy this change to the Standard Tier :confetti_ball: :star_struck: :fairy:

(David Taylor) #61

Found a slightly weird thing - for some reason this doesn’t get recognised as a mention

This is a line of text

This is a line of text

But this works fine

This is a line of text


This is a line of text



Could you explain details, why $inline$ syntax will have no conflicts?

  • what if equation has $ inside (as part of variable name, comment etc)?
  • on i’ve seen that all spaces are replaced with underlines in sources. Is this a mandatory requirement to avoid collisions?

(cpradio) #63

Yeah, that next line is impacting my plugin as well :frowning:

@sam, I do have another issue I’m struggling to work around. It seems markdown-it is only getting setup when the composer is open. My main plugin, is the checklist plugin. Everything works fine when the composer was opened and then closed (without refreshing the page)

Knowing that doesn’t probably make a lot of sense, here is a video of it

The error I receive is

Error: Could not find module `pretty-text/engines/markdown-it/helpers` imported from `discourse/plugins/discourse-plugin-checklist/lib/discourse-markdown/checklist`
    at requireFrom (discourse-loader:128)
    at reify (discourse-loader:106)
    at mod.state (discourse-loader:163)
    at tryFinally (discourse-loader:30)
    at require (discourse-loader:162)
    at eval (pretty-text/engines/discourse-markdown-it:208)
    at Array.forEach ()
    at setup (pretty-text/engines/discourse-markdown-it:206)
    at buildOptions (pretty-text/pretty-text:93)
    at getOpts (discourse/lib/text:23)

What is mind-boggling is it works just fine once the composer is opened and then closed. It only fails to find said helper import if the composer is never opened (you don’t have to type anything in the composer either).

Here is the code I’ve come up with thus far.

The error is being generated from (which I did not alter for markdown-it – not sure I need to)

Edited: Changed the video URL, as I didn’t realize the dev tools was not captured.

(Barry van Oudtshoorn) #64

I’ve got to say that this is probably my absolute favourite improvement that this new engine brings – being able to use double hyphens to produce spaced en dashes is amazing.

Out of curiosity, why the decision to disable the typographer by default? Is it likely to cause issues in languages other than English? Or is it out of fear of breaking existing content on rebake? Given that Discourse is primarily about the reading experience, I think it’d be good to by default enable features like the typographer which improve legibility.

(Sam Saffron) #65

We circled back on this, we may enable it by default in a few weeks, just living with it for a bit now

(Sam Saffron) #66

you would escape it like so: $\$a$

I really do not think so, can you think of an example where this is needed?


No, i just seen something strange on math.stackexchange and asked question about reasons, because you have more experience in this area

(Sam Saffron) #68

Very marginally, I have only been doing MathJax for a few days :mage: :blush: