CommonMark testing started here!

I need to specify any possible size, this becomes super critical stable layout on the page.

I guess what you are trying to determine here is if we could have a custom post processing job that injects size into the HTML and takes this decision away from the user.

My answer to this would be … maybe… If you upload retina you want to specify the smaller size so the retina screens get high fidelity and non-retina just get scaled down. It is possible we could glue this information into an EXIF tag or something and then have a post processor magic an SRCSET. But it would be a huge change.

line breaks between <img> tags

We absolutely need to deal with this cause we have tons of history, I can hack html_block.js to support this edge condition quite easily. But I also think the spec needs an adjustment here.

sepecifying custom image size

I also think the spec should deal with this, especially cause of the HiDPI concern.

In general, everything is blocked by spec. I can explain solutions i know, but all those are not ideal.

Image size can be defined:

  • via html
    • Not convenient.
  • via maruku-like syntax ({attrs} after any markdown element, see “consistend attributes syntax” thread at CM forum)
    • Require parser core update for correct work. Such deep core updates are not welcome without spec change
    • This open the road to tons of vulnerabilities without sanitizer. That’s the main reason why i don’t like this feature to be enabled by default.
    • Can be hacked via image rule replace, but that’s too dirty, because code itself is a bit complicated.
    • Not sure this will ever go to spec.
  • via alt attribute content
    • [alt text|100x200](http://....), [alt text|small](http://....)

So, i described the situation, but don’t like to take responsibility for your choice. IMHO, right now every choice is not ok. Because problem is on spec level, and i can’t push it forward. In nodeca, i decided to use alt content, but only to select between predefined sm|md|orig sizes, not to set WxH. Also, nodeca does not pretend to define de-facto standards.

About keeping breaks between <img> tags. IMHO it’s impossible to solve this problem easy on spec level. Because if you have a line with <img> tag only, it’s impossible to say, is it a raw block, or paragraph with raw inline element. I think, right now it’s better to hack html_block rule to filter out <img> tags - more easy to update in future.

5 Likes

Thanks heaps, totally understand, we are just stuck with no ideal solution here.

I really like this syntax proposal cause it is far simpler to parse and the Markdown looks much cleaner. Sure it is not as “flexible” as maruku like syntax but it is far prettier. I think we may migrate to it.

1 Like

What is the specific markdown that you have that is failing?

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

Without escaping the * on one of the two items, it causes the text Item Two, Item Three to be rendered as italic and therefore the [*] doesn’t render as a checked checkbox, but rather []

If there was a way to force my rules to apply before <em> gets applied to *, it would solve my issue, as my rendered output would negate the parsing of * into <em>. But I’m not sure that is really advisable.

This is a GIANT conundrum.

Regarding:

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

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

At the moment I changed it so we apply the checkboxes AFTER all the inlines happen.

Otherwise stuff like http://test.com?[*] would be rendered as a checkbox which is far from desirable.

We can easily push it up in the chain so it happens prior to applying italics, but then we break automatic links.

The “standard” unofficial plugin also does the application in a core rule (I assume for the link reason)

I really don’t think this can be resolved, I would recommend just documenting this issue. A newline here would fix it anyway or making it a list or escaping.

@Vitaly any thoughts here about the checkbox plugin?

1 Like

OK I fixed the img tag by adding this new block rule.

https://github.com/discourse/discourse/blob/master/app/assets/javascripts/pretty-text/engines/markdown-it/html_img.js.es6

It is not ideal, but at least it is reasonably defined and does not mess with the core of Markdown it.

1 Like

That may need format clarification. For example, to allow px, em, rem if needed. I provided only demo to explain principle. Don’t remember details. Seems, CM forum may have threads with more examples.

I’m 100% okay with going the escaping route, I’ll just drop backwards compatibility support as I don’t really have a lot of time to dig into why it isn’t working quite right without markdown-it enabled (feels like something magical and not a simple mistake on my part). Plus it would keep the plugin a bit cleaner and those who do not wish to upgrade (or can’t), can reference a tag to stay on their current version.

I’ve done that in the past, it hasn’t caused any major issues (to date).

On the other hand, I guess I could change the default behavior to mark checked with [x] instead of [*] and that would solve the issue without the need for escaping. I’d probably have to ask the users of the checklist-plugin about that sort of change though. (ping @meglio, @andrejkosyak, @steven, @downey, @Trash)

Then [*] would only be an issue for existing checklists and/or manually updating/creating them and the preview window would be indicative enough to hint you need to escape the *.

1 Like

Known (unresolved) issues are:

  1. What is proper html5 markup for the list of checkboxes?
  2. How to properly update source when user click checkbox (as on github).

I consider such plugin useful, but i not implemented it due lack of good spec. Seems, someone published implementation in npm registry, but can’t comment anything about quality.

Hello!

When i post first an image and than a google maps embed, it does not work:

<img src="//assets-meta-cdck-prod-meta.s3.dualstack.us-west-1.amazonaws.com/original/3X/f/c/fcbef015c1c3ca22a3dbc5ce76cd93ec9c0a8d0e.png" width="336" height="145">

https://www.google.com/maps/d/embed?mid=1G1IM3vW0QqVGMWy7_z05kmkI_is

2 Likes

Interestingly, it works the other way around: first map, then image.

https://www.google.com/maps/d/embed?mid=1G1IM3vW0QqVGMWy7_z05kmkI_is

<img src="//assets-meta-cdck-prod-meta.s3.dualstack.us-west-1.amazonaws.com/original/3X/f/c/fcbef015c1c3ca22a3dbc5ce76cd93ec9c0a8d0e.png" width="336" height="145">
2 Likes

Looks like an issue with any onebox after an IMG tag. Will get it sorted.

7 Likes

Looks like there is an issue with ‘@’ in urls: Apparently links with @ signs aren’t working correctly, example (Medium urls): https://blog.tendigi.com/@nickplee

I just checked with the old markdown engine and links are generated correctly.

Yeah looks like an issue with linkifier @Vitaly should we open an issue on it? https://blog.tendigi.com/@nickplee is not linkifying right.

Issues with new examples are welcome, if:

  1. Request is popular
  2. It will not cause false positives in other places (with emails (??), for example)

I have not seen url-s with @ before. If you know more formal rule than just sample link - please add those too.

1 Like

Not exactly a canonical source, but it doesn’t look like @ is legal in a URL http - Can I use an at symbol (@) inside URLs? - Stack Overflow

According to RFC 2396 - 3.3 @ is valid in some parts of the url. See It Takes a Village To Read an RSS Feed | by Nick Santos | Medium Engineering for more info:

What this is basically saying is that “@” is OK in some parts but not in other parts. The URL “Medium is valid, but “https://medium@/” is not.

7 Likes

Valid and “works in practice” are different things. I know I’ve seen FTP-style https://user:password@example.com/ URLs as recently as this morning.

Without double checking the RFCs, my memory says that that sort of user and password was explicitly allowed for the ftp: scheme and explicitly not included in the http: and https: schemes. But people use it anyway.

4 Likes

Created a markdown-it issue to track the @ sign issue.

5 Likes