[−][src]Crate minimad
This crate provides a very simple markdown parser.
Its main motivation was to be the basis of the termimad lib, which displays static and dynamic markdown snippets on a terminal without mixing the skin with the code and wrapping the text and tables as needed.
It can be used on its own:
use minimad::*; assert_eq!( parse_line("## a header with some **bold**!"), Line::new_header( 2, vec![ Compound::raw_str("a header with some "), Compound::raw_str("bold").bold(), Compound::raw_str("!"), ] ) ); assert_eq!( parse_inline("*Italic then **bold and italic `and some *code*`** and italic*"), Composite::from(vec![ Compound::raw_str("Italic then ").italic(), Compound::raw_str("bold and italic ").bold().italic(), Compound::raw_str("and some *code*").bold().italic().code(), Compound::raw_str(" and italic").italic(), ]) );
Macros
mad_inline | build an inline from a string literal intepreted as markdown and
optional arguments which may fill places designed as |
Structs
Composite | a composite is a monoline sequence of compounds. It's defined by |
Compound | a Compound is a part of a line with a consistent styling. It can be part of word, several words, some inline code, or even the whole line. |
InlineTemplate | a template built from a markdown string, with optional placeholder |
SubTemplateExpander | an expander for a sub template. You get it using the |
TableRow | |
TableRule | |
Text | a text, that is just a collection of lines |
TextTemplate | a markdown template allowing you to replace some placeholders with given values, or to expand some sub-templates with repetitions (useful with lists, table rows, etc.) |
TextTemplateExpander | an expander you get from a template. You specify replacements
on the expander then you ask it the text using |
Enums
Alignment | Left, Center, Right or Unspecified |
CompositeStyle | The global style of a composite |
Line | a parsed line |
Constants
MAX_HEADER_DEPTH |
Functions
parse_inline | parse a monoline markdown snippet which isn't from a text. Don't produce some types of line: TableRow, Code, ListItem as they only make sense in a multi-line text. |
parse_line | parse a line, which is meant to be part of a markdown text.
This function shouldn't usually be used: if you don't want
a text you probably need |
parse_text | parse a markdown text |