Tobias Kienzler
Tobias Kienzler

Reputation: 27423

How to use two different kinds of itemizations via Markdown?

Using enumitem, I define a second itemization list with different options, e.g. different label:

\usepackage{enumitem}
\newlist{dashize}{itemize}{1}
\setlist[dashize]{label=--}

Now I'd like to use to convert a source, but I'd like to have itemizations use itemize or dashize depending on the itemization symbol used in markdown, i.e.

* this list
* should use
* the usual itemization

- while this one
- should use
- dashize

How can this be achieved best? Filters seem to act too late, as they act on json-converted input which already dropped the distinction of bullet type...

Upvotes: 0

Views: 199

Answers (1)

Waylan
Waylan

Reputation: 42547

The short answer is that you can't, at least not using any existing Markdown parser.

The Markdown rules state:

Unordered lists use asterisks, pluses, and hyphens — interchangably — as list markers:

And that is it, aside from a few examples (the rules then focus entirely on ordered lists). The question is, what is meant by "interchangably"? A look at the examples provided would give the impression that each type of list marker desgnates a new list. However, in practice, the reference implementation actually allows multiple different list markers within one list. For example, the following is a single list:

*   Red
-   Green
+   Blue

The point is that the Markdown parser makes no distinction between the different markers. Therefore, "interchangably" literally means that you can mix and match the list markers in any way and it has no effect on the parser's behavior.

Actually, there are many subtleties to how lists are parsed which create issues for users. That said, most implementations have followed the reference implementations' behavior in this particular matter (see Babelmark for an example). As the parser does not care about which list marker is used, then the parser does not retain any info about which list marker was used. I doubt you will find any Markdown parser which will provide what you want.

Quit simply, the list markers are interchangeable in every way and mean nothing special. They exist simply as a preference for the document author with the added benefit that if you copy someone else's list (to add items to your own list), you do not need to go through and change all the list markers to match.

Upvotes: 1

Related Questions