pub-dev icon indicating copy to clipboard operation
pub-dev copied to clipboard

The markdown `todo` is not rendered correctly

Open hyochan opened this issue 3 years ago • 13 comments

The markdown todo isn't rendered correctly.

  • [ ] <=== Hope this renders correctly.

Currently in pub.dev

Screenshot 2022-11-20 at 1 41 53 PM

Expected as Github readme

Screenshot 2022-11-20 at 1 42 06 PM

hyochan avatar Nov 20 '22 04:11 hyochan

This seems to be a bug on pub-dev, as running markdown on the input renders the correct HTML:

dart pub run markdown --extension-set GitHubWeb
Deprecated. Use `dart run` instead.
## TODO

- [x] Support optional `horizontal` mode
- [x] Separator support in `ListView`
<h2 id="todo">TODO</h2>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" checked="true"></input>Support optional <code>horizontal</code> mode</li>
<li class="task-list-item"><input type="checkbox" checked="true"></input>Separator support in <code>ListView</code></li>
</ul>

isoos avatar Nov 20 '22 08:11 isoos

This seems to be a bug on pub-dev, as running markdown on the input renders the correct HTML:

dart pub run markdown --extension-set GitHubWeb
Deprecated. Use `dart run` instead.
## TODO

- [x] Support optional `horizontal` mode
- [x] Separator support in `ListView`
<h2 id="todo">TODO</h2>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" checked="true"></input>Support optional <code>horizontal</code> mode</li>
<li class="task-list-item"><input type="checkbox" checked="true"></input>Separator support in <code>ListView</code></li>
</ul>

So is there anything I can do to fix this? I am not getting your solution.

hyochan avatar Nov 20 '22 09:11 hyochan

So is there anything I can do to fix this? I am not getting your solution.

No action is needed on your part. I've tagged the issue as bug, and hopefully we'll have some time to look into it why it happens and fix it.

isoos avatar Nov 20 '22 11:11 isoos

@isoos Thanks! Sounds great and looking forward to it 👀

hyochan avatar Nov 20 '22 11:11 hyochan

@jonasfj: This seems to be caused by the HTML sanitization of the markdown code. We could either allow input in package:sanitize_html, or rewrite the <input> element (and maybe related styles) to <span> elements and/or unicode characters. wdyt?

isoos avatar Nov 21 '22 06:11 isoos

They are rendered as input on github because you actually can modify them.

Although they are rendered as disabled input when not signed in...


Hmm, I guess: https://github.com/gjtorikian/html-pipeline/blob/main/lib/html/pipeline/sanitization_filter.rb

which is the basis for sanitize_html is outdated.

We might need to take a look at refactoring sanitize_html to allow more, and be more flexible.

jonasfj avatar Nov 21 '22 11:11 jonasfj

We might need to take a look at refactoring sanitize_html to allow more, and be more flexible.

I don't mind keeping it strict, however, if we don't change sanitize_html, then we should convert the inputs to unicode characters instead. Which way do you prefer?

isoos avatar Nov 21 '22 13:11 isoos

won't unicode break in some browsers / cases....?

jonasfj avatar Nov 21 '22 15:11 jonasfj

won't unicode break in some browsers / cases....?

IIRC it depends on the font face and the system fonts available. An alternative would be to use just an SVG icon as a replacement, e.g. image

isoos avatar Nov 21 '22 18:11 isoos

In that case I propose that we use <input type="checkbox" disabled> maybe we patch package:markdown to create disabled checkboxes?

jonasfj avatar Nov 22 '22 13:11 jonasfj

SVG would also be nice, but how can we reduce the number of hacks?

Can we pass parameters to package:markdown that changes how it renders OrderedListWithCheckboxSyntax ?

I guess we could subclass OrderedListWithCheckboxSyntax? and change the output it returns..

jonasfj avatar Nov 22 '22 13:11 jonasfj

Can we pass parameters to package:markdown that changes how it renders OrderedListWithCheckboxSyntax ?

Unfortunately, it looks like, changing the package:markdown rendering is not easy: https://github.com/dart-lang/markdown/blob/master/lib/src/block_syntaxes/list_syntax.dart#L57-L237

In that case I propose that we use maybe we patch package:markdown to create disabled checkboxes?

We'd need to both change the markdown output to use disabled and also change package:sanitize_html to not remove the input tag and its attributes. I'd rather prefer this one than just changing it into an icon (that we need to distribute).

isoos avatar Nov 23 '22 08:11 isoos

Still an issue

sigurdm avatar Nov 27 '25 10:11 sigurdm