public
Description: An implementation of markdown in C, using a PEG grammar
Clone URL: git://github.com/jgm/peg-markdown.git
Search Repo:
Added extensions parameter to markdown().
This is used to turn on various syntax extensions.
jgm (author)
Tue May 06 20:53:36 -0700 2008
commit  8a59c5dee96c51a4099a63f84e70fbf347a38827
tree    1e0bf05fbb8e4e1a45cdfd95b903ec5e870e06b8
parent  2a3daabc3b5f87fde7098c9049dd8885d203ca56
...
23
24
25
 
26
27
28
29
30
...
215
216
217
218
 
219
220
 
221
222
223
224
225
226
227
 
228
229
230
231
232
...
381
382
383
384
 
385
386
 
387
388
389
390
 
391
392
393
394
...
552
553
554
555
 
556
557
558
 
559
560
561
...
563
564
565
566
 
567
568
569
...
764
765
766
767
 
768
769
770
...
23
24
25
26
27
28
29
30
31
...
216
217
218
 
219
220
 
221
222
223
224
225
226
227
 
228
229
230
231
232
233
...
382
383
384
 
385
386
 
387
388
389
390
 
391
392
393
394
395
...
553
554
555
 
556
557
558
 
559
560
561
562
...
564
565
566
 
567
568
569
570
...
765
766
767
 
768
769
770
771
0
@@ -23,6 +23,7 @@
0
 #include "my_getopt-1.5/getopt.h"
0
 
0
 extern char *strdup(const char *string);
0
+static int extensions = 0;
0
 
0
 /**********************************************************************
0
 
0
0
0
@@ -215,16 +216,16 @@
0
          * is no blank line. We split the string by \001 and parse
0
          * each chunk separately. */
0
         contents = strtok(elt.contents.str, "\001");
0
- print_html_element(markdown(contents), obfuscate);
0
+ print_html_element(markdown(extensions, contents), obfuscate);
0
         while ((contents = strtok(NULL, "\001")))
0
- print_html_element(markdown(contents), obfuscate);
0
+ print_html_element(markdown(extensions, contents), obfuscate);
0
         printf("</li>");
0
         padded = 0;
0
         break;
0
     case BLOCKQUOTE:
0
         pad(2);
0
         printf("<blockquote>");
0
- print_html_element(markdown(eelt.contents.str), obfuscate);
0
+ print_html_element(markdown(extensions, elt.contents.str), obfuscate);
0
         printf("</blockquote>");
0
         padded = 0;
0
         break;
0
0
0
@@ -381,13 +382,13 @@
0
          * is no blank line. We split the string by \001 and parse
0
          * each chunk separately. */
0
         contents = strtok(elt.contents.str, "\001");
0
- print_latex_element(markdown(contents));
0
+ print_latex_element(markdown(extensions, contents));
0
         while ((contents = strtok(NULL, "\001")))
0
- print_latex_element(markdown(contents));
0
+ print_latex_element(markdown(extensions, contents));
0
         break;
0
     case BLOCKQUOTE:
0
         printf("\\begin{quote}");
0
- print_latex_element(markdown(eelt.contents.str));
0
+ print_latex_element(markdown(extensions, elt.contents.str));
0
         printf("\\end{quote}\n\n");
0
         break;
0
     case REFERENCE:
0
0
@@ -552,10 +553,10 @@
0
          * each chunk separately. */
0
         contents = strtok(elt.contents.str, "\001");
0
         padded = 2;
0
- print_groff_mm_element(markdown(contents), 1);
0
+ print_groff_mm_element(markdown(extensions, contents), 1);
0
         while ((contents = strtok(NULL, "\001"))) {
0
             padded = 2;
0
- print_groff_mm_element(markdown(contents), 1);
0
+ print_groff_mm_element(markdown(extensions, contents), 1);
0
         }
0
         in_list_item = false;
0
         break;
0
@@ -563,7 +564,7 @@
0
         pad(1);
0
         printf(".DS I\n");
0
         padded = 2;
0
- print_groff_mm_element(markdown(eelt.contents.str), 1);
0
+ print_groff_mm_element(markdown(extensions, elt.contents.str), 1);
0
         pad(1);
0
         printf(".DE");
0
         padded = 0;
0
@@ -764,7 +765,7 @@
0
 
0
     strcat(inputbuf, strdup("\n\n")); /* add newlines to end to match Markdown.pl behavior */
0
 
0
- element parsed_input = markdown(inputbuf);
0
+ element parsed_input = markdown(extensions, inputbuf);
0
 
0
     switch (output_format) {
0
     case HTML_FORMAT:
...
64
65
66
67
 
 
 
 
 
 
...
64
65
66
 
67
68
69
70
71
72
0
@@ -64,5 +64,10 @@
0
 
0
 typedef struct ElementListItem item;
0
 
0
-element markdown(char *string);
0
+enum markdown_extensions {
0
+ EXT_SMART_QUOTES = 1,
0
+ EXT_SMART_DASHES = 2
0
+};
0
+
0
+element markdown(int extensions, char *string);
...
745
746
747
748
 
749
750
751
...
745
746
747
 
748
749
750
751
0
@@ -745,7 +745,7 @@
0
 
0
 %%
0
 
0
-element markdown(char *string) {
0
+element markdown(int extensions, char *string) {
0
 
0
     char *oldcharbuf;
0
     oldcharbuf = charbuf;

Comments

    No one has commented yet.