0
-It should be pretty easy to modify
markdown.leg to produce other formats
0
+It should be pretty easy to modify
the program to produce other formats
0
than HTML or LaTeX, and to parse syntax extensions. A quick guide:
0
- * To add an output format, add the format to 'formats', modify 'print_element',
0
- and add functions corresponding to 'print_html_string', 'print_html_element',
0
- and 'print_html_element_list'. Also add an option in the main loop that selects
0
+ * `markdown_peg.h` contains declarations for both `markdown_parser.leg`
0
+ and `markdown_output.c`.
0
+ * `markdown_parser.leg` contains the grammar itself, the `markdown()`
0
+ function, and some utility functions used by the parser actions.
0
+ * `markdown_output.c` contains functions for printing the `Element`
0
+ structure in various output formats. (This includes calling
0
+ `markdown()` again when needed to parse list items and blockquotes,
0
+ which are stored initially as raw strings.)
0
+ * To add an output format, add the format to `formats`, modify
0
+ `print_element`, and add functions `print_XXXX_string`,
0
+ `print_XXXX_element`, and `print_XXXX_element_list`. Also add an
0
+ option in the main program that selects the new format. Don't forget
0
+ to add it to the help message.
0
* To add syntax extensions, define them in the PEG grammar (bottom part
0
- of markdown.leg), using existing definitions as a guide. If you need
0
- to add new types of elements (e.g. FOOTNOTE), modify the 'keys'
0
- enum. By using `&{ }` rules it should be possible to selectively
0
- disable extensions depending on command-line options.
0
+ of `markdown_parser.leg`), using existing definitions as a guide.
0
+ New inline elements will need to be added to `Inline =`; new block
0
+ elements will need to be added to `Block =`. If you need to add new
0
+ types of elements (e.g. `FOOTNOTE`), modify the `keys` enum. By using
0
+ `&{ }` rules one can selectively disable extensions depending
0
+ on command-line options. For example, `&{ (syntax_extensions &
0
+ EXT_SMART) }` succeeds only if the `EXT_SMART` bit of the global
0
+ syntax_extensions is set. Add your option to `markdown_extensions`,
0
+ and modify the option parsing in markdown.c so that your option gets
0
- * Note: Avoid using [^abc] character classes in the grammar, because they
0
- cause problems with non-ascii input. Instead, use: ( !'a' !'b' !'c' . )
0
+ * Note: Avoid using `[^abc]` character classes in the grammar, because they
0
+ cause problems with non-ascii input. Instead, use: `( !'a' !'b' !'c' . )`
Comments
No one has commented yet.