CommonMark testing started here!

(Sam Saffron) #69

Yeah, you have to use cookAsync from now on, will check in a deprecation message there.

So your new code would be something like:

  let props = {
     raw: new_raw,
     edit_reason: 'checklist change',  

  cookAsync(new_raw).then(cooked => {
      props.cooked = cooked.string;;

(Tobias Eigen) #70

Will image alignment be made possible with commonmark?

(Sam Saffron) #71

Not much progress in the CommonMark world there…

But … since we already only use HTML based image metadata, whitelisting a few classes is super easy in a plugin.

@codinghorror I wonder if we should just whitelist a few here out of the box?

(Sam Saffron) #72

We are back to no open bugs per:


(Tobias Eigen) #73

Cool - thanks for thinking about image alignment, which may seem unimportant in the grand scheme of things but would be a big help to us.

Right now, my colleague is trying to display some profile pictures with biographical details attractively over here on my discourse.

Interestingly, I was able to get something close to attractive on the commonmark.js demo site:

Here’s the code I used to create that:

[<img src="" width="170" height="125" align="left">]( Lucy Claridge (@LucyClaridge)  is Legal Director at Minority Rights Group International, where she manages the legal department.  Her work uses strategic litigation, advocacy and capacity building to improve access to justice for minority and indigenous communities worldwide, with a particular focus on land rights, political participation and wider anti-discrimination issues.  Casework includes the recent Ogiek land and conservation case against Kenya before the African Court of Human and Peoples' Rights.

(Jeff Atwood) #74

Nah we are fine as is. I don’t want to whitelist a ton of random stuff that we don’t need, every one is a security risk in the long term.

(cpradio) #75

@sam, so that works great for when markdown-it is enabled, however, when it is disabled, I now get

ember:19818 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:13)
    at reify (discourse-loader:106:22)
    at mod.state (discourse-loader:163:17)
    at tryFinally (discourse-loader:30:14)
    at require (discourse-loader:162:5)
    at eval (pretty-text/engines/discourse-markdown:381:26)
    at Array.forEach ()
    at DialectHelper.setup (pretty-text/engines/discourse-markdown:379:40)
    at setup (pretty-text/engines/discourse-markdown:456:12)
    at buildOptions (pretty-text/pretty-text:59:36)

It seems to not like my importing of the helper when markdown-it is not enabled. Is there a way to avoid that error? I tried using

  if (helper.markdownIt)
    const prettyTextHelper = require('pretty-text/engines/markdown-it/helpers');
    helper.registerPlugin(md => {
      const ruler = md.inline.ruler;
      ruler.push('checklist-strikethrough', prettyTextHelper.inlineRegexRule(md, {
        start: '--',
        matcher: /--(.*)--/i,
        emitter: applyStrikethrough

      ruler.push('checklist-empty-checkbox', prettyTextHelper.inlineRegexRule(md, {
        start: '[',
        matcher: /\[([\s_\-x\*]{0,1})\]/i,
        emitter: applyCheckbox

versus an import at the top, but that didn’t work. Otherwise, I may just have to leave this in a branch until markdown-it becomes the default (which I’m not opposed to)

(Sam Saffron) #76

Yeah… you are going to need this PR

Note you can do the strikethrough like you had with the inline regex, but checkboxes you can not. You need to apply at the end of the chain otherwise there be :dragon:

Just import the helper using:

// import like this for backwards compat, add a comment

I think I will clean the API up a bit so we just hang the helpers of the md object then you don’t need to import anything.

(cpradio) #77

Hmm, I’m struggling getting that PR to work. I’ve pulled it in locally, kicked up the docker dev environment, but I can’t get the checkboxes to show with or without markdown-it enabled.

I’ve even completely destroyed the docker dev environment and re-initialized.

Figured it out, this errant return; statement

However, there is already :dragon:: with the current implementation, given the following, it breaks

[] Item One
[*] Item Two (should be checked)
[ ] Item Three
[*] Item Four (should also be checked)

Actual output:, Items Two through Four are italized.

I’ve got that fixed, however, now with markdown-it turned off, the fix for the italize is causing checking a checkbox to not show properly (preview pane shows it properly though when you edit the post afterwards).

It is only breaking with markdown-it disabled. But for the life of me, I haven’t a clue why, as when I trace it down, it is replacing [\*] with the appropriate span tag and classes, but when it saves the post, the [\*] reappears from seemingly nowhere…

Granted, this can happen with [_] as well on new markdown-it, but that value can’t be generated by clicking the checkbox, so the user should see the issue and escape it before it is submitted. Only [*] is capable of being written based on the user clicking a box.

Updated PR to look at (which has your PR and the fixes I described above – and the issue with markdown-it disabled)

(Daniela) #78

I see that headings have changed from ##heading to ## heading (with a space).
What happens to the old topics that use ##heading instead of ## heading after the upgrade?

We have to do a remap as describe here Replace a string in all posts ?

Narrative bot and CommonMark
The #Header markdown syntax stop working
(Rafael dos Santos Silva) #79

If you don’t rebake old posts they will keep the current generated HTML.

(Eli the Bearded) #80

And become a time bomb, waiting to break in the future.

(Joshua Rosenfeld) #81

I’ve already seen a topic of mine here on Meta break. Sub-bullets now need two spaces, not one, so when someone edited a wiki post of mine my bulleted list broke.

I wonder @sam if any sort of migration script is planned?

(Sam Saffron) #82

Very super undecided on a migration script. The concern I have is that it is possible a migration script can mess stuff up more than it will actually help.

I am semi open to making a script that fixes up bad multiline quotes (one’s that start mid line) and maybe the title thing.

Will think about it.

The #Header markdown syntax stop working
(Eli the Bearded) #83

If you store bake time and switch to new engine time, you can punt on a script to deal with later, or to just highlight warnings when appropriate.

“You are editing a post that predates the current parser. Please double check that the syntax still works as expected.”

(Jeff Atwood) #84

No, this is not needed at all. I would not bother. People can fix up the rare affected posts themselves.

The #Header markdown syntax stop working
(cpradio) #86

@sam, can you think of a better way than to deal with two checked items in the checklist producing italized content without escaping the *?

I plan to mess around with the plugin a bit more this week, but I may just ditch trying to support backwards compatability and just wait for the markdown-it to be official and default. I’ve used the approach in the past, by simply tagging a prior version of the plugin and older installs can utilize that (if they are not ready to upgrade).

(Sam Saffron) #87

@Vitaly I have come across an interesting edge case here.

At Discourse we use “raw” html for images cause we need to specify size and sadly you can not specify size in CommonMark (which for the record makes me super :sadpanda:)

So if you have:

<img src="//" width="202" height="148">
<img src="//" width="202" height="148">  
<img src="//" width="202" height="148">

It will render as:

Despite newline being enabled here. This happens cause there is no “inline” defined for the images.

I can work around with:

<img src="//" width="202" height="148">&nbsp;
<img src="//" width="202" height="148">  
<img src="//" width="202" height="148">


I guess I just need a custom inline rule here that wraps and <img in an inline.

Also opened this up:


Do you need to specify any possible size or select from pre-defined set?


I think we need to split problem. Is it about:

  • sepecifying custom image size
  • line breaks between <img> tags
  • both