4 # EXPERIMENTAL Markdown processor with minimal dependencies.
5 # Meant to support all features of John Grubers basic Markdown
6 # + a number of common extensions, mostly inspired by Pandoc Markdown
9 # - HTML processing / escaping (according to environment flag)
10 # - em-dashes and arrows
12 # Supported Features / TODO:
13 # ==========================
14 # [x] done [ ] todo [-] not planned ? unsure
16 # Basic Markdown - Block elements:
17 # -------------------------------
19 # - [x] Double space line breaks
20 # - [x] Proper block element nesting
22 # - [x] ATX-Style Headings
24 # - [x] Lists (ordered, unordered)
25 # - [x] Code blocks (using indention)
26 # - [x] Horizontal rules
27 # - [x] Verbatim HTML block (disabled by default)
29 # Basic Markdown - Inline elements:
30 # ---------------------------------
32 # - [x] Reference style links
33 # - [x] Emphasis *em*/**strong** (*Asterisk*, _Underscore_)
34 # - [x] `code`, also ``code containing `backticks` ``
35 # - [x] Images / reference style images
36 # - [x] <automatic links>
37 # - [x] backslash escapes
38 # - [x] Verbatim HTML inline (disabled by default)
41 # NOTE: Set the environment variable MD_HTML=true to enable verbatim HTML
43 # Extensions - Block elements:
44 # ----------------------------
45 # - ? Heading identifiers (php md, pandoc)
46 # - [x] Automatic heading identifiers (custom)
47 # - [x] Fenced code blocks (php md, pandoc)
48 # - [-] Fenced code attributes
50 # - ? Simple table (pandoc)
51 # - ? Multiline table (pandoc)
52 # - ? Grid table (pandoc)
53 # - ? Pipe table (php md pandoc)
54 # - [x] Line blocks (pandoc)
55 # - [x] Task lists (pandoc)
56 # - [ ] Definition lists (php md, pandoc)
57 # - [-] Numbered example lists (pandoc)
58 # - [-] Metadata blocks (pandoc)
59 # - [-] Fenced Divs (pandoc)
61 # Extensions - Inline elements:
62 # ----------------------------
63 # - [x] Ignore embedded_underscores (php md, pandoc)
64 # - [x] ~~strikeout~~ (pandoc)
65 # - [x] ^Superscript^ ~Subscript~ (pandoc)
66 # - [-] Bracketed spans (pandoc)
67 # - [-] Inline attributes (pandoc)
68 # - [-] TEX-Math (pandoc)
69 # - ? Footnotes (php md)
70 # - ? Abbreviations (php md)
71 # - ? "Curly quotes" (smartypants)
72 # - [ ] em-dashes (--) (smartypants old)
73 # - ? ... three-dot ellipsis (smartypants)
74 # - [-] en-dash (smartypants)
75 # - [ ] Automatic em-dash / en-dash
76 # - [ ] Automatic -> Arrows <-
78 function debug(text) { printf "\n---\n%s\n---\n", text > "/dev/stderr"; }
80 function HTML ( text ) {
81 gsub( /&/, "\\&", text );
82 gsub( /</, "\\<", text );
83 gsub( />/, "\\>", text );
84 gsub( /"/, "\\"", text );
85 gsub( /'/, "\\'", text );
86 gsub( /\\/, "\\\", text );
90 function inline( line, LOCAL, len, code, href, guard ) {
91 nu = "(\\\\\\\\|\\\\[^\\\\]|[^\\\\_]|_[[:alnum:]])*" # not underline (except when escaped)
92 na = "(\\\\\\\\|\\\\[^\\\\]|[^\\\\\\*])*" # not asterisk (except when escaped)
93 ieu = "_([^_[:space:]]|[^_[:space:]]" nu "[^_[:space:]])_" # inner <em> (underline)
94 isu = "__([^_[:space:]]|[^_[:space:]]" nu "[^_[:space:]])__" # inner <strong> (underline)
95 iea = "\\*([^\\*[:space:]]|[^\\*[:space:]]" na "[^\\*[:space:]])\\*" # inner <em> (asterisk)
96 isa = "\\*\\*([^\\*[:space:]]|[^\\*[:space:]]" na "[^\\*[:space:]])\\*\\*" # inner <strong> (asterisk)
98 if ( line ~ /^$/ ) { # Recursion End
101 # omit processing of escaped characters
102 } else if ( line ~ /^\\[]\\`\*_\{\}\(\)#\+-\.![]/) {
103 return substr(line, 2, 1) inline( substr(line, 3) );
106 } else if ( match(line, /^ \n/) ) {
107 return "<br />\n" inline( substr(line, RLENGTH + 1) );
110 } else if ( match( line, /^`+/) ) {
112 guard = substr( line, 1, len )
113 if ( match(line, guard ".*" guard) ) {
114 code = substr( line, len + 1, match( substr(line, len + 1), guard ) - 1)
115 len = 2 * length(guard) + length(code)
116 # strip single surrounding white spaces
117 code = gensub( / (.*) /, "\\1", "1" , code)
118 # escape HTML within code span
119 gsub( /&/, "\\&", code ); gsub( /</, "\\<", code ); gsub( />/, "\\>", code );
120 return "<code>" code "</code>" inline( substr( line, len + 1 ) )
123 # quick links ("automatic links" in md doc)
124 } else if ( match( line, /^<[a-zA-Z]+:\/\/([-\.[:alnum:]]+)(:[0-9]*)?(\/[^>]*)?>/ ) ) {
126 href = HTML( substr( line, 2, len - 2) );
127 return "<a href=\"" href "\">" href "</a>" inline( substr( line, len + 1) );
130 } else if ( match(line, /^\[([^]]+)\]\(([^"\)]+)([ \t]+"([^"]+)")?\)/) ) {
132 text = gensub(/^\[([^]]+)\]\(([^"\)]+)([ \t]+"([^"]+)")?\)/, "\\1", "g", line);
133 href = gensub(/^\[([^]]+)\]\(([^"\)]+)([ \t]+"([^"]+)")?\)/, "\\2", "g", line);
134 title = gensub(/^\[([^]]+)\]\(([^"\)]+)([ \t]+"([^"]+)")?\)/, "\\4", "g", line);
136 return "<a href=\"" HTML(href) "\" title=\"" HTML(title) "\">" inline( text ) "</a>" inline( substr( line, len + 1) );
138 return "<a href=\"" HTML(href) "\">" inline( text ) "</a>" inline( substr( line, len + 1) );
141 # reference style links
142 } else if ( match(line, /^\[([^]]+)\] ?\[([^]]*)\]/ ) ) {
144 text = gensub(/^\[([^\n]+)\] ?\[([^\n]*)\].*/, "\\1", 1, line);
145 id = gensub(/^\[([^\n]+)\] ?\[([^\n]*)\].*/, "\\2", 1, line);
146 if ( ! id ) id = text;
147 if ( rl_href[id] && rl_title[id] ) {
148 return "<a href=\"" rl_href[id] "\" title=\"" rl_title[id] "\">" inline(text) "</a>" inline( substr( line, len + 1) );
149 } else if ( rl_href[id] ) {
150 return "<a href=\"" rl_href[id] "\">" inline(text) "</a>" inline( substr( line, len + 1) );
152 return "" substr(line, 1, len) inline( substr(line, len + 1) );
156 } else if ( match(line, /^!\[([^]]+)\]\(([^"\)]+)([ \t]+"([^"]+)")?\)/) ) {
158 text = gensub(/^!\[([^]]+)\]\(([^"\)]+)([ \t]+"([^"]+)")?\)/, "\\1", "g", line);
159 href = gensub(/^!\[([^]]+)\]\(([^"\)]+)([ \t]+"([^"]+)")?\)/, "\\2", "g", line);
160 title = gensub(/^!\[([^]]+)\]\(([^"\)]+)([ \t]+"([^"]+)")?\)/, "\\4", "g", line);
162 return "<img src=\"" HTML(href) "\" alt=\"" HTML(text) "\" title=\"" HTML(title) "\" />" inline( substr( line, len + 1) );
164 return "<img src=\"" HTML(href) "\" alt=\"" HTML(text) "\" />" inline( substr( line, len + 1) );
167 # reference style images
168 } else if ( match(line, /^!\[([^]]+)\] ?\[([^]]*)\]/ ) ) {
170 text = gensub(/^!\[([^\n]+)\] ?\[([^\n]*)\].*/, "\\1", 1, line);
171 id = gensub(/^!\[([^\n]+)\] ?\[([^\n]*)\].*/, "\\2", 1, line);
172 if ( ! id ) id = text;
173 if ( rl_href[id] && rl_title[id] ) {
174 return "<img src=\"" rl_href[id] "\" alt=\"" HTML(text) "\" title=\"" rl_title[id] "\" />" inline( substr( line, len + 1) );
175 } else if ( rl_href[id] ) {
176 return "<img src=\"" rl_href[id] "\" alt=\"" HTML(text) "\" />" inline( substr( line, len + 1) );
178 return "" substr(line, 1, len) inline( substr(line, len + 1) );
181 # ~~strikeout~~ (pandoc)
182 } else if ( match(line, /^~~([[:graph:]]|[[:graph:]]([^~]|~[^~])*[[:graph:]])~~/) ) {
184 return "<del>" inline( substr( line, 3, len - 4 ) ) "</del>" inline( substr( line, len + 1 ) );
186 # ^superscript^ (pandoc)
187 } else if ( match(line, /^\^([^[:space:]^]|\\[ ^])+\^/) ) {
189 return "<sup>" inline( substr( line, 2, len - 2 ) ) "</sup>" inline( substr( line, len + 1 ) );
191 # ~subscript~ (pandoc)
192 } else if ( match(line, /^~([^[:space:]~]|\\[ ~])+~/) ) {
194 return "<sub>" inline( substr( line, 2, len - 2 ) ) "</sub>" inline( substr( line, len + 1 ) );
196 # ignore embedded underscores (pandoc, php md)
197 } else if ( match(line, "^[[:alnum:]](__|_)") ) {
198 return substr( line, 1, RLENGTH) inline( substr(line, RLENGTH + 1) );
201 } else if ( match(line, "^__(([^_[:space:]]|" ieu ")|([^_[:space:]]|" ieu ")(" nu "|" ieu ")*([^_[:space:]]|" ieu "))__$") ) {
203 return "<strong>" inline( substr( line, 3, len - 4 ) ) "</strong>" inline( substr( line, len + 1 ) );
206 } else if ( match(line, "^__(([^_[:space:]]|" ieu ")|([^_[:space:]]|" ieu ")(" nu "|" ieu ")*([^_[:space:]]|" ieu "))__[[:space:][:punct:]]") ) {
208 return "<strong>" inline( substr( line, 3, len - 5 ) ) "</strong>" inline( substr( line, len) );
211 } else if ( match(line, "^\\*\\*(([^\\*[:space:]]|" iea ")|([^\\*[:space:]]|" iea ")(" na "|" iea ")*([^\\*[:space:]]|" iea "))\\*\\*") ) {
213 return "<strong>" inline( substr( line, 3, len - 4 ) ) "</strong>" inline( substr( line, len + 1 ) );
216 } else if ( match(line, "^_(([^_[:space:]]|" isu ")|([^_[:space:]]|" isu ")(" nu "|" isu ")*([^_[:space:]]|" isu "))_$") ) {
218 return "<em>" inline( substr( line, 2, len - 2 ) ) "</em>" inline( substr( line, len + 1 ) );
221 } else if ( match(line, "^_(([^_[:space:]]|" isu ")|([^_[:space:]]|" isu ")(" nu "|" isu ")*([^_[:space:]]|" isu "))_[[:space:][:punct:]]") ) {
223 return "<em>" inline( substr( line, 2, len - 3 ) ) "</em>" inline( substr( line, len ) );
226 } else if ( match(line, "^\\*(([^\\*[:space:]]|" isa ")|([^\\*[:space:]]|" isa ")(" na "|" isa ")*([^\\*[:space:]]|" isa "))\\*") ) {
228 return "<em>" inline( substr( line, 2, len - 2 ) ) "</em>" inline( substr( line, len + 1 ) );
230 # Verbatim inline HTML
231 } else if ( AllowHTML && match( line, /^(<!--([^-]|-[^-]|--[^>])*-->|<\?([^\?]|\?[^>])*\?>|<![A-Z][^>]*>|<!\[CDATA\[([^\]]|\][^\]]|\]\][^>])*\]\]>|<\/[A-Za-z][A-Za-z0-9-]*[[:space:]]*>|<[A-Za-z][A-Za-z0-9-]*([[:space:]]+[A-Za-z_:][A-Za-z0-9_\.:-]*([[:space:]]*=[[:space:]]*([[:space:]"'=<>`]+|"[^"]*"|'[^']*'))?)*[[:space:]]*\/?>)/) ) {
233 return substr( line, 1, len) inline(substr(line, len + 1));
235 # Literal HTML entities
236 } else if ( match( line, /^&([a-zA-Z]{2,32}|#[0-9]{1,7}|#[xX][0-9a-fA-F]{1,6});/) ) {
238 return substr( line, 1, len ) inline(substr(line, len + 1));
240 # Escape lone HTML character
241 } else if ( match( line, /^[&<>"']/) ) {
242 return HTML(substr(line, 1, 1)) inline(substr(line, 2));
244 # continue walk over string
246 return substr(line, 1, 1) inline( substr(line, 2) );
250 function _block( block, LOCAL, st, len, hlvl, htxt, guard, code, indent ) {
251 gsub( /^\n+|\n+$/, "", block );
257 } else if ( AllowHTML && match( block, /(^|\n) ? ? ?(<!--([^-]|-[^-]|--[^>])*(-->|$)|<\?([^\?]|\?[^>])*(\?>|$)|<![A-Z][^>]*(>|$)|<!\[CDATA\[([^\]]|\][^\]]|\]\][^>])*(\]\]>|$))/) ) {
258 len = RLENGTH; st = RSTART;
259 return _block(substr(block, 1, st - 1)) substr(block, st, len) _block(substr(block, st + len));
262 } else if ( AllowHTML && match( tolower(block), /(^|\n) ? ? ?<\/?(address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[123456]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)([[:space:]\n>]|\/>)([^\n]|\n[ \t]*[^\n])*(\n[[:space:]]*\n|$)/) ) {
263 len = RLENGTH; st = RSTART;
264 return _block(substr(block, 1, st - 1)) substr(block, st, len) _block(substr(block, st + len));
267 } else if ( AllowHTML && match( tolower(block), /(^|\n) ? ? ?<(script|pre|style)([[:space:]\n>]).*(<\/script>|<\/pre>|<\/style>|$)/) ) {
268 len = RLENGTH; st = RSTART;
269 match( tolower(substr(block, st, len)), /(<\/script>|<\/pre>|<\/style>)/);
270 len = RSTART + RLENGTH;
271 return _block(substr(block, 1, st - 1)) substr(block, st, len) _block(substr(block, st + len));
274 } else if ( AllowHTML && match( block, /^ ? ? ?(<\/[A-Za-z][A-Za-z0-9-]*[[:space:]]*>|<[A-Za-z][A-Za-z0-9-]*([[:space:]]+[A-Za-z_:][A-Za-z0-9_\.:-]*([[:space:]]*=[[:space:]]*([[:space:]"'=<>`]+|"[^"]*"|'[^']*'))?)*[[:space:]]*\/?>)([[:space:]]*\n)([^\n]|\n[ \t]*[^\n])*(\n[[:space:]]*\n|$)/) ) {
275 len = RLENGTH; st = RSTART;
276 return substr(block, st, len) _block(substr(block, st + len));
278 # Blockquote (leading >)
279 } else if ( match( block, /^> /) ) {
280 match( block, /(^|\n)[[:space:]]*(\n|$)/ ) || match(block, /$/);
281 len = RLENGTH; st = RSTART;
282 return "<blockquote>\n" _block( gensub( /(^|\n)> /, "\n", "g", substr(block, 1, st - 1) ) ) "</blockquote>\n\n" \
283 _block( substr(block, st + len) );
285 # Line Blocks (pandoc)
286 } else if ( match(block, /^\| [^\n]*(\n|$)(\| [^\n]*(\n|$)|[ \t]+[^\n[:space:]][^\n]*(\n|$))*/) ) {
287 len = RLENGTH; st = RSTART;
288 code = substr(block, 1, len);
289 gsub(/\n[[:space:]]+/, " ", code);
290 gsub(/\n\| /, "\n", code);
291 gsub(/^\| |\n$/, "", code);
292 return "<div class=\"line-block\">" gensub(/\n/, "<br />\n", "g", inline( code )) "</div>\n" \
293 _block( substr( block, len + 1) );
295 # Indented Code Block
296 } else if ( match(block, /^( |\t)[^\n]+(\n|$)(( |\t)[^\n]+(\n|$)|[ \t]*(\n|$))*/) ) {
297 len = RLENGTH; st = RSTART;
298 code = substr(block, 1, len);
299 gsub(/(^|\n)( |\t)/, "\n", code);
300 gsub(/^\n|\n+$/, "", code);
301 return "<pre><code>" HTML( code ) "</code></pre>\n" \
302 _block( substr( block, len + 1 ) );
304 # Fenced Code Block (pandoc)
305 } else if ( match( block, /^(~~~+|```+)/ ) ) {
306 guard = substr( block, 1, RLENGTH );
307 code = gensub(/^[^\n]+\n/, "", 1, block);
308 if ( match(code, "(^|\n)" guard "+(\n|$)" ) ) {
309 len = RLENGTH; st = RSTART;
310 return "<pre><code>" HTML( substr(code, 1, st - 1) ) "</code></pre>\n" \
311 _block( substr( code, st + len ) );
313 match( block, /(^|\n)[[:space:]]*(\n|$)/ ) || match( block, /$/ );
314 len = RLENGTH; st = RSTART;
315 return "<p>" inline( substr(block, 1, st - 1) ) "</p>\n" \
316 _block( substr(block, st + len) );
320 } else if ( match( block, "^ ? ? ?[-+*][ \t]+[^\n]+(\n|$)" \
321 "(([ \t]*\n)* ? ? ?[-+*][ \t]+[^\n]+(\n|$)" \
322 "|([ \t]*\n)*( ? ? ?\t| +)[^\n]+(\n|$)" \
323 "|[^\n]+(\n|$))*" ) ) {
324 list = substr( block, 1, RLENGTH);
325 block = substr( block, RLENGTH + 1);
326 indent = length( gensub(/[-+*][ \t]+[^\n]+.*$/, "", 1, list) );
328 gsub("(^|\n) {0," indent "}", "\n", list);
329 return "\n<ul>\n" _list( substr(list, 2) ) "</ul>\n" _block( block );
332 } else if ( match( block, "^ ? ? ?([0-9]+|#)\\.[ \t]+[^\n]+(\n|$)" \
333 "(([ \t]*\n)* ? ? ?([0-9]+|#)\\.[ \t]+[^\n]+(\n|$)" \
334 "|([ \t]*\n)*( ? ? ?\t| +)[^\n]+(\n|$)" \
335 "|[^\n]+(\n|$))*" ) ) {
336 list = substr( block, 1, RLENGTH);
337 block = substr( block, RLENGTH + 1);
338 indent = length( gensub(/([0-9]+|#)\.[ \t]+[^\n]+.*$/, "", 1, list) );
340 gsub("(^|\n) {0," indent "}", "\n", list);
341 return "\n<ol>\n" _list( substr(list, 2) ) "</ol>\n" _block( block );
343 # First Order Heading
344 } else if ( match( block, /^[^\n]+\n===+(\n|$)/ ) ) {
346 HL[1]++; HL[2] = 0; HL[3] = 0; HL[4] = 0; HL[5] = 0; HL[6] = 0;
347 return "<h1 id=\"" HL[1] " - " HTML(gensub( /\n.*$/, "", "g", block )) "\">" inline( gensub( /\n.*$/, "", "g", block ) ) "</h1>\n\n" \
348 _block( substr( block, len + 1 ) );
350 # Second Order Heading
351 } else if ( match( block, /^[^\n]+\n---+(\n|$)/ ) ) {
353 HL[2]++; HL[3] = 0; HL[4] = 0; HL[5] = 0; HL[6] = 0;
354 return "<h2 id=\"" HL[1] "." HL[2] " - " HTML(gensub( /\n.*$/, "", "g", block )) "\">" inline( gensub( /\n.*$/, "", "g", block ) ) "</h2>\n\n" \
355 _block( substr( block, len + 1) );
358 } else if ( match( block, /^#{1,6}[ \t]*[^\n]+([ \t]*#*)(\n|$)/ ) ) {
360 hlvl = length( gensub( /^(#{1,6}).*$/, "\\1", "g", block ) );
361 htxt = gensub(/^#{1,6}[ \t]*(([^ \t\n]+|[ \t]+[^ \t\n#]|[ \t]+#+[^\n#])+)([ \t]*#*)(\n.*)?$/, "\\1", 1, block);
362 HL[hlvl]++; for ( n = hlvl + 1; n < 7; n++) { HL[n] = 0;}
363 hid = HL[1]; for ( n = 2; n <= hlvl; n++) { hid = hid "." HL[n] ; }
364 return "<h" hlvl " id=\"" hid " - " HTML(htxt) "\">" inline( htxt ) "</h" hlvl ">\n\n" \
365 _block( substr( block, len + 1) );
368 } else if ( match( block, /(^|\n) ? ? ?((\* *){3,}|(- *){3,}|(_ *){3,})($|\n)/) ) {
369 len = RLENGTH; st = RSTART;
370 return _block(substr(block, 1, st - 1)) "<hr />\n" _block(substr(block, st + len));
374 match( block, /(^|\n)[[:space:]]*(\n|$)/ ) || match( block, /$/ );
375 len = RLENGTH; st = RSTART;
376 return "<p>" inline( substr(block, 1, st - 1) ) "</p>\n" \
377 _block( substr(block, st + len) );
381 function _list( block, last, LOCAL, p) {
382 if ( ! length(block) ) return "";
383 gsub(/^([-+*]|[0-9]+\.|#\.)( ? ? ?|\t)/, "", block)
385 # slice next list item from input
386 if ( match( block, /\n([-+*]|[0-9]+\.|#\.)[ \t]+[^\n]+/) ) {
387 p = substr( block, 1, RSTART);
388 block = substr( block, RSTART + 1);
390 p = block; block = "";
392 sub( /\n +([-+*]|[0-9]+\.|#\.)/, "\n&", p );
394 # if this should be a paragraph item
395 # either previous item (last) or current item (p) contains blank lines
396 if (match(last, /\n[[:space:]]*\n/) || match(p, /\n[[:space:]]*\n/) ) {
397 last = p; p = _block(p);
399 last = p; p = _block(p);
400 sub( /^<p>/, "", p );
401 sub( /<\/p>\n/, "", p );
406 if ( p ~ /^\[ \].*/ ) { p = "<input type=checkbox disabled />" substr(p, 4); }
407 else if ( p ~ /^\[[xX]\].*/ ) { p = "<input type=checkbox disabled checked />" substr(p, 4); }
408 else if ( p ~ /^<p>\[ \].*/ ) { p = "<p><input type=checkbox disabled />" substr(p, 7); }
409 else if ( p ~ /^<p>\[[xX]\].*/ ) { p = "<p><input type=checkbox disabled checked />" substr(p, 7); }
410 return "<li>" p "</li>\n" _list( block, last );
415 file = ""; rl_href[""] = ""; rl_title[""] = "";
416 if (ENVIRON["MD_HTML"] == "true") { AllowHTML = "true"; }
417 HL[1] = 0; HL[2] = 0; HL[3] = 0; HL[4] = 0; HL[5] = 0; HL[6] = 0;
419 # Buffering of full file ist necessary, e.g. to find reference links
420 while (getline) { file = file $0 "\n"; }
421 # Clean up MS-DOS line breaks
422 gsub(/\r\n/, "\n", file);
424 # Fill array of reference links
426 re_reflink = "(^|\n) ? ? ?\\[([^]\n]+)\\]: ([^ \t\n]+)(\n?[ \t]+(\"([^\"]+)\"|'([^']+)'|\\(([^)]+)\\)))?(\n|$)";
427 # /(^|\n) ? ? ?\[([^]\n]+)\]: ([^ \t\n]+)(\n?[ \t]+("([^"]+)"|'([^']+)'|\(([^)]+)\)))?(\n|$)/
428 while ( match(f, re_reflink ) ) {
429 rl_id = gensub( re_reflink, "\\2", 1, substr(f, RSTART, RLENGTH) );
430 rl_href[rl_id] = gensub( re_reflink, "\\3", 1, substr(f, RSTART, RLENGTH) );
431 rl_title[rl_id] = gensub( re_reflink, "\\5", 1, substr(f, RSTART, RLENGTH) );
432 f = substr(f, RSTART + RLENGTH);
433 rl_title[rl_id] = substr( rl_title[rl_id], 2, length(rl_title[rl_id]) - 2 );
434 if ( rl_href[rl_id] ~ /<.*>/ ) rl_href[rl_id] = substr( rl_href[rl_id], 2, length(rl_href[rl_id]) - 2 );
436 # Clear reflinks from File
437 while( gsub(re_reflink, "\n", file ) );
438 # for (n in rl_href) { debug(n " | " rl_href[n] " | " rl_title[n] ); }
440 # Run Block Processing -> The Actual Markdown!
441 printf "%s", _block( file );