# CommonMark testing started here!

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

1 Like

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

https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/lib/text.js.es6#L26-L33

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;
viewPost.save(props);
});


3 Likes

Will image alignment be made possible with commonmark?

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?

2 Likes
4 Likes

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="https://community.namati.org/uploads/default/original/2X/4/44c8fd629b36d97fe0c6e618fc99bb84497768bd.jpg" width="170" height="125" align="left">](https://namati.org/network/member/LucyClaridge) 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.

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.

@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)

Yeah… you are going to need this PR

https://github.com/cpradio/discourse-plugin-checklist/pull/9

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

Just import the helper using:

// import like this for backwards compat, add a comment
require('pretty-text/engines/markdown-it/helpers').inlineRegexRule


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.

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.

Edit:
Figured it out, this errant return; statement
https://github.com/cpradio/discourse-plugin-checklist/pull/9/commits/1ff70f501da887b1486a2d97f265e2d6a7dbf298#diff-58d619630012ba3d44eea8bdb4f2440bR114

However, there is already : 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)
https://github.com/cpradio/discourse-plugin-checklist/pull/9

2 Likes

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 ?

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

3 Likes

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

7 Likes

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?

1 Like

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.

4 Likes

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.”

2 Likes

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

2 Likes