Add support for custom numbering of ordered list using [@\d+]

org mode supports [1] setting the value attribute [2] of ordered list items to
change the numbering for the current and following items. Let's do the same. As
the attribute has no meaning for other types of lists [2] we'll just not
support it for those cases [3].

[1] https://orgmode.org/manual/Plain-Lists.html#Plain-Lists
[2] https://developer.mozilla.org/en-US/docs/Web/HTML/Element/li#attributes
[3]
Org mode seems to instead set the id attribute for e.g. unordered lists
starting with `[@\d+]\s` - but I don't really see the value in that and will
skip that for now.
This commit is contained in:
Niklas Fasching 2021-04-17 15:39:14 +02:00
parent b3edd6c182
commit 21f1af7d48
6 changed files with 38 additions and 6 deletions

View file

@ -219,6 +219,9 @@ func (w *OrgWriter) WriteListItem(li ListItem) {
content := strings.TrimPrefix(w.String(), w.indent)
w.Builder, w.indent = originalBuilder, originalIndent
w.WriteString(w.indent + li.Bullet)
if li.Value != "" {
w.WriteString(fmt.Sprintf(" [@%s]", li.Value))
}
if li.Status != "" {
w.WriteString(fmt.Sprintf(" [%s]", li.Status))
}