Add support for list item checkboxes (e.g. [X])

see https://orgmode.org/manual/Checkboxes.html
We're deviating from Org mode regarding the assigned css classes but the chosen
classes feel better than (on, off, trans) and it's not like the export matches
1:1 otherwise.
This commit is contained in:
Niklas Fasching 2018-12-18 14:15:35 +01:00
parent a60f844e38
commit 7331d24452
7 changed files with 55 additions and 35 deletions

View file

@ -203,6 +203,9 @@ func (w *OrgWriter) writeListItem(li ListItem) {
liWriter.writeNodes(li.Children...)
content := strings.TrimPrefix(liWriter.String(), liWriter.indent)
w.WriteString(w.indent + li.Bullet)
if li.Status != "" {
w.WriteString(fmt.Sprintf(" [%s]", li.Status))
}
if len(content) > 0 && content[0] == '\n' {
w.WriteString(content)
} else {
@ -212,6 +215,9 @@ func (w *OrgWriter) writeListItem(li ListItem) {
func (w *OrgWriter) writeDescriptiveListItem(di DescriptiveListItem) {
w.WriteString(w.indent + di.Bullet)
if di.Status != "" {
w.WriteString(fmt.Sprintf(" [%s]", di.Status))
}
indent := w.indent + strings.Repeat(" ", len(di.Bullet)+1)
if len(di.Term) != 0 {
term := w.nodesAsString(di.Term...)