commonmarker 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of commonmarker might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +22 -0
- data/README.md +119 -0
- data/Rakefile +39 -0
- data/bin/commonmarker +41 -0
- data/commonmarker.gemspec +30 -0
- data/ext/commonmarker/cmark/CMakeLists.txt +25 -0
- data/ext/commonmarker/cmark/COPYING +192 -0
- data/ext/commonmarker/cmark/FindAsan.cmake +74 -0
- data/ext/commonmarker/cmark/Makefile +170 -0
- data/ext/commonmarker/cmark/Makefile.nmake +36 -0
- data/ext/commonmarker/cmark/README.md +169 -0
- data/ext/commonmarker/cmark/api_test/CMakeLists.txt +25 -0
- data/ext/commonmarker/cmark/api_test/cplusplus.cpp +15 -0
- data/ext/commonmarker/cmark/api_test/cplusplus.h +17 -0
- data/ext/commonmarker/cmark/api_test/harness.c +102 -0
- data/ext/commonmarker/cmark/api_test/harness.h +42 -0
- data/ext/commonmarker/cmark/api_test/main.c +700 -0
- data/ext/commonmarker/cmark/appveyor.yml +15 -0
- data/ext/commonmarker/cmark/bench/statistics.py +595 -0
- data/ext/commonmarker/cmark/bench/stats.py +19 -0
- data/ext/commonmarker/cmark/benchmarks.md +33 -0
- data/ext/commonmarker/cmark/build/CMakeCache.txt +362 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/3.2.2/CMakeCCompiler.cmake +63 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/3.2.2/CMakeCXXCompiler.cmake +64 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/3.2.2/CMakeDetermineCompilerABI_C.bin +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/3.2.2/CMakeDetermineCompilerABI_CXX.bin +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/3.2.2/CMakeSystem.cmake +15 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/3.2.2/CompilerIdC/CMakeCCompilerId.c +499 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/3.2.2/CompilerIdC/a.out +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/3.2.2/CompilerIdCXX/CMakeCXXCompilerId.cpp +489 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/3.2.2/CompilerIdCXX/a.out +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/CMakeDirectoryInformation.cmake +16 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/CMakeError.log +30 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/CMakeOutput.log +598 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/Makefile.cmake +77 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/Makefile2 +268 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/TargetDirectories.txt +4 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/cmake.check_cache +1 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/feature_tests.bin +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/feature_tests.c +34 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/feature_tests.cxx +405 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/progress.marks +1 -0
- data/ext/commonmarker/cmark/build/CTestTestfile.cmake +10 -0
- data/ext/commonmarker/cmark/build/Makefile +237 -0
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/CMakeDirectoryInformation.cmake +16 -0
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/C.includecache +92 -0
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/CXX.includecache +36 -0
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/DependInfo.cmake +29 -0
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/build.make +155 -0
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/cmake_clean.cmake +12 -0
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/cplusplus.cpp.o +0 -0
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/depend.internal +25 -0
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/depend.make +25 -0
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/flags.make +13 -0
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/harness.c.o +0 -0
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/link.txt +1 -0
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/main.c.o +0 -0
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/progress.make +4 -0
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/progress.marks +1 -0
- data/ext/commonmarker/cmark/build/api_test/Makefile +277 -0
- data/ext/commonmarker/cmark/build/api_test/api_test +0 -0
- data/ext/commonmarker/cmark/build/api_test/cmake_install.cmake +29 -0
- data/ext/commonmarker/cmark/build/cmake_install.cmake +48 -0
- data/ext/commonmarker/cmark/build/man/CMakeFiles/CMakeDirectoryInformation.cmake +16 -0
- data/ext/commonmarker/cmark/build/man/CMakeFiles/progress.marks +1 -0
- data/ext/commonmarker/cmark/build/man/Makefile +181 -0
- data/ext/commonmarker/cmark/build/man/cmake_install.cmake +37 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/CMakeDirectoryInformation.cmake +16 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/C.includecache +422 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/DependInfo.cmake +39 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/blocks.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/buffer.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/build.make +544 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/cmake_clean.cmake +27 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/cmark.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/cmark_ctype.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/commonmark.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/depend.internal +177 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/depend.make +177 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/flags.make +8 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/houdini_href_e.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/houdini_html_e.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/houdini_html_u.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/html.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/inlines.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/iterator.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/link.txt +1 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/main.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/man.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/node.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/progress.make +19 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/references.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/scanners.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/utf8.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/xml.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/C.includecache +394 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/DependInfo.cmake +44 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/blocks.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/buffer.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/build.make +522 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/cmake_clean.cmake +27 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/cmark.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/cmark_ctype.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/commonmark.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/depend.internal +169 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/depend.make +169 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/flags.make +8 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/houdini_href_e.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/houdini_html_e.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/houdini_html_u.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/html.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/inlines.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/iterator.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/link.txt +1 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/man.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/node.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/progress.make +18 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/references.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/scanners.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/utf8.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/xml.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/C.includecache +394 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/DependInfo.cmake +38 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/blocks.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/buffer.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/build.make +519 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/cmake_clean.cmake +26 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/cmake_clean_target.cmake +3 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/cmark.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/cmark_ctype.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/commonmark.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/depend.internal +169 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/depend.make +169 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/flags.make +8 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/houdini_href_e.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/houdini_html_e.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/houdini_html_u.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/html.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/inlines.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/iterator.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/link.txt +2 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/man.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/node.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/progress.make +18 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/references.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/scanners.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/utf8.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/xml.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/progress.marks +1 -0
- data/ext/commonmarker/cmark/build/src/Makefile +814 -0
- data/ext/commonmarker/cmark/build/src/cmake_install.cmake +69 -0
- data/ext/commonmarker/cmark/build/src/cmark +0 -0
- data/ext/commonmarker/cmark/build/src/cmark_export.h +41 -0
- data/ext/commonmarker/cmark/build/src/cmark_version.h +7 -0
- data/ext/commonmarker/cmark/build/src/config.h +23 -0
- data/ext/commonmarker/cmark/build/src/libcmark.0.19.0.dylib +0 -0
- data/ext/commonmarker/cmark/build/src/libcmark.a +0 -0
- data/ext/commonmarker/cmark/build/src/libcmark.dylib +0 -0
- data/ext/commonmarker/cmark/build/src/libcmark.pc +10 -0
- data/ext/commonmarker/cmark/build/testdir/CMakeFiles/CMakeDirectoryInformation.cmake +16 -0
- data/ext/commonmarker/cmark/build/testdir/CMakeFiles/progress.marks +1 -0
- data/ext/commonmarker/cmark/build/testdir/CTestTestfile.cmake +12 -0
- data/ext/commonmarker/cmark/build/testdir/Makefile +181 -0
- data/ext/commonmarker/cmark/build/testdir/cmake_install.cmake +29 -0
- data/ext/commonmarker/cmark/changelog.txt +153 -0
- data/ext/commonmarker/cmark/data/CaseFolding-3.2.0.txt +912 -0
- data/ext/commonmarker/cmark/man/CMakeLists.txt +8 -0
- data/ext/commonmarker/cmark/man/make_man_page.py +131 -0
- data/ext/commonmarker/cmark/man/man1/cmark.1 +54 -0
- data/ext/commonmarker/cmark/man/man3/cmark.3 +583 -0
- data/ext/commonmarker/cmark/nmake.bat +1 -0
- data/ext/commonmarker/cmark/src/CMakeLists.txt +166 -0
- data/ext/commonmarker/cmark/src/bench.h +27 -0
- data/ext/commonmarker/cmark/src/blocks.c +887 -0
- data/ext/commonmarker/cmark/src/buffer.c +381 -0
- data/ext/commonmarker/cmark/src/buffer.h +113 -0
- data/ext/commonmarker/cmark/src/case_fold_switch.inc +2637 -0
- data/ext/commonmarker/cmark/src/chunk.h +110 -0
- data/ext/commonmarker/cmark/src/cmark.c +24 -0
- data/ext/commonmarker/cmark/src/cmark.h +565 -0
- data/ext/commonmarker/cmark/src/cmark_ctype.c +53 -0
- data/ext/commonmarker/cmark/src/cmark_ctype.h +24 -0
- data/ext/commonmarker/cmark/src/cmark_version.h.in +7 -0
- data/ext/commonmarker/cmark/src/commonmark.c +607 -0
- data/ext/commonmarker/cmark/src/config.h.in +23 -0
- data/ext/commonmarker/cmark/src/debug.h +36 -0
- data/ext/commonmarker/cmark/src/houdini.h +52 -0
- data/ext/commonmarker/cmark/src/houdini_href_e.c +107 -0
- data/ext/commonmarker/cmark/src/houdini_html_e.c +81 -0
- data/ext/commonmarker/cmark/src/houdini_html_u.c +116 -0
- data/ext/commonmarker/cmark/src/html.c +322 -0
- data/ext/commonmarker/cmark/src/html_unescape.gperf +2130 -0
- data/ext/commonmarker/cmark/src/html_unescape.h +13375 -0
- data/ext/commonmarker/cmark/src/inlines.c +1147 -0
- data/ext/commonmarker/cmark/src/inlines.h +19 -0
- data/ext/commonmarker/cmark/src/iterator.c +148 -0
- data/ext/commonmarker/cmark/src/iterator.h +25 -0
- data/ext/commonmarker/cmark/src/libcmark.pc.in +10 -0
- data/ext/commonmarker/cmark/src/main.c +191 -0
- data/ext/commonmarker/cmark/src/man.c +287 -0
- data/ext/commonmarker/cmark/src/node.c +873 -0
- data/ext/commonmarker/cmark/src/node.h +82 -0
- data/ext/commonmarker/cmark/src/parser.h +29 -0
- data/ext/commonmarker/cmark/src/references.c +154 -0
- data/ext/commonmarker/cmark/src/references.h +37 -0
- data/ext/commonmarker/cmark/src/scanners.c +15291 -0
- data/ext/commonmarker/cmark/src/scanners.h +41 -0
- data/ext/commonmarker/cmark/src/scanners.re +247 -0
- data/ext/commonmarker/cmark/src/utf8.c +452 -0
- data/ext/commonmarker/cmark/src/utf8.h +22 -0
- data/ext/commonmarker/cmark/src/xml.c +170 -0
- data/ext/commonmarker/cmark/test/CMakeLists.txt +53 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/asterisk +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/attr_generic +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/attr_href +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/attr_xml_lang +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/attr_xmlns +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/backslash +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/backtick +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/colon +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/dashes +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/double_quote +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/entity_builtin +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/entity_decimal +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/entity_external +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/entity_hex +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/equals +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/exclamation +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/greater_than +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/hash +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/hyphen +0 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/indent +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/left_bracket +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/left_paren +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/less_than +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/plus +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/right_bracket +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/right_paren +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/single_quote +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/string_any +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/string_brackets +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/string_cdata +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/string_dashes +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/string_empty_dblquotes +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/string_empty_quotes +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/string_idrefs +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/string_parentheses +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/string_pcdata +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/tag_cdata +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/tag_close +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/tag_doctype +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/tag_element +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/tag_entity +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/tag_notation +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/tag_open +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/tag_open_close +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/tag_open_exclamation +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/tag_open_q +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/tag_sq2_close +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/tag_xml_q +1 -0
- data/ext/commonmarker/cmark/test/afl_dictionary/underscore +1 -0
- data/ext/commonmarker/cmark/test/afl_test_cases/test.md +36 -0
- data/ext/commonmarker/cmark/test/cmark.py +40 -0
- data/ext/commonmarker/cmark/test/normalize.py +179 -0
- data/ext/commonmarker/cmark/test/pathological_tests.py +63 -0
- data/ext/commonmarker/cmark/test/roundtrip.sh +2 -0
- data/ext/commonmarker/cmark/test/smart_punct.txt +96 -0
- data/ext/commonmarker/cmark/test/spec.txt +7505 -0
- data/ext/commonmarker/cmark/test/spec_tests.py +139 -0
- data/ext/commonmarker/cmark/toolchain-mingw32.cmake +17 -0
- data/ext/commonmarker/cmark/tools/mkcasefold.pl +22 -0
- data/ext/commonmarker/cmark/wrappers/wrapper.lua +239 -0
- data/ext/commonmarker/cmark/wrappers/wrapper.py +37 -0
- data/ext/commonmarker/cmark/wrappers/wrapper.rb +15 -0
- data/ext/commonmarker/cmark/wrappers/wrapper.rkt +190 -0
- data/ext/commonmarker/commonmarker.c +165 -0
- data/ext/commonmarker/commonmarker.h +11 -0
- data/ext/commonmarker/extconf.rb +18 -0
- data/lib/commonmarker/config.rb +20 -0
- data/lib/commonmarker/version.rb +3 -0
- data/lib/commonmarker.rb +588 -0
- data/test/benchmark.rb +30 -0
- data/test/spec_tests.json +4074 -0
- data/test/test_basics.rb +44 -0
- data/test/test_helper.rb +5 -0
- data/test/test_maliciousness.rb +9 -0
- data/test/test_pathological_inputs.rb +52 -0
- data/test/test_spec.rb +20 -0
- metadata +399 -0
data/lib/commonmarker.rb
ADDED
@@ -0,0 +1,588 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'commonmarker/commonmarker'
|
3
|
+
require 'commonmarker/config'
|
4
|
+
require 'stringio'
|
5
|
+
require 'cgi'
|
6
|
+
require 'set'
|
7
|
+
require 'uri'
|
8
|
+
|
9
|
+
NODE_TYPES = [:none, :document, :blockquote, :list, :list_item,
|
10
|
+
:code_block, :html, :paragraph,
|
11
|
+
:header, :hrule, :text, :softbreak,
|
12
|
+
:linebreak, :code, :inline_html,
|
13
|
+
:emph, :strong, :link, :image]
|
14
|
+
LIST_TYPES = [:no_list, :bullet_list, :ordered_list]
|
15
|
+
|
16
|
+
# module CMark
|
17
|
+
|
18
|
+
# attach_function :cmark_node_new, [:node_type], :node
|
19
|
+
# attach_function :cmark_node_free, [:node], :void
|
20
|
+
# attach_function :cmark_node_unlink, [:node], :void
|
21
|
+
# attach_function :cmark_node_insert_before, [:node, :node], :int
|
22
|
+
# attach_function :cmark_node_insert_after, [:node, :node], :int
|
23
|
+
# attach_function :cmark_node_prepend_child, [:node, :node], :int
|
24
|
+
# attach_function :cmark_node_append_child, [:node, :node], :int
|
25
|
+
# attach_function :cmark_markdown_to_html, [:string, :int], :string
|
26
|
+
# attach_function :cmark_render_html, [:node], :string
|
27
|
+
# attach_function :cmark_parse_document, [:string, :int], :node
|
28
|
+
# attach_function :cmark_node_first_child, [:node], :node
|
29
|
+
# attach_function :cmark_node_last_child, [:node], :node
|
30
|
+
# attach_function :cmark_node_parent, [:node], :node
|
31
|
+
# attach_function :cmark_node_next, [:node], :node
|
32
|
+
# attach_function :cmark_node_previous, [:node], :node
|
33
|
+
# attach_function :cmark_node_get_type, [:node], :node_type
|
34
|
+
# attach_function :cmark_node_get_literal, [:node], :string
|
35
|
+
# attach_function :cmark_node_set_literal, [:node, :string], :int
|
36
|
+
# attach_function :cmark_node_get_url, [:node], :string
|
37
|
+
# attach_function :cmark_node_set_url, [:node, :string], :int
|
38
|
+
# attach_function :cmark_node_get_title, [:node], :string
|
39
|
+
# attach_function :cmark_node_set_title, [:node, :string], :int
|
40
|
+
# attach_function :cmark_node_get_header_level, [:node], :int
|
41
|
+
# attach_function :cmark_node_set_header_level, [:node, :int], :int
|
42
|
+
# attach_function :cmark_node_get_list_type, [:node], :list_type
|
43
|
+
# attach_function :cmark_node_set_list_type, [:node, :list_type], :int
|
44
|
+
# attach_function :cmark_node_get_list_start, [:node], :int
|
45
|
+
# attach_function :cmark_node_set_list_start, [:node, :int], :int
|
46
|
+
# attach_function :cmark_node_get_list_tight, [:node], :bool
|
47
|
+
# attach_function :cmark_node_set_list_tight, [:node, :bool], :int
|
48
|
+
# attach_function :cmark_node_get_fence_info, [:node], :string
|
49
|
+
# attach_function :cmark_node_set_fence_info, [:node, :string], :int
|
50
|
+
# end
|
51
|
+
|
52
|
+
module CommonMarker
|
53
|
+
class NodeError < StandardError
|
54
|
+
end
|
55
|
+
|
56
|
+
class Node
|
57
|
+
attr_reader :pointer
|
58
|
+
|
59
|
+
# Creates a Node. Either +type+ or +pointer+ should be provided; the
|
60
|
+
# other should be nil. If +type+ is provided, a new node with that
|
61
|
+
# type is created. If +pointer+ is provided, a node is created from the
|
62
|
+
# C node at +pointer+.
|
63
|
+
# Params:
|
64
|
+
# +type+:: +node_type+ of the node to be created (nil if +pointer+ is used).
|
65
|
+
# +pointer+:: pointer to C node (nil if +type+ is used).
|
66
|
+
def initialize(type=nil, pointer=nil)
|
67
|
+
if pointer
|
68
|
+
@pointer = pointer
|
69
|
+
else
|
70
|
+
unless NODE_TYPES.include?(type)
|
71
|
+
raise NodeError, "node type does not exist #{type}"
|
72
|
+
end
|
73
|
+
@pointer = CMark.node_new(type)
|
74
|
+
end
|
75
|
+
if @pointer.nil?
|
76
|
+
raise NodeError, "could not create node of type #{type}"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# Parses a string into a :document Node. The
|
81
|
+
# +free+ method should be called to release the node's
|
82
|
+
# memory when it is no longer needed.
|
83
|
+
# Params:
|
84
|
+
# +s+:: +String+ to be parsed.
|
85
|
+
def self.parse_string(s, option = :default)
|
86
|
+
Config.option_exists?(option)
|
87
|
+
Node.new(nil, CMark.parse_document(s, s.bytesize, Config.to_h[option]))
|
88
|
+
end
|
89
|
+
|
90
|
+
# Parses a file into a :document Node. The
|
91
|
+
# +free+ method should be called to release the node's
|
92
|
+
# memory when it is no longer needed.
|
93
|
+
|
94
|
+
# Params:
|
95
|
+
# +f+:: +File+ to be parsed (caller must open and close).
|
96
|
+
def self.parse_file(f)
|
97
|
+
s = f.read()
|
98
|
+
self.parse_string(s)
|
99
|
+
end
|
100
|
+
|
101
|
+
def first_child
|
102
|
+
Node.new(nil, CMark.node_first_child(@pointer))
|
103
|
+
end
|
104
|
+
|
105
|
+
def last_child
|
106
|
+
Node.new(nil, CMark.node_last_child(@pointer))
|
107
|
+
end
|
108
|
+
|
109
|
+
# Iterator over the children (if any) of this Node.
|
110
|
+
def each_child
|
111
|
+
childptr = CMark.node_first_child(@pointer)
|
112
|
+
until CMark.node_get_type_string(childptr) == "NONE" do
|
113
|
+
nextptr = CMark.node_next(childptr)
|
114
|
+
yield Node.new(nil, childptr)
|
115
|
+
childptr = nextptr
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
# Deletes the node and unlinks it (fixing pointers in
|
120
|
+
# parents and siblings appropriately). Note: this method
|
121
|
+
# does not free the node.
|
122
|
+
def delete
|
123
|
+
CMark.node_unlink(@pointer)
|
124
|
+
end
|
125
|
+
|
126
|
+
# Insert a node before this Node.
|
127
|
+
# Params:
|
128
|
+
# +sibling+:: Sibling node to insert.
|
129
|
+
def insert_before(sibling)
|
130
|
+
res = CMark.node_insert_before(@pointer, sibling.pointer)
|
131
|
+
if res == 0 then raise NodeError, "could not insert before" end
|
132
|
+
end
|
133
|
+
|
134
|
+
# Insert a node after this Node.
|
135
|
+
# Params:
|
136
|
+
# +sibling+:: Sibling Node to insert.
|
137
|
+
def insert_after(sibling)
|
138
|
+
CMark.node_insert_before(@pointer, sibling.pointer)
|
139
|
+
if res == 0 then raise NodeError, "could not insert after" end
|
140
|
+
end
|
141
|
+
|
142
|
+
# Prepend a child to this Node.
|
143
|
+
# Params:
|
144
|
+
# +child+:: Child Node to prepend.
|
145
|
+
def prepend_child(child)
|
146
|
+
CMark.node_prepend_child(@pointer, child.pointer)
|
147
|
+
if res == 0 then raise NodeError, "could not prepend child" end
|
148
|
+
end
|
149
|
+
|
150
|
+
# Append a child to this Node.
|
151
|
+
# Params:
|
152
|
+
# +child+:: Child Node to append.
|
153
|
+
def prepend_child(child)
|
154
|
+
CMark.node_append_child(@pointer, child.pointer)
|
155
|
+
if res == 0 then raise NodeError, "could not append child" end
|
156
|
+
end
|
157
|
+
|
158
|
+
# Returns string content of this Node.
|
159
|
+
def string_content
|
160
|
+
CMark.node_get_string_content(@pointer)
|
161
|
+
end
|
162
|
+
|
163
|
+
# Sets string content of this Node.
|
164
|
+
# Params:
|
165
|
+
# +s+:: +String+ containing new content.
|
166
|
+
def string_content=(s)
|
167
|
+
res = CMark.node_set_string_content(@pointer, s)
|
168
|
+
if res == 0 then raise NodeError, "could not set string content" end
|
169
|
+
end
|
170
|
+
|
171
|
+
# Returns header level of this Node (must be a :header).
|
172
|
+
def header_level
|
173
|
+
if self.type != :header
|
174
|
+
raise NodeError, "can't get header_level for non-header"
|
175
|
+
end
|
176
|
+
CMark.node_get_header_level(@pointer)
|
177
|
+
end
|
178
|
+
|
179
|
+
# Sets header level of this Node (must be a :header).
|
180
|
+
# Params:
|
181
|
+
# +level+:: New header level (+Integer+).
|
182
|
+
def header_level=(level)
|
183
|
+
if self.type != :header
|
184
|
+
raise NodeError, "can't set header_level for non-header"
|
185
|
+
end
|
186
|
+
if !level.kind_of?(Integer) || level < 0 || level > 6
|
187
|
+
raise NodeError, "level must be between 1-6"
|
188
|
+
end
|
189
|
+
res = CMark.node_set_header_level(@pointer, level)
|
190
|
+
if res == 0 then raise NodeError, "could not set header level" end
|
191
|
+
end
|
192
|
+
|
193
|
+
# Returns list type of this Node (must be a :list).
|
194
|
+
def list_type
|
195
|
+
if self.type != :list
|
196
|
+
raise NodeError, "can't get list_type for non-list"
|
197
|
+
end
|
198
|
+
CMark.node_get_list_type(@pointer)
|
199
|
+
end
|
200
|
+
|
201
|
+
# Sets list type of this Node (must be a :list).
|
202
|
+
# Params:
|
203
|
+
# +list_type+:: New list type (+:list_type+), either
|
204
|
+
# :ordered_list or :bullet_list.
|
205
|
+
def list_type=(list_type)
|
206
|
+
if self.type != :list
|
207
|
+
raise NodeError, "can't set list_type for non-list"
|
208
|
+
end
|
209
|
+
res = CMark.node_set_list_type(@pointer, list_type)
|
210
|
+
if res == 0 then raise NodeError, "could not set list_type" end
|
211
|
+
end
|
212
|
+
|
213
|
+
# Returns start number of this Node (must be a :list of
|
214
|
+
# list_type :ordered_list).
|
215
|
+
def list_start
|
216
|
+
if self.type != :list || self.list_type != :ordered_list
|
217
|
+
raise NodeError, "can't get list_start for non-ordered list"
|
218
|
+
end
|
219
|
+
CMark.node_get_list_start(@pointer)
|
220
|
+
end
|
221
|
+
|
222
|
+
# Sets start number of this Node (must be a :list of
|
223
|
+
# list_type :ordered_list).
|
224
|
+
# Params:
|
225
|
+
# +start+:: New start number (+Integer+).
|
226
|
+
def list_start=(start)
|
227
|
+
if self.type != :list || self.list_type != :ordered_list
|
228
|
+
raise NodeError, "can't set list_start for non-ordered list"
|
229
|
+
end
|
230
|
+
if !start.kind_of?(Integer)
|
231
|
+
raise NodeError, "start must be Integer"
|
232
|
+
end
|
233
|
+
res = CMark.node_set_list_start(@pointer, start)
|
234
|
+
if res == 0 then raise NodeError, "could not set list_start" end
|
235
|
+
end
|
236
|
+
|
237
|
+
# Returns tight status of this Node (must be a :list).
|
238
|
+
def list_tight
|
239
|
+
if self.type != :list
|
240
|
+
raise NodeError, "can't get list_tight for non-list"
|
241
|
+
end
|
242
|
+
CMark.node_get_list_tight(@pointer)
|
243
|
+
end
|
244
|
+
|
245
|
+
# Sets tight status of this Node (must be a :list).
|
246
|
+
# Params:
|
247
|
+
# +tight+:: New tight status (boolean).
|
248
|
+
def list_tight=(tight)
|
249
|
+
if self.type != :list
|
250
|
+
raise NodeError, "can't set list_tight for non-list"
|
251
|
+
end
|
252
|
+
res = CMark.node_set_list_tight(@pointer, tight)
|
253
|
+
if res == 0 then raise NodeError, "could not set list_tight" end
|
254
|
+
end
|
255
|
+
|
256
|
+
# Returns URL of this Node (must be a :link or :image).
|
257
|
+
def url
|
258
|
+
if not (self.type == :link || self.type == :image)
|
259
|
+
raise NodeError, "can't get URL for non-link or image"
|
260
|
+
end
|
261
|
+
CMark.node_get_url(@pointer)
|
262
|
+
end
|
263
|
+
|
264
|
+
# Sets URL of this Node (must be a :link or :image).
|
265
|
+
# Params:
|
266
|
+
# +URL+:: New URL (+String+).
|
267
|
+
def url=(url)
|
268
|
+
if not (self.type == :link || self.type == :image)
|
269
|
+
raise NodeError, "can't set URL for non-link or image"
|
270
|
+
end
|
271
|
+
if !url.kind_of?(String)
|
272
|
+
raise NodeError, "url must be a String"
|
273
|
+
end
|
274
|
+
# Make our own copy so ruby won't garbage-collect it:
|
275
|
+
c_url = FFI::MemoryPointer.from_string(url)
|
276
|
+
res = CMark.node_set_url(@pointer, c_url)
|
277
|
+
if res == 0 then raise NodeError, "could not set header level" end
|
278
|
+
end
|
279
|
+
|
280
|
+
# Returns title of this Node (must be a :link or :image).
|
281
|
+
def title
|
282
|
+
if not (self.type == :link || self.type == :image)
|
283
|
+
raise NodeError, "can't get title for non-link or image"
|
284
|
+
end
|
285
|
+
CMark.node_get_title(@pointer)
|
286
|
+
end
|
287
|
+
|
288
|
+
# Sets title of this Node (must be a :link or :image).
|
289
|
+
# Params:
|
290
|
+
# +title+:: New title (+String+).
|
291
|
+
def title=(title)
|
292
|
+
if not (self.type == :link || self.type == :image)
|
293
|
+
raise NodeError, "can't set title for non-link or image"
|
294
|
+
end
|
295
|
+
if !title.kind_of?(String)
|
296
|
+
raise NodeError, "title must be a String"
|
297
|
+
end
|
298
|
+
# Make our own copy so ruby won't garbage-collect it:
|
299
|
+
c_title = FFI::MemoryPointer.from_string(title)
|
300
|
+
res = CMark.node_set_title(@pointer, c_title)
|
301
|
+
if res == 0 then raise NodeError, "could not set header level" end
|
302
|
+
end
|
303
|
+
|
304
|
+
# Returns fence info of this Node (must be a :code_block).
|
305
|
+
def fence_info
|
306
|
+
if not (self.type == :code_block)
|
307
|
+
raise NodeError, "can't get fence_info for non code_block"
|
308
|
+
end
|
309
|
+
CMark.node_get_fence_info(@pointer)
|
310
|
+
end
|
311
|
+
|
312
|
+
# Sets fence_info of this Node (must be a :code_block).
|
313
|
+
# Params:
|
314
|
+
# +info+:: New info (+String+).
|
315
|
+
def fence_info=(info)
|
316
|
+
if self.type != :code_block
|
317
|
+
raise NodeError, "can't set fence_info for non code_block"
|
318
|
+
end
|
319
|
+
if !info.kind_of?(String)
|
320
|
+
raise NodeError, "info must be a String"
|
321
|
+
end
|
322
|
+
# Make our own copy so ruby won't garbage-collect it:
|
323
|
+
c_info = FFI::MemoryPointer.from_string(info)
|
324
|
+
res = CMark.node_set_fence_info(@pointer, c_info)
|
325
|
+
if res == 0 then raise NodeError, "could not set info" end
|
326
|
+
end
|
327
|
+
|
328
|
+
# An iterator that "walks the tree," descending into children
|
329
|
+
# recursively.
|
330
|
+
def walk(&blk)
|
331
|
+
yield self
|
332
|
+
self.each_child do |child|
|
333
|
+
child.walk(&blk)
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
# Returns the type of this Node.
|
338
|
+
def type
|
339
|
+
NODE_TYPES[CMark.node_get_type(@pointer)]
|
340
|
+
end
|
341
|
+
|
342
|
+
def type_string
|
343
|
+
CMark.node_get_type_string(@pointer)
|
344
|
+
end
|
345
|
+
|
346
|
+
|
347
|
+
# Convert to HTML using libcmark's fast (but uncustomizable) renderer.
|
348
|
+
def to_html(option = :default)
|
349
|
+
Config.option_exists?(option)
|
350
|
+
CMark.render_html(@pointer, Config.to_h[option]).force_encoding('utf-8')
|
351
|
+
end
|
352
|
+
|
353
|
+
# Unlinks and frees this Node.
|
354
|
+
def free
|
355
|
+
CMark.node_unlink(@pointer)
|
356
|
+
# CMark.node_free(@pointer)
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
class Renderer
|
361
|
+
attr_accessor :in_tight, :warnings, :in_plain
|
362
|
+
def initialize
|
363
|
+
@stream = StringIO.new
|
364
|
+
@need_blocksep = false
|
365
|
+
@warnings = Set.new []
|
366
|
+
@in_tight = false
|
367
|
+
@in_plain = false
|
368
|
+
end
|
369
|
+
|
370
|
+
def out(*args)
|
371
|
+
args.each do |arg|
|
372
|
+
if arg == :children
|
373
|
+
@node.each_child do |child|
|
374
|
+
self.out(child)
|
375
|
+
end
|
376
|
+
elsif arg.kind_of?(Array)
|
377
|
+
arg.each do |x|
|
378
|
+
self.render(x)
|
379
|
+
end
|
380
|
+
elsif arg.kind_of?(Node)
|
381
|
+
self.render(arg)
|
382
|
+
else
|
383
|
+
@stream.write(arg)
|
384
|
+
end
|
385
|
+
end
|
386
|
+
end
|
387
|
+
|
388
|
+
def render(node)
|
389
|
+
@node = node
|
390
|
+
if node.type == :document
|
391
|
+
self.document(node)
|
392
|
+
return @stream.string
|
393
|
+
elsif self.in_plain && node.type != :text && node.type != :softbreak
|
394
|
+
node.each_child do |child|
|
395
|
+
render(child)
|
396
|
+
end
|
397
|
+
else
|
398
|
+
begin
|
399
|
+
self.send(node.type, node)
|
400
|
+
rescue NoMethodError => e
|
401
|
+
@warnings.add("WARNING: " + node.type.to_s + " not implemented.")
|
402
|
+
raise e
|
403
|
+
end
|
404
|
+
end
|
405
|
+
end
|
406
|
+
|
407
|
+
def document(node)
|
408
|
+
self.out(:children)
|
409
|
+
end
|
410
|
+
|
411
|
+
def code_block(node)
|
412
|
+
self.code_block(node)
|
413
|
+
end
|
414
|
+
|
415
|
+
def reference_def(node)
|
416
|
+
end
|
417
|
+
|
418
|
+
def blocksep
|
419
|
+
self.out("\n")
|
420
|
+
end
|
421
|
+
|
422
|
+
def containersep
|
423
|
+
if !self.in_tight
|
424
|
+
self.out("\n")
|
425
|
+
end
|
426
|
+
end
|
427
|
+
|
428
|
+
def block(&blk)
|
429
|
+
if @need_blocksep
|
430
|
+
self.blocksep
|
431
|
+
end
|
432
|
+
blk.call
|
433
|
+
@need_blocksep = true
|
434
|
+
end
|
435
|
+
|
436
|
+
def container(starter, ender, &blk)
|
437
|
+
self.out(starter)
|
438
|
+
self.containersep
|
439
|
+
@need_blocksep = false
|
440
|
+
blk.call
|
441
|
+
self.containersep
|
442
|
+
self.out(ender)
|
443
|
+
end
|
444
|
+
|
445
|
+
def plain(&blk)
|
446
|
+
old_in_plain = @in_plain
|
447
|
+
@in_plain = true
|
448
|
+
blk.call
|
449
|
+
@in_plain = old_in_plain
|
450
|
+
end
|
451
|
+
end
|
452
|
+
|
453
|
+
class HtmlRenderer < Renderer
|
454
|
+
def render(node)
|
455
|
+
result = super(node)
|
456
|
+
if node.type == :document
|
457
|
+
result += "\n"
|
458
|
+
end
|
459
|
+
end
|
460
|
+
|
461
|
+
def header(node)
|
462
|
+
block do
|
463
|
+
self.out("<h", node.header_level, ">", :children,
|
464
|
+
"</h", node.header_level, ">")
|
465
|
+
end
|
466
|
+
end
|
467
|
+
|
468
|
+
def paragraph(node)
|
469
|
+
block do
|
470
|
+
if self.in_tight
|
471
|
+
self.out(:children)
|
472
|
+
else
|
473
|
+
self.out("<p>", :children, "</p>")
|
474
|
+
end
|
475
|
+
end
|
476
|
+
end
|
477
|
+
|
478
|
+
def list(node)
|
479
|
+
old_in_tight = self.in_tight
|
480
|
+
self.in_tight = node.list_tight
|
481
|
+
block do
|
482
|
+
if node.list_type == :bullet_list
|
483
|
+
container("<ul>", "</ul>") do
|
484
|
+
self.out(:children)
|
485
|
+
end
|
486
|
+
else
|
487
|
+
start = node.list_start == 1 ? '' :
|
488
|
+
(' start="' + node.list_start.to_s + '"')
|
489
|
+
container(start, "</ol>") do
|
490
|
+
self.out(:children)
|
491
|
+
end
|
492
|
+
end
|
493
|
+
end
|
494
|
+
self.in_tight = old_in_tight
|
495
|
+
end
|
496
|
+
|
497
|
+
def list_item(node)
|
498
|
+
block do
|
499
|
+
container("<li>", "</li>") do
|
500
|
+
self.out(:children)
|
501
|
+
end
|
502
|
+
end
|
503
|
+
end
|
504
|
+
|
505
|
+
def blockquote(node)
|
506
|
+
block do
|
507
|
+
container("<blockquote>", "</blockquote>") do
|
508
|
+
self.out(:children)
|
509
|
+
end
|
510
|
+
end
|
511
|
+
end
|
512
|
+
|
513
|
+
def hrule(node)
|
514
|
+
block do
|
515
|
+
self.out("<hr />")
|
516
|
+
end
|
517
|
+
end
|
518
|
+
|
519
|
+
def code_block(node)
|
520
|
+
block do
|
521
|
+
self.out("<pre><code")
|
522
|
+
if node.fence_info && node.fence_info.length > 0
|
523
|
+
self.out(" class=\"language-", node.fence_info.split(/\s+/)[0], "\">")
|
524
|
+
else
|
525
|
+
self.out(">")
|
526
|
+
end
|
527
|
+
self.out(CGI.escapeHTML(node.string_content))
|
528
|
+
self.out("</code></pre>")
|
529
|
+
end
|
530
|
+
end
|
531
|
+
|
532
|
+
def html(node)
|
533
|
+
block do
|
534
|
+
self.out(node.string_content)
|
535
|
+
end
|
536
|
+
end
|
537
|
+
|
538
|
+
def inline_html(node)
|
539
|
+
self.out(node.string_content)
|
540
|
+
end
|
541
|
+
|
542
|
+
def emph(node)
|
543
|
+
self.out("<em>", :children, "</em>")
|
544
|
+
end
|
545
|
+
|
546
|
+
def strong(node)
|
547
|
+
self.out("<strong>", :children, "</strong>")
|
548
|
+
end
|
549
|
+
|
550
|
+
def link(node)
|
551
|
+
self.out('<a href="', node.url.nil? ? '' : URI.escape(node.url), '"')
|
552
|
+
if node.title && node.title.length > 0
|
553
|
+
self.out(' title="', CGI.escapeHTML(node.title), '"')
|
554
|
+
end
|
555
|
+
self.out('>', :children, '</a>')
|
556
|
+
end
|
557
|
+
|
558
|
+
def image(node)
|
559
|
+
self.out('<img src="', URI.escape(node.url), '"')
|
560
|
+
if node.title && node.title.length > 0
|
561
|
+
self.out(' title="', CGI.escapeHTML(node.title), '"')
|
562
|
+
end
|
563
|
+
plain do
|
564
|
+
self.out(' alt="', :children, '" />')
|
565
|
+
end
|
566
|
+
end
|
567
|
+
|
568
|
+
def text(node)
|
569
|
+
self.out(CGI.escapeHTML(node.string_content))
|
570
|
+
end
|
571
|
+
|
572
|
+
def code(node)
|
573
|
+
self.out("<code>")
|
574
|
+
self.out(CGI.escapeHTML(node.string_content))
|
575
|
+
self.out("</code>")
|
576
|
+
end
|
577
|
+
|
578
|
+
def linebreak(node)
|
579
|
+
self.out("<br/>")
|
580
|
+
self.softbreak(node)
|
581
|
+
end
|
582
|
+
|
583
|
+
def softbreak(node)
|
584
|
+
self.out("\n")
|
585
|
+
end
|
586
|
+
end
|
587
|
+
|
588
|
+
end
|
data/test/benchmark.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'commonmarker'
|
2
|
+
require 'redcarpet'
|
3
|
+
require 'kramdown'
|
4
|
+
require 'benchmark'
|
5
|
+
|
6
|
+
def dobench(name, &blk)
|
7
|
+
puts name
|
8
|
+
puts Benchmark.measure(&blk)
|
9
|
+
end
|
10
|
+
|
11
|
+
benchinput = File.open('../CommonMark/bench/benchinput.md', 'r').read()
|
12
|
+
|
13
|
+
printf("input size = %d bytes\n\n", benchinput.bytesize)
|
14
|
+
|
15
|
+
dobench("commonmarker with to_html") do
|
16
|
+
CommonMarker::Node.parse_string(benchinput).to_html
|
17
|
+
end
|
18
|
+
|
19
|
+
dobench("commonmarker with ruby HtmlRenderer") do
|
20
|
+
CommonMarker::HtmlRenderer.new.render(CommonMarker::Node.parse_string(benchinput))
|
21
|
+
end
|
22
|
+
|
23
|
+
dobench("redcarpet") do
|
24
|
+
Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: false, tables: false).render(benchinput)
|
25
|
+
end
|
26
|
+
|
27
|
+
dobench("kramdown") do
|
28
|
+
Kramdown::Document.new(benchinput).to_html(benchinput)
|
29
|
+
end
|
30
|
+
|