daqing_kramdown 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/AUTHORS +1 -0
- data/CONTRIBUTERS +78 -0
- data/COPYING +30 -0
- data/README.md +71 -0
- data/VERSION +1 -0
- data/bin/daqing_kramdown +132 -0
- data/data/kramdown/document.html +22 -0
- data/data/kramdown/document.latex +50 -0
- data/lib/kramdown.rb +10 -0
- data/lib/kramdown/converter.rb +68 -0
- data/lib/kramdown/converter/base.rb +261 -0
- data/lib/kramdown/converter/hash_ast.rb +38 -0
- data/lib/kramdown/converter/html.rb +535 -0
- data/lib/kramdown/converter/kramdown.rb +448 -0
- data/lib/kramdown/converter/latex.rb +625 -0
- data/lib/kramdown/converter/man.rb +300 -0
- data/lib/kramdown/converter/math_engine/mathjax.rb +32 -0
- data/lib/kramdown/converter/remove_html_tags.rb +57 -0
- data/lib/kramdown/converter/syntax_highlighter.rb +56 -0
- data/lib/kramdown/converter/syntax_highlighter/minted.rb +35 -0
- data/lib/kramdown/converter/syntax_highlighter/rouge.rb +85 -0
- data/lib/kramdown/converter/toc.rb +69 -0
- data/lib/kramdown/document.rb +139 -0
- data/lib/kramdown/element.rb +551 -0
- data/lib/kramdown/error.rb +17 -0
- data/lib/kramdown/options.rb +604 -0
- data/lib/kramdown/parser.rb +26 -0
- data/lib/kramdown/parser/base.rb +131 -0
- data/lib/kramdown/parser/html.rb +608 -0
- data/lib/kramdown/parser/kramdown.rb +376 -0
- data/lib/kramdown/parser/kramdown/abbreviation.rb +78 -0
- data/lib/kramdown/parser/kramdown/autolink.rb +31 -0
- data/lib/kramdown/parser/kramdown/blank_line.rb +30 -0
- data/lib/kramdown/parser/kramdown/block_boundary.rb +34 -0
- data/lib/kramdown/parser/kramdown/blockquote.rb +38 -0
- data/lib/kramdown/parser/kramdown/codeblock.rb +57 -0
- data/lib/kramdown/parser/kramdown/codespan.rb +54 -0
- data/lib/kramdown/parser/kramdown/emphasis.rb +61 -0
- data/lib/kramdown/parser/kramdown/eob.rb +26 -0
- data/lib/kramdown/parser/kramdown/escaped_chars.rb +25 -0
- data/lib/kramdown/parser/kramdown/extensions.rb +214 -0
- data/lib/kramdown/parser/kramdown/footnote.rb +64 -0
- data/lib/kramdown/parser/kramdown/header.rb +70 -0
- data/lib/kramdown/parser/kramdown/horizontal_rule.rb +27 -0
- data/lib/kramdown/parser/kramdown/html.rb +162 -0
- data/lib/kramdown/parser/kramdown/html_entity.rb +34 -0
- data/lib/kramdown/parser/kramdown/line_break.rb +25 -0
- data/lib/kramdown/parser/kramdown/link.rb +149 -0
- data/lib/kramdown/parser/kramdown/list.rb +284 -0
- data/lib/kramdown/parser/kramdown/math.rb +53 -0
- data/lib/kramdown/parser/kramdown/paragraph.rb +62 -0
- data/lib/kramdown/parser/kramdown/smart_quotes.rb +174 -0
- data/lib/kramdown/parser/kramdown/table.rb +171 -0
- data/lib/kramdown/parser/kramdown/typographic_symbol.rb +44 -0
- data/lib/kramdown/parser/markdown.rb +57 -0
- data/lib/kramdown/utils.rb +45 -0
- data/lib/kramdown/utils/configurable.rb +45 -0
- data/lib/kramdown/utils/entities.rb +344 -0
- data/lib/kramdown/utils/html.rb +84 -0
- data/lib/kramdown/utils/lru_cache.rb +41 -0
- data/lib/kramdown/utils/string_scanner.rb +81 -0
- data/lib/kramdown/utils/unidecoder.rb +50 -0
- data/lib/kramdown/version.rb +15 -0
- data/man/man1/kramdown.1 +0 -0
- data/test/run_tests.rb +46 -0
- data/test/test_files.rb +298 -0
- data/test/test_location.rb +216 -0
- data/test/test_string_scanner_kramdown.rb +27 -0
- data/test/testcases/block/01_blank_line/spaces.html +1 -0
- data/test/testcases/block/01_blank_line/spaces.text +3 -0
- data/test/testcases/block/01_blank_line/tabs.html +1 -0
- data/test/testcases/block/01_blank_line/tabs.text +6 -0
- data/test/testcases/block/02_eob/beginning.html +1 -0
- data/test/testcases/block/02_eob/beginning.text +3 -0
- data/test/testcases/block/02_eob/end.html +1 -0
- data/test/testcases/block/02_eob/end.text +3 -0
- data/test/testcases/block/02_eob/middle.html +1 -0
- data/test/testcases/block/02_eob/middle.text +5 -0
- data/test/testcases/block/03_paragraph/indented.html +18 -0
- data/test/testcases/block/03_paragraph/indented.html.gfm +18 -0
- data/test/testcases/block/03_paragraph/indented.text +19 -0
- data/test/testcases/block/03_paragraph/line_break_last_line.html +9 -0
- data/test/testcases/block/03_paragraph/line_break_last_line.text +9 -0
- data/test/testcases/block/03_paragraph/no_newline_at_end.html +5 -0
- data/test/testcases/block/03_paragraph/no_newline_at_end.text +5 -0
- data/test/testcases/block/03_paragraph/one_para.html +1 -0
- data/test/testcases/block/03_paragraph/one_para.text +1 -0
- data/test/testcases/block/03_paragraph/standalone_image.html +8 -0
- data/test/testcases/block/03_paragraph/standalone_image.text +6 -0
- data/test/testcases/block/03_paragraph/two_para.html +4 -0
- data/test/testcases/block/03_paragraph/two_para.text +4 -0
- data/test/testcases/block/03_paragraph/with_html_to_native.html +1 -0
- data/test/testcases/block/03_paragraph/with_html_to_native.options +1 -0
- data/test/testcases/block/03_paragraph/with_html_to_native.text +1 -0
- data/test/testcases/block/04_header/atx_header.html +57 -0
- data/test/testcases/block/04_header/atx_header.text +54 -0
- data/test/testcases/block/04_header/atx_header_no_newline_at_end.html +1 -0
- data/test/testcases/block/04_header/atx_header_no_newline_at_end.text +1 -0
- data/test/testcases/block/04_header/header_type_offset.html +11 -0
- data/test/testcases/block/04_header/header_type_offset.kramdown +12 -0
- data/test/testcases/block/04_header/header_type_offset.latex +12 -0
- data/test/testcases/block/04_header/header_type_offset.options +2 -0
- data/test/testcases/block/04_header/header_type_offset.text +13 -0
- data/test/testcases/block/04_header/setext_header.html +32 -0
- data/test/testcases/block/04_header/setext_header.text +39 -0
- data/test/testcases/block/04_header/setext_header_no_newline_at_end.html +1 -0
- data/test/testcases/block/04_header/setext_header_no_newline_at_end.text +2 -0
- data/test/testcases/block/04_header/with_auto_id_prefix.html +3 -0
- data/test/testcases/block/04_header/with_auto_id_prefix.options +2 -0
- data/test/testcases/block/04_header/with_auto_id_prefix.text +3 -0
- data/test/testcases/block/04_header/with_auto_id_stripping.html +1 -0
- data/test/testcases/block/04_header/with_auto_id_stripping.options +1 -0
- data/test/testcases/block/04_header/with_auto_id_stripping.text +1 -0
- data/test/testcases/block/04_header/with_auto_ids.html +21 -0
- data/test/testcases/block/04_header/with_auto_ids.options +2 -0
- data/test/testcases/block/04_header/with_auto_ids.text +24 -0
- data/test/testcases/block/05_blockquote/indented.html +25 -0
- data/test/testcases/block/05_blockquote/indented.text +14 -0
- data/test/testcases/block/05_blockquote/lazy.html +34 -0
- data/test/testcases/block/05_blockquote/lazy.text +20 -0
- data/test/testcases/block/05_blockquote/nested.html +10 -0
- data/test/testcases/block/05_blockquote/nested.text +6 -0
- data/test/testcases/block/05_blockquote/no_newline_at_end.html +4 -0
- data/test/testcases/block/05_blockquote/no_newline_at_end.text +2 -0
- data/test/testcases/block/05_blockquote/very_long_line.html +3 -0
- data/test/testcases/block/05_blockquote/very_long_line.text +1 -0
- data/test/testcases/block/05_blockquote/with_code_blocks.html +15 -0
- data/test/testcases/block/05_blockquote/with_code_blocks.text +11 -0
- data/test/testcases/block/06_codeblock/disable-highlighting.html +4 -0
- data/test/testcases/block/06_codeblock/disable-highlighting.options +1 -0
- data/test/testcases/block/06_codeblock/disable-highlighting.text +4 -0
- data/test/testcases/block/06_codeblock/error.html +4 -0
- data/test/testcases/block/06_codeblock/error.text +4 -0
- data/test/testcases/block/06_codeblock/guess_lang_css_class.html +15 -0
- data/test/testcases/block/06_codeblock/guess_lang_css_class.options +2 -0
- data/test/testcases/block/06_codeblock/guess_lang_css_class.text +13 -0
- data/test/testcases/block/06_codeblock/highlighting-minted-with-opts.latex +9 -0
- data/test/testcases/block/06_codeblock/highlighting-minted-with-opts.options +4 -0
- data/test/testcases/block/06_codeblock/highlighting-minted-with-opts.text +5 -0
- data/test/testcases/block/06_codeblock/highlighting-minted.latex +8 -0
- data/test/testcases/block/06_codeblock/highlighting-minted.options +3 -0
- data/test/testcases/block/06_codeblock/highlighting-minted.text +4 -0
- data/test/testcases/block/06_codeblock/highlighting-opts.html +6 -0
- data/test/testcases/block/06_codeblock/highlighting-opts.options +7 -0
- data/test/testcases/block/06_codeblock/highlighting-opts.text +4 -0
- data/test/testcases/block/06_codeblock/highlighting.html +5 -0
- data/test/testcases/block/06_codeblock/highlighting.options +5 -0
- data/test/testcases/block/06_codeblock/highlighting.text +4 -0
- data/test/testcases/block/06_codeblock/issue_gh45.html +164 -0
- data/test/testcases/block/06_codeblock/issue_gh45.test +188 -0
- data/test/testcases/block/06_codeblock/lazy.html +4 -0
- data/test/testcases/block/06_codeblock/lazy.text +5 -0
- data/test/testcases/block/06_codeblock/no_newline_at_end.html +2 -0
- data/test/testcases/block/06_codeblock/no_newline_at_end.text +1 -0
- data/test/testcases/block/06_codeblock/no_newline_at_end_1.html +2 -0
- data/test/testcases/block/06_codeblock/no_newline_at_end_1.text +2 -0
- data/test/testcases/block/06_codeblock/normal.html +13 -0
- data/test/testcases/block/06_codeblock/normal.text +10 -0
- data/test/testcases/block/06_codeblock/rouge/disabled.html +2 -0
- data/test/testcases/block/06_codeblock/rouge/disabled.options +4 -0
- data/test/testcases/block/06_codeblock/rouge/disabled.text +1 -0
- data/test/testcases/block/06_codeblock/rouge/multiple.html +11 -0
- data/test/testcases/block/06_codeblock/rouge/multiple.options +4 -0
- data/test/testcases/block/06_codeblock/rouge/multiple.text +11 -0
- data/test/testcases/block/06_codeblock/rouge/simple.html +10 -0
- data/test/testcases/block/06_codeblock/rouge/simple.options +3 -0
- data/test/testcases/block/06_codeblock/rouge/simple.text +9 -0
- data/test/testcases/block/06_codeblock/tilde_syntax.html +7 -0
- data/test/testcases/block/06_codeblock/tilde_syntax.text +9 -0
- data/test/testcases/block/06_codeblock/whitespace.html +3 -0
- data/test/testcases/block/06_codeblock/whitespace.text +3 -0
- data/test/testcases/block/06_codeblock/with_blank_line.html +13 -0
- data/test/testcases/block/06_codeblock/with_blank_line.text +12 -0
- data/test/testcases/block/06_codeblock/with_eob_marker.html +6 -0
- data/test/testcases/block/06_codeblock/with_eob_marker.text +5 -0
- data/test/testcases/block/06_codeblock/with_ial.html +6 -0
- data/test/testcases/block/06_codeblock/with_ial.text +5 -0
- data/test/testcases/block/06_codeblock/with_lang_in_fenced_block.html +24 -0
- data/test/testcases/block/06_codeblock/with_lang_in_fenced_block.options +2 -0
- data/test/testcases/block/06_codeblock/with_lang_in_fenced_block.text +33 -0
- data/test/testcases/block/06_codeblock/with_lang_in_fenced_block_any_char.html +8 -0
- data/test/testcases/block/06_codeblock/with_lang_in_fenced_block_any_char.options +2 -0
- data/test/testcases/block/06_codeblock/with_lang_in_fenced_block_any_char.text +11 -0
- data/test/testcases/block/06_codeblock/with_lang_in_fenced_block_name_with_dash.html +3 -0
- data/test/testcases/block/06_codeblock/with_lang_in_fenced_block_name_with_dash.options +2 -0
- data/test/testcases/block/06_codeblock/with_lang_in_fenced_block_name_with_dash.text +4 -0
- data/test/testcases/block/07_horizontal_rule/error.html +7 -0
- data/test/testcases/block/07_horizontal_rule/error.text +7 -0
- data/test/testcases/block/07_horizontal_rule/normal.html +19 -0
- data/test/testcases/block/07_horizontal_rule/normal.text +20 -0
- data/test/testcases/block/07_horizontal_rule/sepspaces.html +3 -0
- data/test/testcases/block/07_horizontal_rule/sepspaces.text +3 -0
- data/test/testcases/block/07_horizontal_rule/septabs.html +3 -0
- data/test/testcases/block/07_horizontal_rule/septabs.text +3 -0
- data/test/testcases/block/08_list/brackets_in_item.latex +3 -0
- data/test/testcases/block/08_list/brackets_in_item.text +1 -0
- data/test/testcases/block/08_list/escaping.html +17 -0
- data/test/testcases/block/08_list/escaping.text +17 -0
- data/test/testcases/block/08_list/item_ial.html +10 -0
- data/test/testcases/block/08_list/item_ial.text +8 -0
- data/test/testcases/block/08_list/lazy.html +39 -0
- data/test/testcases/block/08_list/lazy.text +29 -0
- data/test/testcases/block/08_list/lazy_and_nested.html +9 -0
- data/test/testcases/block/08_list/lazy_and_nested.text +4 -0
- data/test/testcases/block/08_list/list_and_hr.html +9 -0
- data/test/testcases/block/08_list/list_and_hr.text +5 -0
- data/test/testcases/block/08_list/list_and_others.html +40 -0
- data/test/testcases/block/08_list/list_and_others.text +26 -0
- data/test/testcases/block/08_list/mixed.html +117 -0
- data/test/testcases/block/08_list/mixed.text +66 -0
- data/test/testcases/block/08_list/nested.html +17 -0
- data/test/testcases/block/08_list/nested.text +7 -0
- data/test/testcases/block/08_list/other_first_element.html +39 -0
- data/test/testcases/block/08_list/other_first_element.text +18 -0
- data/test/testcases/block/08_list/simple_ol.html +19 -0
- data/test/testcases/block/08_list/simple_ol.text +13 -0
- data/test/testcases/block/08_list/simple_ul.html +48 -0
- data/test/testcases/block/08_list/simple_ul.text +36 -0
- data/test/testcases/block/08_list/single_item.html +3 -0
- data/test/testcases/block/08_list/single_item.text +1 -0
- data/test/testcases/block/08_list/special_cases.html +62 -0
- data/test/testcases/block/08_list/special_cases.text +40 -0
- data/test/testcases/block/09_html/comment.html +18 -0
- data/test/testcases/block/09_html/comment.text +15 -0
- data/test/testcases/block/09_html/content_model/deflists.html +6 -0
- data/test/testcases/block/09_html/content_model/deflists.options +1 -0
- data/test/testcases/block/09_html/content_model/deflists.text +6 -0
- data/test/testcases/block/09_html/content_model/tables.html +14 -0
- data/test/testcases/block/09_html/content_model/tables.options +1 -0
- data/test/testcases/block/09_html/content_model/tables.text +14 -0
- data/test/testcases/block/09_html/html5_attributes.html +15 -0
- data/test/testcases/block/09_html/html5_attributes.text +15 -0
- data/test/testcases/block/09_html/html_after_block.html +7 -0
- data/test/testcases/block/09_html/html_after_block.text +5 -0
- data/test/testcases/block/09_html/html_and_codeblocks.html +15 -0
- data/test/testcases/block/09_html/html_and_codeblocks.options +1 -0
- data/test/testcases/block/09_html/html_and_codeblocks.text +13 -0
- data/test/testcases/block/09_html/html_and_headers.html +5 -0
- data/test/testcases/block/09_html/html_and_headers.text +6 -0
- data/test/testcases/block/09_html/html_to_native/code.html +10 -0
- data/test/testcases/block/09_html/html_to_native/code.text +9 -0
- data/test/testcases/block/09_html/html_to_native/comment.html +7 -0
- data/test/testcases/block/09_html/html_to_native/comment.text +8 -0
- data/test/testcases/block/09_html/html_to_native/emphasis.html +6 -0
- data/test/testcases/block/09_html/html_to_native/emphasis.text +6 -0
- data/test/testcases/block/09_html/html_to_native/entity.html +1 -0
- data/test/testcases/block/09_html/html_to_native/entity.text +1 -0
- data/test/testcases/block/09_html/html_to_native/header.html +6 -0
- data/test/testcases/block/09_html/html_to_native/header.options +2 -0
- data/test/testcases/block/09_html/html_to_native/header.text +6 -0
- data/test/testcases/block/09_html/html_to_native/list_dl.html +8 -0
- data/test/testcases/block/09_html/html_to_native/list_dl.text +8 -0
- data/test/testcases/block/09_html/html_to_native/list_ol.html +15 -0
- data/test/testcases/block/09_html/html_to_native/list_ol.text +17 -0
- data/test/testcases/block/09_html/html_to_native/list_ul.html +19 -0
- data/test/testcases/block/09_html/html_to_native/list_ul.text +22 -0
- data/test/testcases/block/09_html/html_to_native/options +1 -0
- data/test/testcases/block/09_html/html_to_native/paragraph.html +3 -0
- data/test/testcases/block/09_html/html_to_native/paragraph.text +4 -0
- data/test/testcases/block/09_html/html_to_native/table_normal.html +12 -0
- data/test/testcases/block/09_html/html_to_native/table_normal.text +12 -0
- data/test/testcases/block/09_html/html_to_native/table_simple.html +61 -0
- data/test/testcases/block/09_html/html_to_native/table_simple.text +71 -0
- data/test/testcases/block/09_html/html_to_native/typography.html +1 -0
- data/test/testcases/block/09_html/html_to_native/typography.text +1 -0
- data/test/testcases/block/09_html/invalid_html_1.html +5 -0
- data/test/testcases/block/09_html/invalid_html_1.text +5 -0
- data/test/testcases/block/09_html/invalid_html_2.html +5 -0
- data/test/testcases/block/09_html/invalid_html_2.text +5 -0
- data/test/testcases/block/09_html/markdown_attr.html +38 -0
- data/test/testcases/block/09_html/markdown_attr.text +38 -0
- data/test/testcases/block/09_html/not_parsed.html +24 -0
- data/test/testcases/block/09_html/not_parsed.text +24 -0
- data/test/testcases/block/09_html/parse_as_raw.html +35 -0
- data/test/testcases/block/09_html/parse_as_raw.htmlinput +34 -0
- data/test/testcases/block/09_html/parse_as_raw.options +1 -0
- data/test/testcases/block/09_html/parse_as_raw.text +33 -0
- data/test/testcases/block/09_html/parse_as_span.html +12 -0
- data/test/testcases/block/09_html/parse_as_span.htmlinput +12 -0
- data/test/testcases/block/09_html/parse_as_span.options +1 -0
- data/test/testcases/block/09_html/parse_as_span.text +9 -0
- data/test/testcases/block/09_html/parse_block_html.html +21 -0
- data/test/testcases/block/09_html/parse_block_html.options +1 -0
- data/test/testcases/block/09_html/parse_block_html.text +17 -0
- data/test/testcases/block/09_html/processing_instruction.html +12 -0
- data/test/testcases/block/09_html/processing_instruction.text +12 -0
- data/test/testcases/block/09_html/simple.html +60 -0
- data/test/testcases/block/09_html/simple.options +1 -0
- data/test/testcases/block/09_html/simple.text +55 -0
- data/test/testcases/block/09_html/standalone_image_in_div.htmlinput +7 -0
- data/test/testcases/block/09_html/standalone_image_in_div.text +8 -0
- data/test/testcases/block/09_html/textarea.html +8 -0
- data/test/testcases/block/09_html/textarea.text +8 -0
- data/test/testcases/block/09_html/xml.html +8 -0
- data/test/testcases/block/09_html/xml.text +7 -0
- data/test/testcases/block/10_ald/simple.html +2 -0
- data/test/testcases/block/10_ald/simple.text +8 -0
- data/test/testcases/block/11_ial/auto_id_and_ial.html +1 -0
- data/test/testcases/block/11_ial/auto_id_and_ial.options +1 -0
- data/test/testcases/block/11_ial/auto_id_and_ial.text +2 -0
- data/test/testcases/block/11_ial/nested.html +11 -0
- data/test/testcases/block/11_ial/nested.text +15 -0
- data/test/testcases/block/11_ial/simple.html +29 -0
- data/test/testcases/block/11_ial/simple.text +41 -0
- data/test/testcases/block/12_extension/comment.html +8 -0
- data/test/testcases/block/12_extension/comment.text +12 -0
- data/test/testcases/block/12_extension/ignored.html +8 -0
- data/test/testcases/block/12_extension/ignored.text +8 -0
- data/test/testcases/block/12_extension/nomarkdown.html +10 -0
- data/test/testcases/block/12_extension/nomarkdown.kramdown +20 -0
- data/test/testcases/block/12_extension/nomarkdown.latex +13 -0
- data/test/testcases/block/12_extension/nomarkdown.text +21 -0
- data/test/testcases/block/12_extension/options.html +21 -0
- data/test/testcases/block/12_extension/options.text +23 -0
- data/test/testcases/block/12_extension/options2.html +10 -0
- data/test/testcases/block/12_extension/options2.text +5 -0
- data/test/testcases/block/12_extension/options3.html +8 -0
- data/test/testcases/block/12_extension/options3.text +7 -0
- data/test/testcases/block/13_definition_list/auto_ids.html +15 -0
- data/test/testcases/block/13_definition_list/auto_ids.text +18 -0
- data/test/testcases/block/13_definition_list/definition_at_beginning.html +1 -0
- data/test/testcases/block/13_definition_list/definition_at_beginning.text +1 -0
- data/test/testcases/block/13_definition_list/deflist_ial.html +4 -0
- data/test/testcases/block/13_definition_list/deflist_ial.text +4 -0
- data/test/testcases/block/13_definition_list/item_ial.html +17 -0
- data/test/testcases/block/13_definition_list/item_ial.text +16 -0
- data/test/testcases/block/13_definition_list/multiple_terms.html +13 -0
- data/test/testcases/block/13_definition_list/multiple_terms.text +10 -0
- data/test/testcases/block/13_definition_list/no_def_list.html +2 -0
- data/test/testcases/block/13_definition_list/no_def_list.text +2 -0
- data/test/testcases/block/13_definition_list/para_wrapping.html +10 -0
- data/test/testcases/block/13_definition_list/para_wrapping.text +6 -0
- data/test/testcases/block/13_definition_list/separated_by_eob.html +8 -0
- data/test/testcases/block/13_definition_list/separated_by_eob.text +5 -0
- data/test/testcases/block/13_definition_list/simple.html +10 -0
- data/test/testcases/block/13_definition_list/simple.text +10 -0
- data/test/testcases/block/13_definition_list/styled_terms.html +4 -0
- data/test/testcases/block/13_definition_list/styled_terms.text +2 -0
- data/test/testcases/block/13_definition_list/too_much_space.html +3 -0
- data/test/testcases/block/13_definition_list/too_much_space.text +4 -0
- data/test/testcases/block/13_definition_list/with_blocks.html +38 -0
- data/test/testcases/block/13_definition_list/with_blocks.text +24 -0
- data/test/testcases/block/14_table/empty_tag_in_cell.html +8 -0
- data/test/testcases/block/14_table/empty_tag_in_cell.options +1 -0
- data/test/testcases/block/14_table/empty_tag_in_cell.text +1 -0
- data/test/testcases/block/14_table/errors.html +12 -0
- data/test/testcases/block/14_table/errors.text +13 -0
- data/test/testcases/block/14_table/escaping.html +52 -0
- data/test/testcases/block/14_table/escaping.text +19 -0
- data/test/testcases/block/14_table/footer.html +65 -0
- data/test/testcases/block/14_table/footer.text +25 -0
- data/test/testcases/block/14_table/header.html +117 -0
- data/test/testcases/block/14_table/header.text +39 -0
- data/test/testcases/block/14_table/no_table.html +3 -0
- data/test/testcases/block/14_table/no_table.text +3 -0
- data/test/testcases/block/14_table/simple.html +192 -0
- data/test/testcases/block/14_table/simple.text +53 -0
- data/test/testcases/block/14_table/table_with_footnote.html +25 -0
- data/test/testcases/block/14_table/table_with_footnote.latex +11 -0
- data/test/testcases/block/14_table/table_with_footnote.text +6 -0
- data/test/testcases/block/15_math/gh_128.html +1 -0
- data/test/testcases/block/15_math/gh_128.text +1 -0
- data/test/testcases/block/15_math/no_engine.html +3 -0
- data/test/testcases/block/15_math/no_engine.options +1 -0
- data/test/testcases/block/15_math/no_engine.text +2 -0
- data/test/testcases/block/15_math/normal.html +30 -0
- data/test/testcases/block/15_math/normal.text +30 -0
- data/test/testcases/block/16_toc/no_toc.html +14 -0
- data/test/testcases/block/16_toc/no_toc.text +16 -0
- data/test/testcases/block/16_toc/toc_exclude.html +35 -0
- data/test/testcases/block/16_toc/toc_exclude.options +1 -0
- data/test/testcases/block/16_toc/toc_exclude.text +19 -0
- data/test/testcases/block/16_toc/toc_levels.html +24 -0
- data/test/testcases/block/16_toc/toc_levels.options +2 -0
- data/test/testcases/block/16_toc/toc_levels.text +16 -0
- data/test/testcases/block/16_toc/toc_with_footnotes.html +13 -0
- data/test/testcases/block/16_toc/toc_with_footnotes.options +1 -0
- data/test/testcases/block/16_toc/toc_with_footnotes.text +6 -0
- data/test/testcases/block/16_toc/toc_with_links.html +8 -0
- data/test/testcases/block/16_toc/toc_with_links.options +2 -0
- data/test/testcases/block/16_toc/toc_with_links.text +8 -0
- data/test/testcases/cjk-line-break.html +4 -0
- data/test/testcases/cjk-line-break.options +1 -0
- data/test/testcases/cjk-line-break.text +12 -0
- data/test/testcases/encoding.html +46 -0
- data/test/testcases/encoding.text +28 -0
- data/test/testcases/man/example.man +123 -0
- data/test/testcases/man/example.text +85 -0
- data/test/testcases/man/heading-name-dash-description.man +4 -0
- data/test/testcases/man/heading-name-dash-description.text +1 -0
- data/test/testcases/man/heading-name-description.man +4 -0
- data/test/testcases/man/heading-name-description.text +2 -0
- data/test/testcases/man/heading-name-section-description.man +4 -0
- data/test/testcases/man/heading-name-section-description.text +1 -0
- data/test/testcases/man/heading-name-section.man +2 -0
- data/test/testcases/man/heading-name-section.text +1 -0
- data/test/testcases/man/heading-name.man +2 -0
- data/test/testcases/man/heading-name.text +1 -0
- data/test/testcases/man/sections.man +4 -0
- data/test/testcases/man/sections.text +11 -0
- data/test/testcases/man/text-escaping.man +8 -0
- data/test/testcases/man/text-escaping.text +7 -0
- data/test/testcases/span/01_link/empty.html +5 -0
- data/test/testcases/span/01_link/empty.text +5 -0
- data/test/testcases/span/01_link/empty_title.htmlinput +3 -0
- data/test/testcases/span/01_link/empty_title.text +7 -0
- data/test/testcases/span/01_link/image_in_a.html +5 -0
- data/test/testcases/span/01_link/image_in_a.text +5 -0
- data/test/testcases/span/01_link/imagelinks.html +15 -0
- data/test/testcases/span/01_link/imagelinks.text +18 -0
- data/test/testcases/span/01_link/inline.html +46 -0
- data/test/testcases/span/01_link/inline.text +48 -0
- data/test/testcases/span/01_link/latex_escaping.latex +6 -0
- data/test/testcases/span/01_link/latex_escaping.text +5 -0
- data/test/testcases/span/01_link/link_defs.html +9 -0
- data/test/testcases/span/01_link/link_defs.text +27 -0
- data/test/testcases/span/01_link/link_defs_with_ial.html +4 -0
- data/test/testcases/span/01_link/link_defs_with_ial.text +16 -0
- data/test/testcases/span/01_link/links_with_angle_brackets.html +3 -0
- data/test/testcases/span/01_link/links_with_angle_brackets.text +3 -0
- data/test/testcases/span/01_link/reference.html +37 -0
- data/test/testcases/span/01_link/reference.options +3 -0
- data/test/testcases/span/01_link/reference.text +53 -0
- data/test/testcases/span/02_emphasis/empty.html +3 -0
- data/test/testcases/span/02_emphasis/empty.text +3 -0
- data/test/testcases/span/02_emphasis/errors.html +9 -0
- data/test/testcases/span/02_emphasis/errors.text +9 -0
- data/test/testcases/span/02_emphasis/nesting.html +41 -0
- data/test/testcases/span/02_emphasis/nesting.text +36 -0
- data/test/testcases/span/02_emphasis/normal.html +65 -0
- data/test/testcases/span/02_emphasis/normal.options +1 -0
- data/test/testcases/span/02_emphasis/normal.text +63 -0
- data/test/testcases/span/03_codespan/empty.html +5 -0
- data/test/testcases/span/03_codespan/empty.text +5 -0
- data/test/testcases/span/03_codespan/errors.html +1 -0
- data/test/testcases/span/03_codespan/errors.text +1 -0
- data/test/testcases/span/03_codespan/highlighting-minted.latex +2 -0
- data/test/testcases/span/03_codespan/highlighting-minted.options +1 -0
- data/test/testcases/span/03_codespan/highlighting-minted.text +1 -0
- data/test/testcases/span/03_codespan/highlighting.html +1 -0
- data/test/testcases/span/03_codespan/highlighting.text +1 -0
- data/test/testcases/span/03_codespan/normal-css-class.html +1 -0
- data/test/testcases/span/03_codespan/normal-css-class.options +2 -0
- data/test/testcases/span/03_codespan/normal-css-class.text +1 -0
- data/test/testcases/span/03_codespan/normal.html +16 -0
- data/test/testcases/span/03_codespan/normal.text +16 -0
- data/test/testcases/span/03_codespan/rouge/disabled.html +1 -0
- data/test/testcases/span/03_codespan/rouge/disabled.options +4 -0
- data/test/testcases/span/03_codespan/rouge/disabled.text +1 -0
- data/test/testcases/span/03_codespan/rouge/simple.html +1 -0
- data/test/testcases/span/03_codespan/rouge/simple.options +1 -0
- data/test/testcases/span/03_codespan/rouge/simple.text +1 -0
- data/test/testcases/span/04_footnote/backlink_inline.html +79 -0
- data/test/testcases/span/04_footnote/backlink_inline.options +1 -0
- data/test/testcases/span/04_footnote/backlink_inline.text +38 -0
- data/test/testcases/span/04_footnote/backlink_text.html +9 -0
- data/test/testcases/span/04_footnote/backlink_text.options +1 -0
- data/test/testcases/span/04_footnote/backlink_text.text +3 -0
- data/test/testcases/span/04_footnote/definitions.html +17 -0
- data/test/testcases/span/04_footnote/definitions.latex +17 -0
- data/test/testcases/span/04_footnote/definitions.text +24 -0
- data/test/testcases/span/04_footnote/footnote_nr.html +12 -0
- data/test/testcases/span/04_footnote/footnote_nr.latex +2 -0
- data/test/testcases/span/04_footnote/footnote_nr.options +1 -0
- data/test/testcases/span/04_footnote/footnote_nr.text +4 -0
- data/test/testcases/span/04_footnote/footnote_prefix.html +12 -0
- data/test/testcases/span/04_footnote/footnote_prefix.options +1 -0
- data/test/testcases/span/04_footnote/footnote_prefix.text +4 -0
- data/test/testcases/span/04_footnote/inside_footnote.html +17 -0
- data/test/testcases/span/04_footnote/inside_footnote.text +9 -0
- data/test/testcases/span/04_footnote/markers.html +46 -0
- data/test/testcases/span/04_footnote/markers.latex +23 -0
- data/test/testcases/span/04_footnote/markers.options +2 -0
- data/test/testcases/span/04_footnote/markers.text +27 -0
- data/test/testcases/span/04_footnote/placement.html +11 -0
- data/test/testcases/span/04_footnote/placement.options +1 -0
- data/test/testcases/span/04_footnote/placement.text +8 -0
- data/test/testcases/span/04_footnote/regexp_problem.html +14 -0
- data/test/testcases/span/04_footnote/regexp_problem.options +2 -0
- data/test/testcases/span/04_footnote/regexp_problem.text +52 -0
- data/test/testcases/span/04_footnote/without_backlink.html +9 -0
- data/test/testcases/span/04_footnote/without_backlink.options +1 -0
- data/test/testcases/span/04_footnote/without_backlink.text +3 -0
- data/test/testcases/span/05_html/across_lines.html +1 -0
- data/test/testcases/span/05_html/across_lines.text +2 -0
- data/test/testcases/span/05_html/button.html +7 -0
- data/test/testcases/span/05_html/button.text +7 -0
- data/test/testcases/span/05_html/invalid.html +1 -0
- data/test/testcases/span/05_html/invalid.text +1 -0
- data/test/testcases/span/05_html/link_with_mailto.html +1 -0
- data/test/testcases/span/05_html/link_with_mailto.text +1 -0
- data/test/testcases/span/05_html/mark_element.html +3 -0
- data/test/testcases/span/05_html/mark_element.text +3 -0
- data/test/testcases/span/05_html/markdown_attr.html +6 -0
- data/test/testcases/span/05_html/markdown_attr.text +6 -0
- data/test/testcases/span/05_html/normal.html +43 -0
- data/test/testcases/span/05_html/normal.text +43 -0
- data/test/testcases/span/05_html/raw_span_elements.html +2 -0
- data/test/testcases/span/05_html/raw_span_elements.text +2 -0
- data/test/testcases/span/05_html/xml.html +5 -0
- data/test/testcases/span/05_html/xml.text +5 -0
- data/test/testcases/span/abbreviations/abbrev.html +21 -0
- data/test/testcases/span/abbreviations/abbrev.text +34 -0
- data/test/testcases/span/abbreviations/abbrev_defs.html +2 -0
- data/test/testcases/span/abbreviations/abbrev_defs.text +5 -0
- data/test/testcases/span/abbreviations/in_footnote.html +9 -0
- data/test/testcases/span/abbreviations/in_footnote.text +5 -0
- data/test/testcases/span/autolinks/url_links.html +15 -0
- data/test/testcases/span/autolinks/url_links.text +16 -0
- data/test/testcases/span/escaped_chars/normal.html +47 -0
- data/test/testcases/span/escaped_chars/normal.text +47 -0
- data/test/testcases/span/extension/comment.html +6 -0
- data/test/testcases/span/extension/comment.text +6 -0
- data/test/testcases/span/extension/ignored.html +1 -0
- data/test/testcases/span/extension/ignored.text +1 -0
- data/test/testcases/span/extension/nomarkdown.html +1 -0
- data/test/testcases/span/extension/nomarkdown.text +1 -0
- data/test/testcases/span/extension/options.html +1 -0
- data/test/testcases/span/extension/options.text +1 -0
- data/test/testcases/span/ial/simple.html +6 -0
- data/test/testcases/span/ial/simple.text +6 -0
- data/test/testcases/span/line_breaks/normal.html +11 -0
- data/test/testcases/span/line_breaks/normal.latex +12 -0
- data/test/testcases/span/line_breaks/normal.text +11 -0
- data/test/testcases/span/math/no_engine.html +1 -0
- data/test/testcases/span/math/no_engine.options +1 -0
- data/test/testcases/span/math/no_engine.text +1 -0
- data/test/testcases/span/math/normal.html +10 -0
- data/test/testcases/span/math/normal.text +10 -0
- data/test/testcases/span/text_substitutions/entities.html +6 -0
- data/test/testcases/span/text_substitutions/entities.options +1 -0
- data/test/testcases/span/text_substitutions/entities.text +6 -0
- data/test/testcases/span/text_substitutions/entities_as_char.html +1 -0
- data/test/testcases/span/text_substitutions/entities_as_char.options +2 -0
- data/test/testcases/span/text_substitutions/entities_as_char.text +1 -0
- data/test/testcases/span/text_substitutions/entities_as_input.html +1 -0
- data/test/testcases/span/text_substitutions/entities_as_input.options +1 -0
- data/test/testcases/span/text_substitutions/entities_as_input.text +1 -0
- data/test/testcases/span/text_substitutions/entities_numeric.html +1 -0
- data/test/testcases/span/text_substitutions/entities_numeric.options +1 -0
- data/test/testcases/span/text_substitutions/entities_numeric.text +1 -0
- data/test/testcases/span/text_substitutions/entities_symbolic.html +1 -0
- data/test/testcases/span/text_substitutions/entities_symbolic.options +1 -0
- data/test/testcases/span/text_substitutions/entities_symbolic.text +1 -0
- data/test/testcases/span/text_substitutions/greaterthan.html +1 -0
- data/test/testcases/span/text_substitutions/greaterthan.text +1 -0
- data/test/testcases/span/text_substitutions/lowerthan.html +1 -0
- data/test/testcases/span/text_substitutions/lowerthan.text +1 -0
- data/test/testcases/span/text_substitutions/typography.html +40 -0
- data/test/testcases/span/text_substitutions/typography.options +1 -0
- data/test/testcases/span/text_substitutions/typography.text +40 -0
- data/test/testcases/span/text_substitutions/typography_subst.html +3 -0
- data/test/testcases/span/text_substitutions/typography_subst.latex +4 -0
- data/test/testcases/span/text_substitutions/typography_subst.options +8 -0
- data/test/testcases/span/text_substitutions/typography_subst.text +3 -0
- metadata +659 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- coding: utf-8; frozen_string_literal: true -*-
|
2
|
+
#
|
3
|
+
#--
|
4
|
+
# Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
|
5
|
+
#
|
6
|
+
# This file is part of kramdown which is licensed under the MIT.
|
7
|
+
#++
|
8
|
+
#
|
9
|
+
|
10
|
+
module Kramdown
|
11
|
+
module Parser
|
12
|
+
class Kramdown
|
13
|
+
|
14
|
+
ACHARS = '[[:alnum:]]-_.'
|
15
|
+
AUTOLINK_START_STR = "<((mailto|https?|ftps?):.+?|[#{ACHARS}]+?@[#{ACHARS}]+?)>"
|
16
|
+
AUTOLINK_START = /#{AUTOLINK_START_STR}/u
|
17
|
+
|
18
|
+
# Parse the autolink at the current location.
|
19
|
+
def parse_autolink
|
20
|
+
start_line_number = @src.current_line_number
|
21
|
+
@src.pos += @src.matched_size
|
22
|
+
href = (@src[2].nil? ? "mailto:#{@src[1]}" : @src[1])
|
23
|
+
el = Element.new(:auto_a, nil, {'href' => href}, location: start_line_number)
|
24
|
+
add_text(@src[1].sub(/^mailto:/, ''), el)
|
25
|
+
@tree.children << el
|
26
|
+
end
|
27
|
+
define_parser(:autolink, AUTOLINK_START, '<')
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- coding: utf-8; frozen_string_literal: true -*-
|
2
|
+
#
|
3
|
+
#--
|
4
|
+
# Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
|
5
|
+
#
|
6
|
+
# This file is part of kramdown which is licensed under the MIT.
|
7
|
+
#++
|
8
|
+
#
|
9
|
+
|
10
|
+
module Kramdown
|
11
|
+
module Parser
|
12
|
+
class Kramdown
|
13
|
+
|
14
|
+
BLANK_LINE = /(?>^\s*\n)+/
|
15
|
+
|
16
|
+
# Parse the blank line at the current postition.
|
17
|
+
def parse_blank_line
|
18
|
+
@src.pos += @src.matched_size
|
19
|
+
if (last_child = @tree.children.last) && last_child.type == :blank
|
20
|
+
last_child.value << @src.matched
|
21
|
+
else
|
22
|
+
@tree.children << new_block_el(:blank, @src.matched)
|
23
|
+
end
|
24
|
+
true
|
25
|
+
end
|
26
|
+
define_parser(:blank_line, BLANK_LINE)
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# -*- coding: utf-8; frozen_string_literal: true -*-
|
2
|
+
#
|
3
|
+
#--
|
4
|
+
# Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
|
5
|
+
#
|
6
|
+
# This file is part of kramdown which is licensed under the MIT.
|
7
|
+
#++
|
8
|
+
#
|
9
|
+
|
10
|
+
require 'kramdown/parser/kramdown/extensions'
|
11
|
+
require 'kramdown/parser/kramdown/blank_line'
|
12
|
+
require 'kramdown/parser/kramdown/eob'
|
13
|
+
|
14
|
+
module Kramdown
|
15
|
+
module Parser
|
16
|
+
class Kramdown
|
17
|
+
|
18
|
+
BLOCK_BOUNDARY = /#{BLANK_LINE}|#{EOB_MARKER}|#{IAL_BLOCK_START}|\Z/
|
19
|
+
|
20
|
+
# Return +true+ if we are after a block boundary.
|
21
|
+
def after_block_boundary?
|
22
|
+
last_child = @tree.children.last
|
23
|
+
!last_child || last_child.type == :blank ||
|
24
|
+
(last_child.type == :eob && last_child.value.nil?) || @block_ial
|
25
|
+
end
|
26
|
+
|
27
|
+
# Return +true+ if we are before a block boundary.
|
28
|
+
def before_block_boundary?
|
29
|
+
@src.check(self.class::BLOCK_BOUNDARY)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# -*- coding: utf-8; frozen_string_literal: true -*-
|
2
|
+
#
|
3
|
+
#--
|
4
|
+
# Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
|
5
|
+
#
|
6
|
+
# This file is part of kramdown which is licensed under the MIT.
|
7
|
+
#++
|
8
|
+
#
|
9
|
+
|
10
|
+
require 'kramdown/parser/kramdown/blank_line'
|
11
|
+
require 'kramdown/parser/kramdown/extensions'
|
12
|
+
require 'kramdown/parser/kramdown/eob'
|
13
|
+
|
14
|
+
module Kramdown
|
15
|
+
module Parser
|
16
|
+
class Kramdown
|
17
|
+
|
18
|
+
BLOCKQUOTE_START = /^#{OPT_SPACE}> ?/
|
19
|
+
|
20
|
+
# Parse the blockquote at the current location.
|
21
|
+
def parse_blockquote
|
22
|
+
start_line_number = @src.current_line_number
|
23
|
+
result = @src.scan(PARAGRAPH_MATCH)
|
24
|
+
until @src.match?(self.class::LAZY_END)
|
25
|
+
result << @src.scan(PARAGRAPH_MATCH)
|
26
|
+
end
|
27
|
+
result.gsub!(BLOCKQUOTE_START, '')
|
28
|
+
|
29
|
+
el = new_block_el(:blockquote, nil, nil, location: start_line_number)
|
30
|
+
@tree.children << el
|
31
|
+
parse_blocks(el, result)
|
32
|
+
true
|
33
|
+
end
|
34
|
+
define_parser(:blockquote, BLOCKQUOTE_START)
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# -*- coding: utf-8; frozen_string_literal: true -*-
|
2
|
+
#
|
3
|
+
#--
|
4
|
+
# Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
|
5
|
+
#
|
6
|
+
# This file is part of kramdown which is licensed under the MIT.
|
7
|
+
#++
|
8
|
+
#
|
9
|
+
|
10
|
+
require 'kramdown/parser/kramdown/blank_line'
|
11
|
+
require 'kramdown/parser/kramdown/extensions'
|
12
|
+
require 'kramdown/parser/kramdown/eob'
|
13
|
+
require 'kramdown/parser/kramdown/paragraph'
|
14
|
+
|
15
|
+
module Kramdown
|
16
|
+
module Parser
|
17
|
+
class Kramdown
|
18
|
+
|
19
|
+
CODEBLOCK_START = INDENT
|
20
|
+
CODEBLOCK_MATCH = /(?:#{BLANK_LINE}?(?:#{INDENT}[ \t]*\S.*\n)+(?:(?!#{IAL_BLOCK_START}|#{EOB_MARKER}|^#{OPT_SPACE}#{LAZY_END_HTML_STOP}|^#{OPT_SPACE}#{LAZY_END_HTML_START})^[ \t]*\S.*\n)*)*/
|
21
|
+
|
22
|
+
# Parse the indented codeblock at the current location.
|
23
|
+
def parse_codeblock
|
24
|
+
start_line_number = @src.current_line_number
|
25
|
+
data = @src.scan(self.class::CODEBLOCK_MATCH)
|
26
|
+
data.gsub!(/\n( {0,3}\S)/, ' \\1')
|
27
|
+
data.gsub!(INDENT, '')
|
28
|
+
@tree.children << new_block_el(:codeblock, data, nil, location: start_line_number)
|
29
|
+
true
|
30
|
+
end
|
31
|
+
define_parser(:codeblock, CODEBLOCK_START)
|
32
|
+
|
33
|
+
FENCED_CODEBLOCK_START = /^~{3,}/
|
34
|
+
FENCED_CODEBLOCK_MATCH = /^((~){3,})\s*?((\S+?)(?:\?\S*)?)?\s*?\n(.*?)^\1\2*\s*?\n/m
|
35
|
+
|
36
|
+
# Parse the fenced codeblock at the current location.
|
37
|
+
def parse_codeblock_fenced
|
38
|
+
if @src.check(self.class::FENCED_CODEBLOCK_MATCH)
|
39
|
+
start_line_number = @src.current_line_number
|
40
|
+
@src.pos += @src.matched_size
|
41
|
+
el = new_block_el(:codeblock, @src[5], nil, location: start_line_number, fenced: true)
|
42
|
+
lang = @src[3].to_s.strip
|
43
|
+
unless lang.empty?
|
44
|
+
el.options[:lang] = lang
|
45
|
+
el.attr['class'] = "language-#{@src[4]}"
|
46
|
+
end
|
47
|
+
@tree.children << el
|
48
|
+
true
|
49
|
+
else
|
50
|
+
false
|
51
|
+
end
|
52
|
+
end
|
53
|
+
define_parser(:codeblock_fenced, FENCED_CODEBLOCK_START)
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# -*- coding: utf-8; frozen_string_literal: true -*-
|
2
|
+
#
|
3
|
+
#--
|
4
|
+
# Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
|
5
|
+
#
|
6
|
+
# This file is part of kramdown which is licensed under the MIT.
|
7
|
+
#++
|
8
|
+
#
|
9
|
+
|
10
|
+
module Kramdown
|
11
|
+
module Parser
|
12
|
+
class Kramdown
|
13
|
+
|
14
|
+
CODESPAN_DELIMITER = /`+/
|
15
|
+
|
16
|
+
# Parse the codespan at the current scanner location.
|
17
|
+
def parse_codespan
|
18
|
+
start_line_number = @src.current_line_number
|
19
|
+
result = @src.scan(CODESPAN_DELIMITER)
|
20
|
+
simple = (result.length == 1)
|
21
|
+
saved_pos = @src.save_pos
|
22
|
+
|
23
|
+
if simple && @src.pre_match =~ /\s\Z/ && @src.match?(/\s/)
|
24
|
+
add_text(result)
|
25
|
+
return
|
26
|
+
end
|
27
|
+
|
28
|
+
# assign static regex to avoid allocating the same on every instance
|
29
|
+
# where +result+ equals a single-backtick. Interpolate otherwise.
|
30
|
+
if result == '`'
|
31
|
+
scan_pattern = /`/
|
32
|
+
str_sub_pattern = /`\Z/
|
33
|
+
else
|
34
|
+
scan_pattern = /#{result}/
|
35
|
+
str_sub_pattern = /#{result}\Z/
|
36
|
+
end
|
37
|
+
|
38
|
+
if (text = @src.scan_until(scan_pattern))
|
39
|
+
text.sub!(str_sub_pattern, '')
|
40
|
+
unless simple
|
41
|
+
text = text[1..-1] if text[0..0] == ' '
|
42
|
+
text = text[0..-2] if text[-1..-1] == ' '
|
43
|
+
end
|
44
|
+
@tree.children << Element.new(:codespan, text, nil, location: start_line_number)
|
45
|
+
else
|
46
|
+
@src.revert_pos(saved_pos)
|
47
|
+
add_text(result)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
define_parser(:codespan, CODESPAN_DELIMITER, '`')
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# -*- coding: utf-8; frozen_string_literal: true -*-
|
2
|
+
#
|
3
|
+
#--
|
4
|
+
# Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
|
5
|
+
#
|
6
|
+
# This file is part of kramdown which is licensed under the MIT.
|
7
|
+
#++
|
8
|
+
#
|
9
|
+
|
10
|
+
module Kramdown
|
11
|
+
module Parser
|
12
|
+
class Kramdown
|
13
|
+
|
14
|
+
EMPHASIS_START = /(?:\*\*?|__?)/
|
15
|
+
|
16
|
+
# Parse the emphasis at the current location.
|
17
|
+
def parse_emphasis
|
18
|
+
start_line_number = @src.current_line_number
|
19
|
+
saved_pos = @src.save_pos
|
20
|
+
|
21
|
+
result = @src.scan(EMPHASIS_START)
|
22
|
+
element = (result.length == 2 ? :strong : :em)
|
23
|
+
type = result[0..0]
|
24
|
+
|
25
|
+
if (type == '_' && @src.pre_match =~ /[[:alpha:]]-?[[:alpha:]]*\z/) || @src.check(/\s/) ||
|
26
|
+
@tree.type == element || @stack.any? {|el, _| el.type == element }
|
27
|
+
add_text(result)
|
28
|
+
return
|
29
|
+
end
|
30
|
+
|
31
|
+
sub_parse = lambda do |delim, elem|
|
32
|
+
el = Element.new(elem, nil, nil, location: start_line_number)
|
33
|
+
stop_re = /#{Regexp.escape(delim)}/
|
34
|
+
found = parse_spans(el, stop_re) do
|
35
|
+
(@src.pre_match[-1, 1] !~ /\s/) &&
|
36
|
+
(elem != :em || !@src.match?(/#{Regexp.escape(delim * 2)}(?!#{Regexp.escape(delim)})/)) &&
|
37
|
+
(type != '_' || !@src.match?(/#{Regexp.escape(delim)}[[:alnum:]]/)) && !el.children.empty?
|
38
|
+
end
|
39
|
+
[found, el, stop_re]
|
40
|
+
end
|
41
|
+
|
42
|
+
found, el, stop_re = sub_parse.call(result, element)
|
43
|
+
if !found && element == :strong && @tree.type != :em
|
44
|
+
@src.revert_pos(saved_pos)
|
45
|
+
@src.pos += 1
|
46
|
+
found, el, stop_re = sub_parse.call(type, :em)
|
47
|
+
end
|
48
|
+
if found
|
49
|
+
@src.scan(stop_re)
|
50
|
+
@tree.children << el
|
51
|
+
else
|
52
|
+
@src.revert_pos(saved_pos)
|
53
|
+
@src.pos += result.length
|
54
|
+
add_text(result)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
define_parser(:emphasis, EMPHASIS_START, '\*|_')
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- coding: utf-8; frozen_string_literal: true -*-
|
2
|
+
#
|
3
|
+
#--
|
4
|
+
# Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
|
5
|
+
#
|
6
|
+
# This file is part of kramdown which is licensed under the MIT.
|
7
|
+
#++
|
8
|
+
#
|
9
|
+
|
10
|
+
module Kramdown
|
11
|
+
module Parser
|
12
|
+
class Kramdown
|
13
|
+
|
14
|
+
EOB_MARKER = /^\^\s*?\n/
|
15
|
+
|
16
|
+
# Parse the EOB marker at the current location.
|
17
|
+
def parse_eob_marker
|
18
|
+
@src.pos += @src.matched_size
|
19
|
+
@tree.children << new_block_el(:eob)
|
20
|
+
true
|
21
|
+
end
|
22
|
+
define_parser(:eob_marker, EOB_MARKER)
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- coding: utf-8; frozen_string_literal: true -*-
|
2
|
+
#
|
3
|
+
#--
|
4
|
+
# Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
|
5
|
+
#
|
6
|
+
# This file is part of kramdown which is licensed under the MIT.
|
7
|
+
#++
|
8
|
+
#
|
9
|
+
|
10
|
+
module Kramdown
|
11
|
+
module Parser
|
12
|
+
class Kramdown
|
13
|
+
|
14
|
+
ESCAPED_CHARS = /\\([\\.*_+`<>()\[\]{}#!:|"'\$=-])/
|
15
|
+
|
16
|
+
# Parse the backslash-escaped character at the current location.
|
17
|
+
def parse_escaped_chars
|
18
|
+
@src.pos += @src.matched_size
|
19
|
+
add_text(@src[1])
|
20
|
+
end
|
21
|
+
define_parser(:escaped_chars, ESCAPED_CHARS, '\\\\')
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,214 @@
|
|
1
|
+
# -*- coding: utf-8; frozen_string_literal: true -*-
|
2
|
+
#
|
3
|
+
#--
|
4
|
+
# Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
|
5
|
+
#
|
6
|
+
# This file is part of kramdown which is licensed under the MIT.
|
7
|
+
#++
|
8
|
+
#
|
9
|
+
|
10
|
+
module Kramdown
|
11
|
+
module Parser
|
12
|
+
class Kramdown
|
13
|
+
|
14
|
+
IAL_CLASS_ATTR = 'class'
|
15
|
+
|
16
|
+
# Parse the string +str+ and extract all attributes and add all found attributes to the hash
|
17
|
+
# +opts+.
|
18
|
+
def parse_attribute_list(str, opts)
|
19
|
+
return if str.strip.empty? || str.strip == ':'
|
20
|
+
attrs = str.scan(ALD_TYPE_ANY)
|
21
|
+
attrs.each do |key, sep, val, ref, id_and_or_class, _, _|
|
22
|
+
if ref
|
23
|
+
(opts[:refs] ||= []) << ref
|
24
|
+
elsif id_and_or_class
|
25
|
+
id_and_or_class.scan(ALD_TYPE_ID_OR_CLASS).each do |id_attr, class_attr|
|
26
|
+
if class_attr
|
27
|
+
opts[IAL_CLASS_ATTR] = "#{opts[IAL_CLASS_ATTR]} #{class_attr}".lstrip
|
28
|
+
else
|
29
|
+
opts['id'] = id_attr
|
30
|
+
end
|
31
|
+
end
|
32
|
+
else
|
33
|
+
val.gsub!(/\\(\}|#{sep})/, "\\1")
|
34
|
+
opts[key] = val
|
35
|
+
end
|
36
|
+
end
|
37
|
+
warning("No or invalid attributes found in IAL/ALD content: #{str}") if attrs.empty?
|
38
|
+
end
|
39
|
+
|
40
|
+
# Update the +ial+ with the information from the inline attribute list +opts+.
|
41
|
+
def update_ial_with_ial(ial, opts)
|
42
|
+
(ial[:refs] ||= []).concat(opts[:refs]) if opts.key?(:refs)
|
43
|
+
opts.each do |k, v|
|
44
|
+
if k == IAL_CLASS_ATTR
|
45
|
+
ial[k] = "#{ial[k]} #{v}".lstrip
|
46
|
+
elsif k.kind_of?(String)
|
47
|
+
ial[k] = v
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# Parse the generic extension at the current point. The parameter +type+ can either be :block
|
53
|
+
# or :span depending whether we parse a block or span extension tag.
|
54
|
+
def parse_extension_start_tag(type)
|
55
|
+
saved_pos = @src.save_pos
|
56
|
+
start_line_number = @src.current_line_number
|
57
|
+
@src.pos += @src.matched_size
|
58
|
+
|
59
|
+
error_block = lambda do |msg|
|
60
|
+
warning(msg)
|
61
|
+
@src.revert_pos(saved_pos)
|
62
|
+
add_text(@src.getch) if type == :span
|
63
|
+
false
|
64
|
+
end
|
65
|
+
|
66
|
+
if @src[4] || @src.matched == '{:/}'
|
67
|
+
name = (@src[4] ? "for '#{@src[4]}' " : '')
|
68
|
+
return error_block.call("Invalid extension stop tag #{name} found on line " \
|
69
|
+
"#{start_line_number} - ignoring it")
|
70
|
+
end
|
71
|
+
|
72
|
+
ext = @src[1]
|
73
|
+
opts = {}
|
74
|
+
body = nil
|
75
|
+
parse_attribute_list(@src[2] || '', opts)
|
76
|
+
|
77
|
+
unless @src[3]
|
78
|
+
stop_re = (type == :block ? /#{EXT_BLOCK_STOP_STR % ext}/ : /#{EXT_STOP_STR % ext}/)
|
79
|
+
if (result = @src.scan_until(stop_re))
|
80
|
+
body = result.sub!(stop_re, '')
|
81
|
+
body.chomp! if type == :block
|
82
|
+
else
|
83
|
+
return error_block.call("No stop tag for extension '#{ext}' found on line " \
|
84
|
+
"#{start_line_number} - ignoring it")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
if !handle_extension(ext, opts, body, type, start_line_number)
|
89
|
+
error_block.call("Invalid extension with name '#{ext}' specified on line " \
|
90
|
+
"#{start_line_number} - ignoring it")
|
91
|
+
else
|
92
|
+
true
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def handle_extension(name, opts, body, type, line_no = nil)
|
97
|
+
case name
|
98
|
+
when 'comment'
|
99
|
+
if body.kind_of?(String)
|
100
|
+
@tree.children << Element.new(:comment, body, nil, category: type, location: line_no)
|
101
|
+
end
|
102
|
+
true
|
103
|
+
when 'nomarkdown'
|
104
|
+
if body.kind_of?(String)
|
105
|
+
@tree.children << Element.new(:raw, body, nil, category: type,
|
106
|
+
location: line_no, type: opts['type'].to_s.split(/\s+/))
|
107
|
+
end
|
108
|
+
true
|
109
|
+
when 'options'
|
110
|
+
opts.select do |k, v|
|
111
|
+
k = k.to_sym
|
112
|
+
if Kramdown::Options.defined?(k)
|
113
|
+
if @options[:forbidden_inline_options].include?(k) ||
|
114
|
+
k == :forbidden_inline_options
|
115
|
+
warning("Option #{k} may not be set inline")
|
116
|
+
next false
|
117
|
+
end
|
118
|
+
|
119
|
+
begin
|
120
|
+
val = Kramdown::Options.parse(k, v)
|
121
|
+
@options[k] = val
|
122
|
+
(@root.options[:options] ||= {})[k] = val
|
123
|
+
rescue StandardError
|
124
|
+
end
|
125
|
+
false
|
126
|
+
else
|
127
|
+
true
|
128
|
+
end
|
129
|
+
end.each do |k, _v|
|
130
|
+
warning("Unknown kramdown option '#{k}'")
|
131
|
+
end
|
132
|
+
@tree.children << new_block_el(:eob, :extension) if type == :block
|
133
|
+
true
|
134
|
+
else
|
135
|
+
false
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
ALD_ID_CHARS = /[\w-]/
|
140
|
+
ALD_ANY_CHARS = /\\\}|[^\}]/
|
141
|
+
ALD_ID_NAME = /\w#{ALD_ID_CHARS}*/
|
142
|
+
ALD_CLASS_NAME = /[^\s\.#]+/
|
143
|
+
ALD_TYPE_KEY_VALUE_PAIR = /(#{ALD_ID_NAME})=("|')((?:\\\}|\\\2|[^\}\2])*?)\2/
|
144
|
+
ALD_TYPE_CLASS_NAME = /\.(#{ALD_CLASS_NAME})/
|
145
|
+
ALD_TYPE_ID_NAME = /#([A-Za-z][\w:-]*)/
|
146
|
+
ALD_TYPE_ID_OR_CLASS = /#{ALD_TYPE_ID_NAME}|#{ALD_TYPE_CLASS_NAME}/
|
147
|
+
ALD_TYPE_ID_OR_CLASS_MULTI = /((?:#{ALD_TYPE_ID_NAME}|#{ALD_TYPE_CLASS_NAME})+)/
|
148
|
+
ALD_TYPE_REF = /(#{ALD_ID_NAME})/
|
149
|
+
ALD_TYPE_ANY = /(?:\A|\s)(?:#{ALD_TYPE_KEY_VALUE_PAIR}|#{ALD_TYPE_REF}|#{ALD_TYPE_ID_OR_CLASS_MULTI})(?=\s|\Z)/
|
150
|
+
ALD_START = /^#{OPT_SPACE}\{:(#{ALD_ID_NAME}):(#{ALD_ANY_CHARS}+)\}\s*?\n/
|
151
|
+
|
152
|
+
EXT_STOP_STR = "\\{:/(%s)?\\}"
|
153
|
+
EXT_START_STR = "\\{::(\\w+)(?:\\s(#{ALD_ANY_CHARS}*?)|)(\\/)?\\}"
|
154
|
+
EXT_BLOCK_START = /^#{OPT_SPACE}(?:#{EXT_START_STR}|#{EXT_STOP_STR % ALD_ID_NAME})\s*?\n/
|
155
|
+
EXT_BLOCK_STOP_STR = "^#{OPT_SPACE}#{EXT_STOP_STR}\s*?\n"
|
156
|
+
|
157
|
+
IAL_BLOCK = /\{:(?!:|\/)(#{ALD_ANY_CHARS}+)\}\s*?\n/
|
158
|
+
IAL_BLOCK_START = /^#{OPT_SPACE}#{IAL_BLOCK}/
|
159
|
+
|
160
|
+
BLOCK_EXTENSIONS_START = /^#{OPT_SPACE}\{:/
|
161
|
+
|
162
|
+
# Parse one of the block extensions (ALD, block IAL or generic extension) at the current
|
163
|
+
# location.
|
164
|
+
def parse_block_extensions
|
165
|
+
if @src.scan(ALD_START)
|
166
|
+
parse_attribute_list(@src[2], @alds[@src[1]] ||= {})
|
167
|
+
@tree.children << new_block_el(:eob, :ald)
|
168
|
+
true
|
169
|
+
elsif @src.check(EXT_BLOCK_START)
|
170
|
+
parse_extension_start_tag(:block)
|
171
|
+
elsif @src.scan(IAL_BLOCK_START)
|
172
|
+
if (last_child = @tree.children.last) && last_child.type != :blank &&
|
173
|
+
(last_child.type != :eob ||
|
174
|
+
[:link_def, :abbrev_def, :footnote_def].include?(last_child.value))
|
175
|
+
parse_attribute_list(@src[1], last_child.options[:ial] ||= {})
|
176
|
+
@tree.children << new_block_el(:eob, :ial) unless @src.check(IAL_BLOCK_START)
|
177
|
+
else
|
178
|
+
parse_attribute_list(@src[1], @block_ial ||= {})
|
179
|
+
end
|
180
|
+
true
|
181
|
+
else
|
182
|
+
false
|
183
|
+
end
|
184
|
+
end
|
185
|
+
define_parser(:block_extensions, BLOCK_EXTENSIONS_START)
|
186
|
+
|
187
|
+
EXT_SPAN_START = /#{EXT_START_STR}|#{EXT_STOP_STR % ALD_ID_NAME}/
|
188
|
+
IAL_SPAN_START = /\{:(#{ALD_ANY_CHARS}+)\}/
|
189
|
+
SPAN_EXTENSIONS_START = /\{:/
|
190
|
+
|
191
|
+
# Parse the extension span at the current location.
|
192
|
+
def parse_span_extensions
|
193
|
+
if @src.check(EXT_SPAN_START)
|
194
|
+
parse_extension_start_tag(:span)
|
195
|
+
elsif @src.check(IAL_SPAN_START)
|
196
|
+
if (last_child = @tree.children.last) && last_child.type != :text
|
197
|
+
@src.pos += @src.matched_size
|
198
|
+
attr = {}
|
199
|
+
parse_attribute_list(@src[1], attr)
|
200
|
+
update_ial_with_ial(last_child.options[:ial] ||= {}, attr)
|
201
|
+
update_attr_with_ial(last_child.attr, attr)
|
202
|
+
else
|
203
|
+
warning("Found span IAL after text - ignoring it")
|
204
|
+
add_text(@src.getch)
|
205
|
+
end
|
206
|
+
else
|
207
|
+
add_text(@src.getch)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
define_parser(:span_extensions, SPAN_EXTENSIONS_START, '\{:')
|
211
|
+
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|