-
Notifications
You must be signed in to change notification settings - Fork 14
Emit names for task list checkboxes #12
Comments
I'm not sure I understand what you mean with "emit". Checkboxes already have IDs to be used by JavaScripts side processing. |
They do? >>> import markdown
>>> from mdx_gfm import GithubFlavoredMarkdownExtension
>>>
>>> source = """
... Hello, *world*! This is a ~~good~~marvelous day!
... Here is an auto link: https://example.org/
...
... Le me introduce you to [task lists] (https://github.com/blog/1375-task-lists-in-gfm-issues-pulls-comments):
...
... - [ ] eggs
... - [x] milk
...
... You can also have fenced code blocks:
...
... ```
... import this
... ```
... """
>>> md = markdown.Markdown(extensions=[GithubFlavoredMarkdownExtension()])
>>> html = md.convert(source)
>>> html
'<p>Hello, <em>world</em>! This is a <del>good</del>marvelous day!<br />\nHere is an auto link: <a href="https://example.org/">https://example.org/</a></p>\n<p>Le me introduce you to <a href="https://github.com/blog/1375-task-lists-in-gfm-issues-pulls-comments">task lists</a>:</p>\n<ul>\n<li><input disabled="disabled" type="checkbox" /> eggs</li>\n<li><input checked="checked" disabled="disabled" type="checkbox" /> milk</li>\n</ul>\n<p>You can also have fenced code blocks:</p>\n<div class="highlight"><pre><span></span>import this\n</pre></div>' I would like to do server-side processing, rather than with JavaScript. To that end I'll put the generated Markdown in a form, and if the checkboxes have a |
For some reason the readthedocs docs are somewhat broken, the list of links to extensions does not show. Please refer to the inline documentation on how to set |
That's not flexible enough, I'd still have to implement my own markdown parser to find the character index of the checkboxes to do the toggle. I just want something like |
I understand your issue, indeed py-gfm does not expose the required API to cleanly toggle the checkbox by modifying the markdown input. It's quite far from the original purpose of a markdown renderer, but I'll try to address this in a new release. You could also come up with a PR that I'll happily review. |
I have to disagree. This isn't a traditionally designed parser but it's quite common for a parser to prepare an annotated AST that the consumer can examine, including information about the line number and character index of each semantic object in the source. This is necessary, for example, to show syntax errors with a line and column number. I think it's well within the purview of a markdown implementation. |
So that, when ticked, we can easily update the text.
The text was updated successfully, but these errors were encountered: