parkdown-libertree 1.4.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +68 -0
  3. data/README.markdown +86 -0
  4. data/Rakefile +170 -0
  5. data/bin/parkdown +13 -0
  6. data/ext/extconf.h +3 -0
  7. data/ext/extconf.rb +15 -0
  8. data/ext/markdown.c +104 -0
  9. data/ext/markdown_lib.c +186 -0
  10. data/ext/markdown_lib.h +44 -0
  11. data/ext/markdown_output.c +1275 -0
  12. data/ext/markdown_parser.c +7275 -0
  13. data/ext/markdown_peg.h +90 -0
  14. data/ext/parsing_functions.c +128 -0
  15. data/ext/utility_functions.c +217 -0
  16. data/lib/markdown.rb +1 -0
  17. data/lib/peg_markdown.rb +104 -0
  18. data/test/MarkdownTest_1.0/MarkdownTest.pl +157 -0
  19. data/test/MarkdownTest_1.0/Tests/Amps and angle encoding.html +17 -0
  20. data/test/MarkdownTest_1.0/Tests/Amps and angle encoding.text +21 -0
  21. data/test/MarkdownTest_1.0/Tests/Auto links.html +18 -0
  22. data/test/MarkdownTest_1.0/Tests/Auto links.text +13 -0
  23. data/test/MarkdownTest_1.0/Tests/Backslash escapes.html +102 -0
  24. data/test/MarkdownTest_1.0/Tests/Backslash escapes.text +104 -0
  25. data/test/MarkdownTest_1.0/Tests/Blockquotes with code blocks.html +15 -0
  26. data/test/MarkdownTest_1.0/Tests/Blockquotes with code blocks.text +11 -0
  27. data/test/MarkdownTest_1.0/Tests/Hard-wrapped paragraphs with list-like lines.html +8 -0
  28. data/test/MarkdownTest_1.0/Tests/Hard-wrapped paragraphs with list-like lines.text +8 -0
  29. data/test/MarkdownTest_1.0/Tests/Horizontal rules.html +71 -0
  30. data/test/MarkdownTest_1.0/Tests/Horizontal rules.text +67 -0
  31. data/test/MarkdownTest_1.0/Tests/Inline HTML (Advanced).html +14 -0
  32. data/test/MarkdownTest_1.0/Tests/Inline HTML (Advanced).text +14 -0
  33. data/test/MarkdownTest_1.0/Tests/Inline HTML (Simple).html +72 -0
  34. data/test/MarkdownTest_1.0/Tests/Inline HTML (Simple).text +69 -0
  35. data/test/MarkdownTest_1.0/Tests/Inline HTML comments.html +13 -0
  36. data/test/MarkdownTest_1.0/Tests/Inline HTML comments.text +13 -0
  37. data/test/MarkdownTest_1.0/Tests/Links, inline style.html +9 -0
  38. data/test/MarkdownTest_1.0/Tests/Links, inline style.text +9 -0
  39. data/test/MarkdownTest_1.0/Tests/Links, reference style.html +18 -0
  40. data/test/MarkdownTest_1.0/Tests/Links, reference style.text +31 -0
  41. data/test/MarkdownTest_1.0/Tests/Literal quotes in titles.html +3 -0
  42. data/test/MarkdownTest_1.0/Tests/Literal quotes in titles.text +7 -0
  43. data/test/MarkdownTest_1.0/Tests/Markdown Documentation - Basics.html +314 -0
  44. data/test/MarkdownTest_1.0/Tests/Markdown Documentation - Basics.text +306 -0
  45. data/test/MarkdownTest_1.0/Tests/Markdown Documentation - Syntax.html +942 -0
  46. data/test/MarkdownTest_1.0/Tests/Markdown Documentation - Syntax.text +888 -0
  47. data/test/MarkdownTest_1.0/Tests/Nested blockquotes.html +9 -0
  48. data/test/MarkdownTest_1.0/Tests/Nested blockquotes.text +5 -0
  49. data/test/MarkdownTest_1.0/Tests/Ordered and unordered lists.html +137 -0
  50. data/test/MarkdownTest_1.0/Tests/Ordered and unordered lists.text +122 -0
  51. data/test/MarkdownTest_1.0/Tests/Strong and em together.html +7 -0
  52. data/test/MarkdownTest_1.0/Tests/Strong and em together.text +7 -0
  53. data/test/MarkdownTest_1.0/Tests/Tabs.html +25 -0
  54. data/test/MarkdownTest_1.0/Tests/Tabs.text +21 -0
  55. data/test/MarkdownTest_1.0/Tests/Tidyness.html +8 -0
  56. data/test/MarkdownTest_1.0/Tests/Tidyness.text +5 -0
  57. data/test/MarkdownTest_1.0.3/MarkdownTest.pl +176 -0
  58. data/test/MarkdownTest_1.0.3/Tests/Amps and angle encoding.html +17 -0
  59. data/test/MarkdownTest_1.0.3/Tests/Amps and angle encoding.text +21 -0
  60. data/test/MarkdownTest_1.0.3/Tests/Auto links.html +18 -0
  61. data/test/MarkdownTest_1.0.3/Tests/Auto links.text +13 -0
  62. data/test/MarkdownTest_1.0.3/Tests/Backslash escapes.html +118 -0
  63. data/test/MarkdownTest_1.0.3/Tests/Backslash escapes.text +120 -0
  64. data/test/MarkdownTest_1.0.3/Tests/Blockquotes with code blocks.html +15 -0
  65. data/test/MarkdownTest_1.0.3/Tests/Blockquotes with code blocks.text +11 -0
  66. data/test/MarkdownTest_1.0.3/Tests/Code Blocks.html +18 -0
  67. data/test/MarkdownTest_1.0.3/Tests/Code Blocks.text +14 -0
  68. data/test/MarkdownTest_1.0.3/Tests/Code Spans.html +6 -0
  69. data/test/MarkdownTest_1.0.3/Tests/Code Spans.text +6 -0
  70. data/test/MarkdownTest_1.0.3/Tests/Hard-wrapped paragraphs with list-like lines.html +8 -0
  71. data/test/MarkdownTest_1.0.3/Tests/Hard-wrapped paragraphs with list-like lines.text +8 -0
  72. data/test/MarkdownTest_1.0.3/Tests/Horizontal rules.html +71 -0
  73. data/test/MarkdownTest_1.0.3/Tests/Horizontal rules.text +67 -0
  74. data/test/MarkdownTest_1.0.3/Tests/Inline HTML (Advanced).html +15 -0
  75. data/test/MarkdownTest_1.0.3/Tests/Inline HTML (Advanced).text +15 -0
  76. data/test/MarkdownTest_1.0.3/Tests/Inline HTML (Simple).html +72 -0
  77. data/test/MarkdownTest_1.0.3/Tests/Inline HTML (Simple).text +69 -0
  78. data/test/MarkdownTest_1.0.3/Tests/Inline HTML comments.html +13 -0
  79. data/test/MarkdownTest_1.0.3/Tests/Inline HTML comments.text +13 -0
  80. data/test/MarkdownTest_1.0.3/Tests/Links, inline style.html +11 -0
  81. data/test/MarkdownTest_1.0.3/Tests/Links, inline style.text +12 -0
  82. data/test/MarkdownTest_1.0.3/Tests/Links, reference style.html +52 -0
  83. data/test/MarkdownTest_1.0.3/Tests/Links, reference style.text +71 -0
  84. data/test/MarkdownTest_1.0.3/Tests/Links, shortcut references.html +9 -0
  85. data/test/MarkdownTest_1.0.3/Tests/Links, shortcut references.text +20 -0
  86. data/test/MarkdownTest_1.0.3/Tests/Literal quotes in titles.html +3 -0
  87. data/test/MarkdownTest_1.0.3/Tests/Literal quotes in titles.text +7 -0
  88. data/test/MarkdownTest_1.0.3/Tests/Markdown Documentation - Basics.html +314 -0
  89. data/test/MarkdownTest_1.0.3/Tests/Markdown Documentation - Basics.text +306 -0
  90. data/test/MarkdownTest_1.0.3/Tests/Markdown Documentation - Syntax.html +942 -0
  91. data/test/MarkdownTest_1.0.3/Tests/Markdown Documentation - Syntax.text +888 -0
  92. data/test/MarkdownTest_1.0.3/Tests/Nested blockquotes.html +9 -0
  93. data/test/MarkdownTest_1.0.3/Tests/Nested blockquotes.text +5 -0
  94. data/test/MarkdownTest_1.0.3/Tests/Ordered and unordered lists.html +148 -0
  95. data/test/MarkdownTest_1.0.3/Tests/Ordered and unordered lists.text +131 -0
  96. data/test/MarkdownTest_1.0.3/Tests/Strong and em together.html +7 -0
  97. data/test/MarkdownTest_1.0.3/Tests/Strong and em together.text +7 -0
  98. data/test/MarkdownTest_1.0.3/Tests/Tabs.html +25 -0
  99. data/test/MarkdownTest_1.0.3/Tests/Tabs.text +21 -0
  100. data/test/MarkdownTest_1.0.3/Tests/Tidyness.html +8 -0
  101. data/test/MarkdownTest_1.0.3/Tests/Tidyness.text +5 -0
  102. data/test/benchmark.rb +49 -0
  103. data/test/markdown_test.rb +84 -0
  104. metadata +150 -0
@@ -0,0 +1,90 @@
1
+ /* markdown_peg.h */
2
+ #ifndef MARKDOWN_PEG_H
3
+ #define MARKDOWN_PEG_H
4
+
5
+ #include "markdown_lib.h"
6
+ #include <glib.h>
7
+
8
+ /* Information (label, URL and title) for a link. */
9
+ struct Link {
10
+ struct Element *label;
11
+ char *url;
12
+ char *title;
13
+ };
14
+
15
+ typedef struct Link link;
16
+
17
+ /* Information (label and two sources) for a media link. */
18
+ struct Media {
19
+ struct Element *label;
20
+ char *source1;
21
+ char *source2;
22
+ };
23
+
24
+ typedef struct Media media;
25
+
26
+ /* Union for contents of an Element (string, list, link, or media). */
27
+ union Contents {
28
+ char *str;
29
+ struct Link *link;
30
+ struct Media *media;
31
+ };
32
+
33
+ /* Types of semantic values returned by parsers. */
34
+ enum keys { LIST, /* A generic list of values. For ordered and bullet lists, see below. */
35
+ RAW, /* Raw markdown to be processed further */
36
+ SPACE,
37
+ LINEBREAK,
38
+ ELLIPSIS,
39
+ EMDASH,
40
+ ENDASH,
41
+ ENSPACE,
42
+ APOSTROPHE,
43
+ SINGLEQUOTED,
44
+ DOUBLEQUOTED,
45
+ STR,
46
+ LINK,
47
+ IMAGE,
48
+ MEDIA,
49
+ AUDIO,
50
+ VIDEO,
51
+ CODE,
52
+ HTML,
53
+ EMPH,
54
+ STRONG,
55
+ STRIKE,
56
+ PLAIN,
57
+ PARA,
58
+ LISTITEM,
59
+ BULLETLIST,
60
+ ORDEREDLIST,
61
+ H1, H2, H3, H4, H5, H6, /* Code assumes that these are in order. */
62
+ BLOCKQUOTE,
63
+ SPOILERBLOCK,
64
+ VERBATIM,
65
+ HASHTAG,
66
+ USERNAME,
67
+ HTMLBLOCK,
68
+ HRULE,
69
+ REFERENCE,
70
+ NOTE
71
+ };
72
+
73
+ /* Semantic value of a parsing action. */
74
+ struct Element {
75
+ int key;
76
+ union Contents contents;
77
+ struct Element *children;
78
+ struct Element *next;
79
+ };
80
+
81
+ typedef struct Element element;
82
+
83
+ element * parse_references(char *string, int extensions);
84
+ element * parse_notes(char *string, int extensions, element *reference_list);
85
+ element * parse_markdown(char *string, int extensions, element *reference_list, element *note_list);
86
+ void free_element_list(element * elt);
87
+ void free_element(element *elt);
88
+ void print_element_list(GString *out, element *elt, int format, int exts);
89
+
90
+ #endif
@@ -0,0 +1,128 @@
1
+ /* parsing_functions.c - Functions for parsing markdown and
2
+ * freeing element lists. */
3
+
4
+ /* These yy_* functions come from markdown_parser.c which is
5
+ * generated from markdown_parser.leg
6
+ * */
7
+ typedef int (*yyrule)();
8
+
9
+ extern int yyparse();
10
+ extern int yyparsefrom(yyrule);
11
+ extern int yy_References();
12
+ extern int yy_Notes();
13
+ extern int yy_Doc();
14
+
15
+ #include "utility_functions.h"
16
+ #include "parsing_functions.h"
17
+ #include "markdown_peg.h"
18
+
19
+ static void free_element_contents(element elt);
20
+
21
+ /* free_element_list - free list of elements recursively */
22
+ void free_element_list(element * elt) {
23
+ element * next = NULL;
24
+ while (elt != NULL) {
25
+ next = elt->next;
26
+ free_element_contents(*elt);
27
+ if (elt->children != NULL) {
28
+ free_element_list(elt->children);
29
+ elt->children = NULL;
30
+ }
31
+ free(elt);
32
+ elt = next;
33
+ }
34
+ }
35
+
36
+ /* free_element_contents - free element contents depending on type */
37
+ static void free_element_contents(element elt) {
38
+ switch (elt.key) {
39
+ case STR:
40
+ case SPACE:
41
+ case RAW:
42
+ case HTMLBLOCK:
43
+ case HTML:
44
+ case VERBATIM:
45
+ case CODE:
46
+ case NOTE:
47
+ free(elt.contents.str);
48
+ elt.contents.str = NULL;
49
+ break;
50
+ case LINK:
51
+ case IMAGE:
52
+ case REFERENCE:
53
+ free(elt.contents.link->url);
54
+ elt.contents.link->url = NULL;
55
+ free(elt.contents.link->title);
56
+ elt.contents.link->title = NULL;
57
+ free_element_list(elt.contents.link->label);
58
+ free(elt.contents.link);
59
+ elt.contents.link = NULL;
60
+ break;
61
+ case MEDIA:
62
+ case AUDIO:
63
+ case VIDEO:
64
+ free(elt.contents.media->source1);
65
+ elt.contents.media->source1 = NULL;
66
+ free(elt.contents.media->source2);
67
+ elt.contents.media->source2 = NULL;
68
+ free_element_list(elt.contents.media->label);
69
+ free(elt.contents.media);
70
+ elt.contents.media = NULL;
71
+ break;
72
+ default:
73
+ ;
74
+ }
75
+ }
76
+
77
+ /* free_element - free element and contents */
78
+ void free_element(element *elt) {
79
+ free_element_contents(*elt);
80
+ free(elt);
81
+ }
82
+
83
+ element * parse_references(char *string, int extensions) {
84
+
85
+ char *oldcharbuf;
86
+ syntax_extensions = extensions;
87
+
88
+ oldcharbuf = charbuf;
89
+ charbuf = string;
90
+ yyparsefrom(yy_References); /* first pass, just to collect references */
91
+ charbuf = oldcharbuf;
92
+
93
+ return references;
94
+ }
95
+
96
+ element * parse_notes(char *string, int extensions, element *reference_list) {
97
+
98
+ char *oldcharbuf;
99
+ notes = NULL;
100
+ syntax_extensions = extensions;
101
+
102
+ if (extension(EXT_NOTES)) {
103
+ references = reference_list;
104
+ oldcharbuf = charbuf;
105
+ charbuf = string;
106
+ yyparsefrom(yy_Notes); /* second pass for notes */
107
+ charbuf = oldcharbuf;
108
+ }
109
+
110
+ return notes;
111
+ }
112
+
113
+ element * parse_markdown(char *string, int extensions, element *reference_list, element *note_list) {
114
+
115
+ char *oldcharbuf;
116
+ syntax_extensions = extensions;
117
+ references = reference_list;
118
+ notes = note_list;
119
+
120
+ oldcharbuf = charbuf;
121
+ charbuf = string;
122
+
123
+ yyparsefrom(yy_Doc);
124
+
125
+ charbuf = oldcharbuf; /* restore charbuf to original value */
126
+ return parse_result;
127
+
128
+ }
@@ -0,0 +1,217 @@
1
+ /* utility_functions.c - List manipulation functions, element
2
+ * constructors, and macro definitions for leg markdown parser. */
3
+
4
+ #include "utility_functions.h"
5
+ #include "markdown_peg.h"
6
+
7
+ #include <string.h>
8
+ #include <assert.h>
9
+
10
+
11
+ /**********************************************************************
12
+
13
+ List manipulation functions
14
+
15
+ ***********************************************************************/
16
+
17
+ /* cons - cons an element onto a list, returning pointer to new head */
18
+ element * cons(element *new, element *list) {
19
+ assert(new != NULL);
20
+ new->next = list;
21
+ return new;
22
+ }
23
+
24
+ /* reverse - reverse a list, returning pointer to new list */
25
+ element *reverse(element *list) {
26
+ element *new = NULL;
27
+ element *next = NULL;
28
+ while (list != NULL) {
29
+ next = list->next;
30
+ new = cons(list, new);
31
+ list = next;
32
+ }
33
+ return new;
34
+ }
35
+
36
+ /* concat_string_list - concatenates string contents of list of STR elements.
37
+ * Frees STR elements as they are added to the concatenation. */
38
+ GString *concat_string_list(element *list) {
39
+ GString *result;
40
+ element *next;
41
+ result = g_string_new("");
42
+ while (list != NULL) {
43
+ assert(list->key == STR);
44
+ assert(list->contents.str != NULL);
45
+ g_string_append(result, list->contents.str);
46
+ next = list->next;
47
+ free_element(list);
48
+ list = next;
49
+ }
50
+ return result;
51
+ }
52
+
53
+ /**********************************************************************
54
+
55
+ Global variables used in parsing
56
+
57
+ ***********************************************************************/
58
+
59
+ char *charbuf = ""; /* Buffer of characters to be parsed. */
60
+ element *references = NULL; /* List of link references found. */
61
+ element *notes = NULL; /* List of footnotes found. */
62
+ element *parse_result; /* Results of parse. */
63
+ int syntax_extensions; /* Syntax extensions selected. */
64
+
65
+ /**********************************************************************
66
+
67
+ Auxiliary functions for parsing actions.
68
+ These make it easier to build up data structures (including lists)
69
+ in the parsing actions.
70
+
71
+ ***********************************************************************/
72
+
73
+ /* mk_element - generic constructor for element */
74
+ element * mk_element(int key) {
75
+ element *result = malloc(sizeof(element));
76
+ result->key = key;
77
+ result->children = NULL;
78
+ result->next = NULL;
79
+ result->contents.str = NULL;
80
+ return result;
81
+ }
82
+
83
+ /* mk_str - constructor for STR element */
84
+ element * mk_str(char *string) {
85
+ element *result;
86
+ assert(string != NULL);
87
+ result = mk_element(STR);
88
+ result->contents.str = strdup(string);
89
+ return result;
90
+ }
91
+
92
+ /* mk_str_from_list - makes STR element by concatenating a
93
+ * reversed list of strings, adding optional extra newline */
94
+ element * mk_str_from_list(element *list, bool extra_newline) {
95
+ element *result;
96
+ GString *c = concat_string_list(reverse(list));
97
+ if (extra_newline)
98
+ g_string_append(c, "\n");
99
+ result = mk_element(STR);
100
+ result->contents.str = c->str;
101
+ g_string_free(c, false);
102
+ return result;
103
+ }
104
+
105
+ /* mk_list - makes new list with key 'key' and children the reverse of 'lst'.
106
+ * This is designed to be used with cons to build lists in a parser action.
107
+ * The reversing is necessary because cons adds to the head of a list. */
108
+ element * mk_list(int key, element *lst) {
109
+ element *result;
110
+ result = mk_element(key);
111
+ result->children = reverse(lst);
112
+ return result;
113
+ }
114
+
115
+ /* mk_link - constructor for LINK element */
116
+ element * mk_link(element *label, char *url, char *title) {
117
+ element *result;
118
+ result = mk_element(LINK);
119
+ result->contents.link = malloc(sizeof(link));
120
+ result->contents.link->label = label;
121
+ result->contents.link->url = strdup(url);
122
+ result->contents.link->title = strdup(title);
123
+ return result;
124
+ }
125
+
126
+ /* mk_media - constructor for AUDIO and VIDEO element */
127
+ element * mk_media(element *label, char *source1, char *source2) {
128
+ element *result;
129
+ result = mk_element(MEDIA);
130
+ result->contents.media = malloc(sizeof(media));
131
+ result->contents.media->label = label;
132
+ result->contents.media->source1 = strdup(source1);
133
+ result->contents.media->source2 = strdup(source2);
134
+ return result;
135
+ }
136
+
137
+ /* extension = returns true if extension is selected */
138
+ bool extension(int ext) {
139
+ return (syntax_extensions & ext);
140
+ }
141
+
142
+ /* match_inlines - returns true if inline lists match (case-insensitive...) */
143
+ bool match_inlines(element *l1, element *l2) {
144
+ while (l1 != NULL && l2 != NULL) {
145
+ if (l1->key != l2->key)
146
+ return false;
147
+ switch (l1->key) {
148
+ case SPACE:
149
+ case LINEBREAK:
150
+ case ELLIPSIS:
151
+ case EMDASH:
152
+ case ENDASH:
153
+ case APOSTROPHE:
154
+ break;
155
+ case CODE:
156
+ case STR:
157
+ case HTML:
158
+ if (strcasecmp(l1->contents.str, l2->contents.str) == 0)
159
+ break;
160
+ else
161
+ return false;
162
+ case EMPH:
163
+ case STRONG:
164
+ case LIST:
165
+ case SINGLEQUOTED:
166
+ case DOUBLEQUOTED:
167
+ if (match_inlines(l1->children, l2->children))
168
+ break;
169
+ else
170
+ return false;
171
+ case LINK:
172
+ case IMAGE:
173
+ return false; /* No links or images within links */
174
+ default:
175
+ fprintf(stderr, "match_inlines encountered unknown key = %d\n", l1->key);
176
+ exit(EXIT_FAILURE);
177
+ break;
178
+ }
179
+ l1 = l1->next;
180
+ l2 = l2->next;
181
+ }
182
+ return (l1 == NULL && l2 == NULL); /* return true if both lists exhausted */
183
+ }
184
+
185
+ /* find_reference - return true if link found in references matching label.
186
+ * 'link' is modified with the matching url and title. */
187
+ bool find_reference(link *result, element *label) {
188
+ element *cur = references; /* pointer to walk up list of references */
189
+ link *curitem;
190
+ while (cur != NULL) {
191
+ curitem = cur->contents.link;
192
+ if (match_inlines(label, curitem->label)) {
193
+ *result = *curitem;
194
+ return true;
195
+ }
196
+ else
197
+ cur = cur->next;
198
+ }
199
+ return false;
200
+ }
201
+
202
+ /* find_note - return true if note found in notes matching label.
203
+ if found, 'result' is set to point to matched note. */
204
+
205
+ bool find_note(element **result, char *label) {
206
+ element *cur = notes; /* pointer to walk up list of notes */
207
+ while (cur != NULL) {
208
+ if (strcmp(label, cur->contents.str) == 0) {
209
+ *result = cur;
210
+ return true;
211
+ }
212
+ else
213
+ cur = cur->next;
214
+ }
215
+ return false;
216
+ }
217
+
data/lib/markdown.rb ADDED
@@ -0,0 +1 @@
1
+ require 'peg_markdown'
@@ -0,0 +1,104 @@
1
+ require 'peg_markdown.so'
2
+
3
+ # Front-end to jgm's peg-markdown implementation of Markdown, the humane
4
+ # text markup language.
5
+ #
6
+ # A simple processor:
7
+ # >>> puts Markdown.new("Hello, World.").to_html
8
+ # <p>Hello, World.</p>
9
+ #
10
+ # With other stuff:
11
+ # >>> puts Markdown.new("_Hello -- World!_", :smart, :filter_html).to_html
12
+ # <p><em>Hello World!</em></p>
13
+ #
14
+ class PEGMarkdown
15
+
16
+ # Original Markdown formatted text.
17
+ attr_reader :text
18
+
19
+ # Set true to have smarty-like quote translation performed.
20
+ attr_accessor :smart
21
+
22
+ # Set true to have footnotes processed.
23
+ attr_accessor :notes
24
+
25
+ # Do not output <style> tags included in the source text.
26
+ attr_accessor :filter_styles
27
+
28
+ # Do not output any raw HTML included in the source text.
29
+ attr_accessor :filter_html
30
+
31
+ # Included for compatibility with RedCloth's interface.
32
+ attr_accessor :fold_lines
33
+
34
+ # Set true to enable strike-through extension.
35
+ attr_accessor :strike
36
+
37
+ # Set true to enable autolink extension.
38
+ attr_accessor :autolink
39
+
40
+ # Set true to enable hard wrap extension.
41
+ attr_accessor :hard_wrap
42
+
43
+ # Set true to disable rendering of images.
44
+ attr_accessor :no_images
45
+
46
+ # Set true to enable audio/video extension.
47
+ attr_accessor :media
48
+
49
+ # Set true to enable codeblock extension.
50
+ attr_accessor :codeblock
51
+
52
+ # Set true to enable hashtags extension.
53
+ attr_accessor :hashtags
54
+
55
+ # Set true to enable usernames extension.
56
+ attr_accessor :usernames
57
+
58
+ # Set true to enable spoilerblock extension.
59
+ attr_accessor :spoilerblock
60
+
61
+ # Create a new Markdown processor. The +text+ argument is a string
62
+ # containing Markdown text. Variable other arguments may be supplied to
63
+ # set various processing options:
64
+ #
65
+ # * <tt>:smart</tt> - Enable SmartyPants processing.
66
+ # * <tt>:notes</tt> - Enable footnotes.
67
+ # * <tt>:filter_styles</tt> - Do not output <style> tags included in the
68
+ # source text.
69
+ # * <tt>:filter_html</tt> - Do not output raw HTML included in the
70
+ # source text.
71
+ # * <tt>:fold_lines</tt> - RedCloth compatible line folding (not used).
72
+ # * <tt>:strike</tt> - Enable strike-through extension.
73
+ # * <tt>:autolink</tt> - Enable autolinking of bare URLs.
74
+ # * <tt>:hard_wrap</tt> - Insert line breaks inside paragraphs.
75
+ # * <tt>:no_images</tt> - Treat image links as if they were plain links.
76
+ # * <tt>:media</tt> - Replace audio/video links with HTML5 audio/video objects.
77
+ # * <tt>:codeblock</tt> - Render block enclosed in ~~~ as verbatim section.
78
+ # * <tt>:hashtags</tt> - Mark hashtags.
79
+ # * <tt>:usernames</tt> - Mark usernames.
80
+ # * <tt>:spoilerblock</tt> - Render block prefixed with ?> as spoiler section.
81
+ #
82
+ def initialize(text, *extensions)
83
+ @text = text
84
+ @smart = false
85
+ @notes = false
86
+ @filter_styles = false
87
+ @filter_html = false
88
+ @strike = false
89
+ @autolink = false
90
+ @hard_wrap = false
91
+ @no_images = false
92
+ @media = false
93
+ @codeblock = false
94
+ @hashtags = false
95
+ @usernames = false
96
+ @spoilerblock = false
97
+ extensions.each { |e| send("#{e}=", true) }
98
+ end
99
+
100
+ alias to_s text
101
+
102
+ end
103
+
104
+ Markdown = PEGMarkdown unless defined? Markdown