CommonMark testing started here!

And with this commit I am done with core!

https://github.com/discourse/discourse/commit/d941ed90d6c12a8bf0c8b922076cb6eca8114816

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

8 Likes

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 https://github.com/classeur/markdown-it-mathjax

3 Likes

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.

3 Likes

That isnā€™t actually related to markdown-it, it is an existing issue

2 Likes

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ā€).

2 Likes

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

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.

5 Likes

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

https://github.com/markdown-it/linkify-it/blob/master/lib/re.js - 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.

2 Likes

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.
6 Likes

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

2 Likes

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 math.stackexchange.com seem to use so there is lots of prior art.

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

6 Likes

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

8 Likes

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

This is a line of text
@sam

This is a line of text
@sam


But this works fine

This is a line of text

@sam

This is a line of text

@sam

4 Likes

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

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

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
http://nimb.ws/UNn5gb

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.

https://github.com/cpradio/discourse-plugin-checklist/compare/markdown-it?expand=1

The error is being generated from (which I did not alter for markdown-it ā€“ not sure I need to)
https://github.com/cpradio/discourse-plugin-checklist/blob/master/assets/javascripts/discourse/initializers/checklist.js.es6#L47

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

4 Likes

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.

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

5 Likes

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

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

1 Like