markdown
Module¶
Tools for parsing and manipulating markdown, including a very basic tokenizer.
-
strip_link
(text)¶ Parses and removes any links from the input string
- Parameters
text – An input string which may be a markdown link, either literal or an ID
- Returns
A tuple of (name, url, id). If the input is not a link, it is returned verbatim as the name.
-
join
(segments: List[str]) → str¶ Joins multiple lines of markdown by adding double newlines between them, or a single newline between list items
- Parameters
segments – A list of strings to join
- Returns
A joined markdown string
-
class
Token
(line_no: int, lines: List[str], kind: str)¶ A single tokenized block of markdown, consisting of one or more lines of text.
-
line_no
¶ Which line this block appears on in the original file
-
lines
¶ The lines of text making up this block
-
kind
¶ What kind of token this is. One of
h[1-6]
,p
,li
orcode
-