jgm / pandoc

Universal markup converter
https://pandoc.org
Other
34.03k stars 3.35k forks source link

Markdown checkboxes #3051

Closed graymalkin closed 5 years ago

graymalkin commented 8 years ago

It would be nice if Pandoc's GFM supported checkboxes, either through an extension or native to the GFM.

 - [ ] example unchecked
 - [x] example checked

I hope I'm not just being thick here, I couldn't find anything about it in the manual, and no one appears to have mentioned it in the issue tracker.

lollipopman commented 5 years ago

@OleMussmann I agree that it looks better without the bullet point

jgm commented 5 years ago

One possibility would be to parse

- [x] Foo
- [ ] Bar

into the pandoc structure

Div ("",["checklist"],[])
 [ BulletList
   [ [Plain [Span ("",["checkbox","checked"],[]) [Str "☑",Space], Str "Foo"]]
   , [Plain [Span ("",["checkbox","unchecked"],[]) [Str "☐",Space], Str "Bar"]]
   ]
 ]

In most formats, this would come out as a bullet list with the unicode checkbox characters. But specific writers could be taught to give special output, e.g. the HTML output suggested above.

mb21 commented 5 years ago

I suppose the extra Span wrapping the unicode string lowers the probability of a clash even further, though I guess it's not strictly necessary. But yeah, maybe it's somewhat cleaner...

jgm commented 5 years ago

Mauro Bieg notifications@github.com writes:

I suppose the extra Span wrapping the unicode string lowers the probability of a clash even further, though I guess it's not strictly necessary. But yeah, maybe it's somewhat cleaner...

The point of the extra span is to make it easy for writers to replace it, e.g. with an input element.

zethdubois commented 1 year ago

I have a hack that I'm using to render a box next to a text list.

I'm writing Markdown in Obsidian, and it allows for LaTeX math symbols, natively.

$\Box$ This is left side checkbox

Check box to the right of this line of text $\Box$

Pandoc conversions of the Markdown to pdf using --pdf-engine=xelatex render to PDF with no issues.