public
Description: An implementation of markdown in C, using a PEG grammar
Clone URL: git://github.com/jgm/peg-markdown.git
Search Repo:
Updated README.
jgm (author)
Thu May 08 14:31:54 -0700 2008
commit  320bdab8acb58a5ee6a043aa4571638810d50889
tree    b3d37c34a2deca924e279026ebefa3d74ec85b59
parent  8d8f6e2ba51b14b098052c9d4d0cef164cd6f1ad
0
...
55
56
57
58
 
59
60
61
62
63
64
 
 
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
67
68
69
70
 
 
 
 
 
 
 
 
 
 
71
72
73
 
 
...
55
56
57
 
58
59
60
 
 
 
 
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
 
 
 
 
79
80
81
82
83
84
85
86
87
88
89
 
 
90
91
0
@@ -55,20 +55,38 @@
0
 Hacking
0
 =======
0
 
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
 
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
- the new format.
0
+ * `markdown_peg.h` contains declarations for both `markdown_parser.leg`
0
+ and `markdown_output.c`.
0
 
0
+ * `markdown_parser.leg` contains the grammar itself, the `markdown()`
0
+ function, and some utility functions used by the parser actions.
0
+
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
+
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
+
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
+ set appropriately.
0
 
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.