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
@@ -0,0 +1,110 @@
|
|
1
|
+
#ifndef CMARK_CHUNK_H
|
2
|
+
#define CMARK_CHUNK_H
|
3
|
+
|
4
|
+
#include <string.h>
|
5
|
+
#include <stdlib.h>
|
6
|
+
#include <assert.h>
|
7
|
+
#include "cmark_ctype.h"
|
8
|
+
#include "buffer.h"
|
9
|
+
|
10
|
+
typedef struct {
|
11
|
+
unsigned char *data;
|
12
|
+
int len;
|
13
|
+
int alloc; // also implies a NULL-terminated string
|
14
|
+
} cmark_chunk;
|
15
|
+
|
16
|
+
static inline void cmark_chunk_free(cmark_chunk *c)
|
17
|
+
{
|
18
|
+
if (c->alloc)
|
19
|
+
free(c->data);
|
20
|
+
|
21
|
+
c->data = NULL;
|
22
|
+
c->alloc = 0;
|
23
|
+
c->len = 0;
|
24
|
+
}
|
25
|
+
|
26
|
+
static inline void cmark_chunk_ltrim(cmark_chunk *c)
|
27
|
+
{
|
28
|
+
assert(!c->alloc);
|
29
|
+
|
30
|
+
while (c->len && cmark_isspace(c->data[0])) {
|
31
|
+
c->data++;
|
32
|
+
c->len--;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
static inline void cmark_chunk_rtrim(cmark_chunk *c)
|
37
|
+
{
|
38
|
+
while (c->len > 0) {
|
39
|
+
if (!cmark_isspace(c->data[c->len - 1]))
|
40
|
+
break;
|
41
|
+
|
42
|
+
c->len--;
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
static inline void cmark_chunk_trim(cmark_chunk *c)
|
47
|
+
{
|
48
|
+
cmark_chunk_ltrim(c);
|
49
|
+
cmark_chunk_rtrim(c);
|
50
|
+
}
|
51
|
+
|
52
|
+
static inline int cmark_chunk_strchr(cmark_chunk *ch, int c, int offset)
|
53
|
+
{
|
54
|
+
const unsigned char *p = (unsigned char *)memchr(ch->data + offset, c, ch->len - offset);
|
55
|
+
return p ? (int)(p - ch->data) : ch->len;
|
56
|
+
}
|
57
|
+
|
58
|
+
static inline const char *cmark_chunk_to_cstr(cmark_chunk *c)
|
59
|
+
{
|
60
|
+
unsigned char *str;
|
61
|
+
|
62
|
+
if (c->alloc) {
|
63
|
+
return (char *)c->data;
|
64
|
+
}
|
65
|
+
str = (unsigned char *)malloc(c->len + 1);
|
66
|
+
if(str != NULL) {
|
67
|
+
memcpy(str, c->data, c->len);
|
68
|
+
str[c->len] = 0;
|
69
|
+
}
|
70
|
+
c->data = str;
|
71
|
+
c->alloc = 1;
|
72
|
+
|
73
|
+
return (char *)str;
|
74
|
+
}
|
75
|
+
|
76
|
+
static inline void cmark_chunk_set_cstr(cmark_chunk *c, const char *str)
|
77
|
+
{
|
78
|
+
if (c->alloc) {
|
79
|
+
free(c->data);
|
80
|
+
}
|
81
|
+
c->len = strlen(str);
|
82
|
+
c->data = (unsigned char *)malloc(c->len + 1);
|
83
|
+
c->alloc = 1;
|
84
|
+
memcpy(c->data, str, c->len + 1);
|
85
|
+
}
|
86
|
+
|
87
|
+
static inline cmark_chunk cmark_chunk_literal(const char *data)
|
88
|
+
{
|
89
|
+
cmark_chunk c = {(unsigned char *)data, data ? strlen(data) : 0, 0};
|
90
|
+
return c;
|
91
|
+
}
|
92
|
+
|
93
|
+
static inline cmark_chunk cmark_chunk_dup(const cmark_chunk *ch, int pos, int len)
|
94
|
+
{
|
95
|
+
cmark_chunk c = {ch->data + pos, len, 0};
|
96
|
+
return c;
|
97
|
+
}
|
98
|
+
|
99
|
+
static inline cmark_chunk cmark_chunk_buf_detach(cmark_strbuf *buf)
|
100
|
+
{
|
101
|
+
cmark_chunk c;
|
102
|
+
|
103
|
+
c.len = buf->size;
|
104
|
+
c.data = cmark_strbuf_detach(buf);
|
105
|
+
c.alloc = 1;
|
106
|
+
|
107
|
+
return c;
|
108
|
+
}
|
109
|
+
|
110
|
+
#endif
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#include <stdlib.h>
|
2
|
+
#include <assert.h>
|
3
|
+
#include <stdio.h>
|
4
|
+
#include "node.h"
|
5
|
+
#include "houdini.h"
|
6
|
+
#include "cmark.h"
|
7
|
+
#include "buffer.h"
|
8
|
+
|
9
|
+
const int cmark_version = CMARK_VERSION;
|
10
|
+
const char cmark_version_string[] = CMARK_VERSION_STRING;
|
11
|
+
|
12
|
+
char *cmark_markdown_to_html(const char *text, int len, int options)
|
13
|
+
{
|
14
|
+
cmark_node *doc;
|
15
|
+
char *result;
|
16
|
+
|
17
|
+
doc = cmark_parse_document(text, len, options);
|
18
|
+
|
19
|
+
result = cmark_render_html(doc, options);
|
20
|
+
cmark_node_free(doc);
|
21
|
+
|
22
|
+
return result;
|
23
|
+
}
|
24
|
+
|
@@ -0,0 +1,565 @@
|
|
1
|
+
#ifndef CMARK_H
|
2
|
+
#define CMARK_H
|
3
|
+
|
4
|
+
#include <stdio.h>
|
5
|
+
#include <cmark_export.h>
|
6
|
+
#include <cmark_version.h>
|
7
|
+
|
8
|
+
#ifdef __cplusplus
|
9
|
+
extern "C" {
|
10
|
+
#endif
|
11
|
+
|
12
|
+
/** # NAME
|
13
|
+
*
|
14
|
+
* **cmark** - CommonMark parsing, manipulating, and rendering
|
15
|
+
*/
|
16
|
+
|
17
|
+
/** # DESCRIPTION
|
18
|
+
*
|
19
|
+
* ## Simple Interface
|
20
|
+
*/
|
21
|
+
|
22
|
+
/** Convert 'text' (assumed to be a UTF-8 encoded string with length
|
23
|
+
* 'len' from CommonMark Markdown to HTML, returning a null-terminated,
|
24
|
+
* UTF-8-encoded string.
|
25
|
+
*/
|
26
|
+
CMARK_EXPORT
|
27
|
+
char *cmark_markdown_to_html(const char *text, int len, int options);
|
28
|
+
|
29
|
+
/** ## Node Structure
|
30
|
+
*/
|
31
|
+
|
32
|
+
typedef enum {
|
33
|
+
/* Error status */
|
34
|
+
CMARK_NODE_NONE,
|
35
|
+
|
36
|
+
/* Block */
|
37
|
+
CMARK_NODE_DOCUMENT,
|
38
|
+
CMARK_NODE_BLOCK_QUOTE,
|
39
|
+
CMARK_NODE_LIST,
|
40
|
+
CMARK_NODE_ITEM,
|
41
|
+
CMARK_NODE_CODE_BLOCK,
|
42
|
+
CMARK_NODE_HTML,
|
43
|
+
CMARK_NODE_PARAGRAPH,
|
44
|
+
CMARK_NODE_HEADER,
|
45
|
+
CMARK_NODE_HRULE,
|
46
|
+
|
47
|
+
CMARK_NODE_FIRST_BLOCK = CMARK_NODE_DOCUMENT,
|
48
|
+
CMARK_NODE_LAST_BLOCK = CMARK_NODE_HRULE,
|
49
|
+
|
50
|
+
/* Inline */
|
51
|
+
CMARK_NODE_TEXT,
|
52
|
+
CMARK_NODE_SOFTBREAK,
|
53
|
+
CMARK_NODE_LINEBREAK,
|
54
|
+
CMARK_NODE_CODE,
|
55
|
+
CMARK_NODE_INLINE_HTML,
|
56
|
+
CMARK_NODE_EMPH,
|
57
|
+
CMARK_NODE_STRONG,
|
58
|
+
CMARK_NODE_LINK,
|
59
|
+
CMARK_NODE_IMAGE,
|
60
|
+
|
61
|
+
CMARK_NODE_FIRST_INLINE = CMARK_NODE_TEXT,
|
62
|
+
CMARK_NODE_LAST_INLINE = CMARK_NODE_IMAGE,
|
63
|
+
} cmark_node_type;
|
64
|
+
|
65
|
+
|
66
|
+
typedef enum {
|
67
|
+
CMARK_NO_LIST,
|
68
|
+
CMARK_BULLET_LIST,
|
69
|
+
CMARK_ORDERED_LIST
|
70
|
+
} cmark_list_type;
|
71
|
+
|
72
|
+
typedef enum {
|
73
|
+
CMARK_NO_DELIM,
|
74
|
+
CMARK_PERIOD_DELIM,
|
75
|
+
CMARK_PAREN_DELIM
|
76
|
+
} cmark_delim_type;
|
77
|
+
|
78
|
+
typedef struct cmark_node cmark_node;
|
79
|
+
typedef struct cmark_parser cmark_parser;
|
80
|
+
typedef struct cmark_iter cmark_iter;
|
81
|
+
|
82
|
+
typedef enum {
|
83
|
+
CMARK_EVENT_NONE,
|
84
|
+
CMARK_EVENT_DONE,
|
85
|
+
CMARK_EVENT_ENTER,
|
86
|
+
CMARK_EVENT_EXIT
|
87
|
+
} cmark_event_type;
|
88
|
+
|
89
|
+
/**
|
90
|
+
* ## Creating and Destroying Nodes
|
91
|
+
*/
|
92
|
+
|
93
|
+
/** Creates a new node of type 'type'. Note that the node may have
|
94
|
+
* other required properties, which it is the caller's responsibility
|
95
|
+
* to assign.
|
96
|
+
*/
|
97
|
+
CMARK_EXPORT cmark_node*
|
98
|
+
cmark_node_new(cmark_node_type type);
|
99
|
+
|
100
|
+
/** Frees the memory allocated for a node.
|
101
|
+
*/
|
102
|
+
CMARK_EXPORT void
|
103
|
+
cmark_node_free(cmark_node *node);
|
104
|
+
|
105
|
+
/**
|
106
|
+
* ## Tree Traversal
|
107
|
+
*/
|
108
|
+
|
109
|
+
/** Returns the next node in the sequence after 'node', or NULL if
|
110
|
+
* there is none.
|
111
|
+
*/
|
112
|
+
CMARK_EXPORT cmark_node*
|
113
|
+
cmark_node_next(cmark_node *node);
|
114
|
+
|
115
|
+
/** Returns the previous node in the sequence after 'node', or NULL if
|
116
|
+
* there is none.
|
117
|
+
*/
|
118
|
+
CMARK_EXPORT cmark_node*
|
119
|
+
cmark_node_previous(cmark_node *node);
|
120
|
+
|
121
|
+
/** Returns the parent of 'node', or NULL if there is none.
|
122
|
+
*/
|
123
|
+
CMARK_EXPORT cmark_node*
|
124
|
+
cmark_node_parent(cmark_node *node);
|
125
|
+
|
126
|
+
/** Returns the first child of 'node', or NULL if 'node' has no children.
|
127
|
+
*/
|
128
|
+
CMARK_EXPORT cmark_node*
|
129
|
+
cmark_node_first_child(cmark_node *node);
|
130
|
+
|
131
|
+
/** Returns the last child of 'node', or NULL if 'node' has no children.
|
132
|
+
*/
|
133
|
+
CMARK_EXPORT cmark_node*
|
134
|
+
cmark_node_last_child(cmark_node *node);
|
135
|
+
|
136
|
+
/**
|
137
|
+
* ## Iterator
|
138
|
+
*
|
139
|
+
* An iterator will walk through a tree of nodes, starting from a root
|
140
|
+
* node, returning one node at a time, together with information about
|
141
|
+
* whether the node is being entered or exited. The iterator will
|
142
|
+
* first descend to a child node, if there is one. When there is no
|
143
|
+
* child, the iterator will go to the next sibling. When there is no
|
144
|
+
* next sibling, the iterator will return to the parent (but with
|
145
|
+
* a 'cmark_event_type' of `CMARK_EVENT_EXIT`). The iterator will
|
146
|
+
* return `CMARK_EVENT_DONE` when it reaches the root node again.
|
147
|
+
* One natural application is an HTML renderer, where an `ENTER` event
|
148
|
+
* outputs an open tag and an `EXIT` event outputs a close tag.
|
149
|
+
* An iterator might also be used to transform an AST in some systematic
|
150
|
+
* way, for example, turning all level-3 headers into regular paragraphs.
|
151
|
+
*
|
152
|
+
* void
|
153
|
+
* usage_example(cmark_node *root) {
|
154
|
+
* cmark_event_type ev_type;
|
155
|
+
* cmark_iter *iter = cmark_iter_new(root);
|
156
|
+
*
|
157
|
+
* while ((ev_type = cmark_iter_next(iter)) != CMARK_EVENT_DONE) {
|
158
|
+
* cmark_node *cur = cmark_iter_get_node(iter);
|
159
|
+
* // Do something with `cur` and `ev_type`
|
160
|
+
* }
|
161
|
+
*
|
162
|
+
* cmark_iter_free(iter);
|
163
|
+
* }
|
164
|
+
*
|
165
|
+
* Iterators will never return `EXIT` events for leaf nodes, which are nodes
|
166
|
+
* of type:
|
167
|
+
*
|
168
|
+
* * CMARK_NODE_HTML
|
169
|
+
* * CMARK_NODE_HRULE
|
170
|
+
* * CMARK_NODE_CODE_BLOCK
|
171
|
+
* * CMARK_NODE_TEXT
|
172
|
+
* * CMARK_NODE_SOFTBREAK
|
173
|
+
* * CMARK_NODE_LINEBREAK
|
174
|
+
* * CMARK_NODE_CODE
|
175
|
+
* * CMARK_NODE_INLINE_HTML
|
176
|
+
*
|
177
|
+
* Nodes must only be modified after an `EXIT` event, or an `ENTER` event for
|
178
|
+
* leaf nodes.
|
179
|
+
*/
|
180
|
+
|
181
|
+
/** Creates a new iterator starting at 'root'. The current node and event
|
182
|
+
* type are undefined until `cmark_iter_next` is called for the first time.
|
183
|
+
*/
|
184
|
+
CMARK_EXPORT
|
185
|
+
cmark_iter*
|
186
|
+
cmark_iter_new(cmark_node *root);
|
187
|
+
|
188
|
+
/** Frees the memory allocated for an iterator.
|
189
|
+
*/
|
190
|
+
CMARK_EXPORT
|
191
|
+
void
|
192
|
+
cmark_iter_free(cmark_iter *iter);
|
193
|
+
|
194
|
+
/** Advances to the next node and returns the event type (`CMARK_EVENT_ENTER`,
|
195
|
+
* `CMARK_EVENT_EXIT` or `CMARK_EVENT_DONE`).
|
196
|
+
*/
|
197
|
+
CMARK_EXPORT
|
198
|
+
cmark_event_type
|
199
|
+
cmark_iter_next(cmark_iter *iter);
|
200
|
+
|
201
|
+
/** Returns the current node.
|
202
|
+
*/
|
203
|
+
CMARK_EXPORT
|
204
|
+
cmark_node*
|
205
|
+
cmark_iter_get_node(cmark_iter *iter);
|
206
|
+
|
207
|
+
/** Returns the current event type.
|
208
|
+
*/
|
209
|
+
CMARK_EXPORT
|
210
|
+
cmark_event_type
|
211
|
+
cmark_iter_get_event_type(cmark_iter *iter);
|
212
|
+
|
213
|
+
/** Returns the root node.
|
214
|
+
*/
|
215
|
+
CMARK_EXPORT
|
216
|
+
cmark_node*
|
217
|
+
cmark_iter_get_root(cmark_iter *iter);
|
218
|
+
|
219
|
+
/** Resets the iterator so that the current node is 'current' and
|
220
|
+
* the event type is 'event_type'. The new current node must be a
|
221
|
+
* descendant of the root node or the root node itself.
|
222
|
+
*/
|
223
|
+
CMARK_EXPORT
|
224
|
+
void
|
225
|
+
cmark_iter_reset(cmark_iter *iter, cmark_node *current,
|
226
|
+
cmark_event_type event_type);
|
227
|
+
|
228
|
+
/**
|
229
|
+
* ## Accessors
|
230
|
+
*/
|
231
|
+
|
232
|
+
/** Returns the user data of 'node'.
|
233
|
+
*/
|
234
|
+
CMARK_EXPORT void*
|
235
|
+
cmark_node_get_user_data(cmark_node *node);
|
236
|
+
|
237
|
+
/** Sets arbitrary user data for 'node'. Returns 1 on success,
|
238
|
+
* 0 on failure.
|
239
|
+
*/
|
240
|
+
CMARK_EXPORT int
|
241
|
+
cmark_node_set_user_data(cmark_node *node, void *user_data);
|
242
|
+
|
243
|
+
/** Returns the type of 'node', or `CMARK_NODE_NONE` on error.
|
244
|
+
*/
|
245
|
+
CMARK_EXPORT cmark_node_type
|
246
|
+
cmark_node_get_type(cmark_node *node);
|
247
|
+
|
248
|
+
/** Like 'cmark_node_get_type', but returns a string representation
|
249
|
+
of the type, or `"<unknown>"`.
|
250
|
+
*/
|
251
|
+
CMARK_EXPORT
|
252
|
+
const char*
|
253
|
+
cmark_node_get_type_string(cmark_node *node);
|
254
|
+
|
255
|
+
/** Returns the string contents of 'node', or NULL if none.
|
256
|
+
*/
|
257
|
+
CMARK_EXPORT const char*
|
258
|
+
cmark_node_get_literal(cmark_node *node);
|
259
|
+
|
260
|
+
/** Sets the string contents of 'node'. Returns 1 on success,
|
261
|
+
* 0 on failure.
|
262
|
+
*/
|
263
|
+
CMARK_EXPORT int
|
264
|
+
cmark_node_set_literal(cmark_node *node, const char *content);
|
265
|
+
|
266
|
+
/** Returns the header level of 'node', or 0 if 'node' is not a header.
|
267
|
+
*/
|
268
|
+
CMARK_EXPORT int
|
269
|
+
cmark_node_get_header_level(cmark_node *node);
|
270
|
+
|
271
|
+
/** Sets the header level of 'node', returning 1 on success and 0 on error.
|
272
|
+
*/
|
273
|
+
CMARK_EXPORT int
|
274
|
+
cmark_node_set_header_level(cmark_node *node, int level);
|
275
|
+
|
276
|
+
/** Returns the list type of 'node', or `CMARK_NO_LIST` if 'node'
|
277
|
+
* is not a list.
|
278
|
+
*/
|
279
|
+
CMARK_EXPORT cmark_list_type
|
280
|
+
cmark_node_get_list_type(cmark_node *node);
|
281
|
+
|
282
|
+
/** Sets the list type of 'node', returning 1 on success and 0 on error.
|
283
|
+
*/
|
284
|
+
CMARK_EXPORT int
|
285
|
+
cmark_node_set_list_type(cmark_node *node, cmark_list_type type);
|
286
|
+
|
287
|
+
/** Returns the list delimiter type of 'node', or `CMARK_NO_DELIM` if 'node'
|
288
|
+
* is not a list.
|
289
|
+
*/
|
290
|
+
CMARK_EXPORT cmark_delim_type
|
291
|
+
cmark_node_get_list_delim(cmark_node *node);
|
292
|
+
|
293
|
+
/** Sets the list delimiter type of 'node', returning 1 on success and 0
|
294
|
+
* on error.
|
295
|
+
*/
|
296
|
+
CMARK_EXPORT int
|
297
|
+
cmark_node_set_list_delim(cmark_node *node, cmark_delim_type delim);
|
298
|
+
|
299
|
+
/** Returns starting number of 'node', if it is an ordered list, otherwise 0.
|
300
|
+
*/
|
301
|
+
CMARK_EXPORT int
|
302
|
+
cmark_node_get_list_start(cmark_node *node);
|
303
|
+
|
304
|
+
/** Sets starting number of 'node', if it is an ordered list. Returns 1
|
305
|
+
* on success, 0 on failure.
|
306
|
+
*/
|
307
|
+
CMARK_EXPORT int
|
308
|
+
cmark_node_set_list_start(cmark_node *node, int start);
|
309
|
+
|
310
|
+
/** Returns 1 if 'node' is a tight list, 0 otherwise.
|
311
|
+
*/
|
312
|
+
CMARK_EXPORT int
|
313
|
+
cmark_node_get_list_tight(cmark_node *node);
|
314
|
+
|
315
|
+
/** Sets the "tightness" of a list. Returns 1 on success, 0 on failure.
|
316
|
+
*/
|
317
|
+
CMARK_EXPORT int
|
318
|
+
cmark_node_set_list_tight(cmark_node *node, int tight);
|
319
|
+
|
320
|
+
/** Returns the info string from a fenced code block, or NULL if none.
|
321
|
+
*/
|
322
|
+
CMARK_EXPORT const char*
|
323
|
+
cmark_node_get_fence_info(cmark_node *node);
|
324
|
+
|
325
|
+
/** Sets the info string in a fenced code block, returning 1 on
|
326
|
+
* success and 0 on failure.
|
327
|
+
*/
|
328
|
+
CMARK_EXPORT int
|
329
|
+
cmark_node_set_fence_info(cmark_node *node, const char *info);
|
330
|
+
|
331
|
+
/** Gets the URL of a link or image 'node', or NULL if none.
|
332
|
+
*/
|
333
|
+
CMARK_EXPORT const char*
|
334
|
+
cmark_node_get_url(cmark_node *node);
|
335
|
+
|
336
|
+
/** Sets the URL of a link or image 'node'. Returns 1 on success,
|
337
|
+
* 0 on failure.
|
338
|
+
*/
|
339
|
+
CMARK_EXPORT int
|
340
|
+
cmark_node_set_url(cmark_node *node, const char *url);
|
341
|
+
|
342
|
+
/** Gets the title of a link or image 'node', or NULL if none.
|
343
|
+
*/
|
344
|
+
CMARK_EXPORT const char*
|
345
|
+
cmark_node_get_title(cmark_node *node);
|
346
|
+
|
347
|
+
/** Sets the title of a link or image 'node'. Returns 1 on success,
|
348
|
+
* 0 on failure.
|
349
|
+
*/
|
350
|
+
CMARK_EXPORT int
|
351
|
+
cmark_node_set_title(cmark_node *node, const char *title);
|
352
|
+
|
353
|
+
/** Returns the line on which 'node' begins.
|
354
|
+
*/
|
355
|
+
CMARK_EXPORT int
|
356
|
+
cmark_node_get_start_line(cmark_node *node);
|
357
|
+
|
358
|
+
/** Returns the column at which 'node' begins.
|
359
|
+
*/
|
360
|
+
CMARK_EXPORT int
|
361
|
+
cmark_node_get_start_column(cmark_node *node);
|
362
|
+
|
363
|
+
/** Returns the line on which 'node' ends.
|
364
|
+
*/
|
365
|
+
CMARK_EXPORT int
|
366
|
+
cmark_node_get_end_line(cmark_node *node);
|
367
|
+
|
368
|
+
/** Returns the column at which 'node' ends.
|
369
|
+
*/
|
370
|
+
CMARK_EXPORT int
|
371
|
+
cmark_node_get_end_column(cmark_node *node);
|
372
|
+
|
373
|
+
/**
|
374
|
+
* ## Tree Manipulation
|
375
|
+
*/
|
376
|
+
|
377
|
+
/** Unlinks a 'node', removing it from the tree, but not freeing its
|
378
|
+
* memory. (Use 'cmark_node_free' for that.)
|
379
|
+
*/
|
380
|
+
CMARK_EXPORT void
|
381
|
+
cmark_node_unlink(cmark_node *node);
|
382
|
+
|
383
|
+
/** Inserts 'sibling' before 'node'. Returns 1 on success, 0 on failure.
|
384
|
+
*/
|
385
|
+
CMARK_EXPORT int
|
386
|
+
cmark_node_insert_before(cmark_node *node, cmark_node *sibling);
|
387
|
+
|
388
|
+
/** Inserts 'sibling' after 'node'. Returns 1 on success, 0 on failure.
|
389
|
+
*/
|
390
|
+
CMARK_EXPORT int
|
391
|
+
cmark_node_insert_after(cmark_node *node, cmark_node *sibling);
|
392
|
+
|
393
|
+
/** Adds 'child' to the beginning of the children of 'node'.
|
394
|
+
* Returns 1 on success, 0 on failure.
|
395
|
+
*/
|
396
|
+
CMARK_EXPORT int
|
397
|
+
cmark_node_prepend_child(cmark_node *node, cmark_node *child);
|
398
|
+
|
399
|
+
/** Adds 'child' to the end of the children of 'node'.
|
400
|
+
* Returns 1 on success, 0 on failure.
|
401
|
+
*/
|
402
|
+
CMARK_EXPORT int
|
403
|
+
cmark_node_append_child(cmark_node *node, cmark_node *child);
|
404
|
+
|
405
|
+
/** Consolidates adjacent text nodes.
|
406
|
+
*/
|
407
|
+
CMARK_EXPORT void
|
408
|
+
cmark_consolidate_text_nodes(cmark_node *root);
|
409
|
+
|
410
|
+
/**
|
411
|
+
* ## Parsing
|
412
|
+
*
|
413
|
+
* Simple interface:
|
414
|
+
*
|
415
|
+
* cmark_node *document = cmark_parse_document("Hello *world*", 12,
|
416
|
+
* CMARK_OPT_DEFAULT);
|
417
|
+
*
|
418
|
+
* Streaming interface:
|
419
|
+
*
|
420
|
+
* cmark_parser *parser = cmark_parser_new(CMARK_OPT_DEFAULT);
|
421
|
+
* FILE *fp = fopen("myfile.md", "r");
|
422
|
+
* while ((bytes = fread(buffer, 1, sizeof(buffer), fp)) > 0) {
|
423
|
+
* cmark_parser_feed(parser, buffer, bytes);
|
424
|
+
* if (bytes < sizeof(buffer)) {
|
425
|
+
* break;
|
426
|
+
* }
|
427
|
+
* }
|
428
|
+
* document = cmark_parser_finish(parser);
|
429
|
+
* cmark_parser_free(parser);
|
430
|
+
*/
|
431
|
+
|
432
|
+
/** Creates a new parser object.
|
433
|
+
*/
|
434
|
+
CMARK_EXPORT
|
435
|
+
cmark_parser *cmark_parser_new(int options);
|
436
|
+
|
437
|
+
/** Frees memory allocated for a parser object.
|
438
|
+
*/
|
439
|
+
CMARK_EXPORT
|
440
|
+
void cmark_parser_free(cmark_parser *parser);
|
441
|
+
|
442
|
+
/** Feeds a string of length 'len' to 'parser'.
|
443
|
+
*/
|
444
|
+
CMARK_EXPORT
|
445
|
+
void cmark_parser_feed(cmark_parser *parser, const char *buffer, size_t len);
|
446
|
+
|
447
|
+
/** Finish parsing and return a pointer to a tree of nodes.
|
448
|
+
*/
|
449
|
+
CMARK_EXPORT
|
450
|
+
cmark_node *cmark_parser_finish(cmark_parser *parser);
|
451
|
+
|
452
|
+
/** Parse a CommonMark document in 'buffer' of length 'len'.
|
453
|
+
* Returns a pointer to a tree of nodes.
|
454
|
+
*/
|
455
|
+
CMARK_EXPORT
|
456
|
+
cmark_node *cmark_parse_document(const char *buffer, size_t len, int options);
|
457
|
+
|
458
|
+
/** Parse a CommonMark document in file 'f', returning a pointer to
|
459
|
+
* a tree of nodes.
|
460
|
+
*/
|
461
|
+
CMARK_EXPORT
|
462
|
+
cmark_node *cmark_parse_file(FILE *f, int options);
|
463
|
+
|
464
|
+
/**
|
465
|
+
* ## Rendering
|
466
|
+
*/
|
467
|
+
|
468
|
+
/** Render a 'node' tree as XML.
|
469
|
+
*/
|
470
|
+
CMARK_EXPORT
|
471
|
+
char *cmark_render_xml(cmark_node *root, int options);
|
472
|
+
|
473
|
+
/** Render a 'node' tree as an HTML fragment. It is up to the user
|
474
|
+
* to add an appropriate header and footer.
|
475
|
+
*/
|
476
|
+
CMARK_EXPORT
|
477
|
+
char *cmark_render_html(cmark_node *root, int options);
|
478
|
+
|
479
|
+
/** Render a 'node' tree as a groff man page, without the header.
|
480
|
+
*/
|
481
|
+
CMARK_EXPORT
|
482
|
+
char *cmark_render_man(cmark_node *root, int options);
|
483
|
+
|
484
|
+
/** Render a 'node' tree as a commonmark document.
|
485
|
+
*/
|
486
|
+
CMARK_EXPORT
|
487
|
+
char *cmark_render_commonmark(cmark_node *root, int options, int width);
|
488
|
+
|
489
|
+
/** Default writer options.
|
490
|
+
*/
|
491
|
+
#define CMARK_OPT_DEFAULT 0
|
492
|
+
|
493
|
+
/** Include a `data-sourcepos` attribute on all block elements.
|
494
|
+
*/
|
495
|
+
#define CMARK_OPT_SOURCEPOS 1
|
496
|
+
|
497
|
+
/** Render `softbreak` elements as hard line breaks.
|
498
|
+
*/
|
499
|
+
#define CMARK_OPT_HARDBREAKS 2
|
500
|
+
|
501
|
+
/** Normalize tree by consolidating adjacent text nodes.
|
502
|
+
*/
|
503
|
+
#define CMARK_OPT_NORMALIZE 4
|
504
|
+
|
505
|
+
/** Convert straight quotes to curly, --- to em dashes, -- to en dashes.
|
506
|
+
*/
|
507
|
+
#define CMARK_OPT_SMART 8
|
508
|
+
|
509
|
+
/**
|
510
|
+
* ## Version information
|
511
|
+
*/
|
512
|
+
|
513
|
+
/** The library version as integer for runtime checks. Also available as
|
514
|
+
* macro CMARK_VERSION for compile time checks.
|
515
|
+
*
|
516
|
+
* * Bits 16-23 contain the major version.
|
517
|
+
* * Bits 8-15 contain the minor version.
|
518
|
+
* * Bits 0-7 contain the patchlevel.
|
519
|
+
*
|
520
|
+
* In hexadecimal format, the number 0x010203 represents version 1.2.3.
|
521
|
+
*/
|
522
|
+
CMARK_EXPORT
|
523
|
+
extern const int cmark_version;
|
524
|
+
|
525
|
+
/** The library version string for runtime checks. Also available as
|
526
|
+
* macro CMARK_VERSION_STRING for compile time checks.
|
527
|
+
*/
|
528
|
+
CMARK_EXPORT
|
529
|
+
extern const char cmark_version_string[];
|
530
|
+
|
531
|
+
/** # AUTHORS
|
532
|
+
*
|
533
|
+
* John MacFarlane, Vicent Marti, Kārlis Gaņģis, Nick Wellnhofer.
|
534
|
+
*/
|
535
|
+
|
536
|
+
#ifndef CMARK_NO_SHORT_NAMES
|
537
|
+
#define NODE_DOCUMENT CMARK_NODE_DOCUMENT
|
538
|
+
#define NODE_BLOCK_QUOTE CMARK_NODE_BLOCK_QUOTE
|
539
|
+
#define NODE_LIST CMARK_NODE_LIST
|
540
|
+
#define NODE_ITEM CMARK_NODE_ITEM
|
541
|
+
#define NODE_CODE_BLOCK CMARK_NODE_CODE_BLOCK
|
542
|
+
#define NODE_HTML CMARK_NODE_HTML
|
543
|
+
#define NODE_PARAGRAPH CMARK_NODE_PARAGRAPH
|
544
|
+
#define NODE_HEADER CMARK_NODE_HEADER
|
545
|
+
#define NODE_HRULE CMARK_NODE_HRULE
|
546
|
+
#define NODE_TEXT CMARK_NODE_TEXT
|
547
|
+
#define NODE_SOFTBREAK CMARK_NODE_SOFTBREAK
|
548
|
+
#define NODE_LINEBREAK CMARK_NODE_LINEBREAK
|
549
|
+
#define NODE_CODE CMARK_NODE_CODE
|
550
|
+
#define NODE_INLINE_HTML CMARK_NODE_INLINE_HTML
|
551
|
+
#define NODE_EMPH CMARK_NODE_EMPH
|
552
|
+
#define NODE_STRONG CMARK_NODE_STRONG
|
553
|
+
#define NODE_LINK CMARK_NODE_LINK
|
554
|
+
#define NODE_IMAGE CMARK_NODE_IMAGE
|
555
|
+
#define BULLET_LIST CMARK_BULLET_LIST
|
556
|
+
#define ORDERED_LIST CMARK_ORDERED_LIST
|
557
|
+
#define PERIOD_DELIM CMARK_PERIOD_DELIM
|
558
|
+
#define PAREN_DELIM CMARK_PAREN_DELIM
|
559
|
+
#endif
|
560
|
+
|
561
|
+
#ifdef __cplusplus
|
562
|
+
}
|
563
|
+
#endif
|
564
|
+
|
565
|
+
#endif
|