From 33974f1acdd16827342b31cba6b27db5030e733f Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 28 Oct 2021 17:06:06 +0300 Subject: Enable footnotes for cmark-gfm parser Also bump version constraints to 0.29.0-a.3 for libcmark-gfm* dependencies. --- manifest | 4 ++-- mod/page.cxx | 29 +++++++++++++++-------------- tests/load/1/math/libfoo-1.2.4+1.tar.gz | Bin 1033 -> 1061 bytes tests/load/1/math/packages.manifest | 5 +++-- tests/load/driver.cxx | 8 +++++--- 5 files changed, 25 insertions(+), 21 deletions(-) diff --git a/manifest b/manifest index 3214f49..80d0290 100644 --- a/manifest +++ b/manifest @@ -24,8 +24,8 @@ depends: * bpkg >= 0.14.0- requires: ? cli ; Only required if changing .cli files. depends: libapr1 depends: libapreq2 -depends: libcmark-gfm == 0.29.0-a.1 -depends: libcmark-gfm-extensions == 0.29.0-a.1 +depends: libcmark-gfm == 0.29.0-a.3 +depends: libcmark-gfm-extensions == 0.29.0-a.3 depends: libstudxml ^1.1.0-b.10 depends: libodb [2.5.0-b.22.1 2.5.0-b.23) depends: libodb-pgsql [2.5.0-b.22.1 2.5.0-b.23) diff --git a/mod/page.cxx b/mod/page.cxx index b9424dc..f2f1843 100644 --- a/mod/page.cxx +++ b/mod/page.cxx @@ -903,8 +903,14 @@ namespace brep { // Parse Markdown into the AST. // + // Note that the footnotes extension needs to be enabled via the + // CMARK_OPT_FOOTNOTES flag rather than the + // cmark_parser_attach_syntax_extension() function call. + // unique_ptr parser ( - cmark_parser_new (CMARK_OPT_DEFAULT | CMARK_OPT_VALIDATE_UTF8), + cmark_parser_new (CMARK_OPT_DEFAULT | + CMARK_OPT_FOOTNOTES | + CMARK_OPT_VALIDATE_UTF8), [] (cmark_parser* p) {cmark_parser_free (p);}); // Enable GitHub extensions in the parser, if requested. @@ -912,25 +918,20 @@ namespace brep if (type_ == text_type::github_mark) { auto add = [&parser] (const char* ext) - { - cmark_syntax_extension* e ( - cmark_find_syntax_extension (ext)); + { + cmark_syntax_extension* e ( + cmark_find_syntax_extension (ext)); - // Built-in extension is only expected. - // - assert (e != nullptr); + // Built-in extension is only expected. + // + assert (e != nullptr); - cmark_parser_attach_syntax_extension (parser.get (), e); - }; + cmark_parser_attach_syntax_extension (parser.get (), e); + }; add ("table"); add ("strikethrough"); add ("autolink"); - - // Somehow feels unsafe (there are some nasty warnings when - // upstream's tasklist.c is compiled), so let's disable for now. - // - // add ("tasklist"); } cmark_parser_feed (parser.get (), text_.c_str (), text_.size ()); diff --git a/tests/load/1/math/libfoo-1.2.4+1.tar.gz b/tests/load/1/math/libfoo-1.2.4+1.tar.gz index 80a6271..c678acf 100644 Binary files a/tests/load/1/math/libfoo-1.2.4+1.tar.gz and b/tests/load/1/math/libfoo-1.2.4+1.tar.gz differ diff --git a/tests/load/1/math/packages.manifest b/tests/load/1/math/packages.manifest index 7ed9a7d..3c2064b 100644 --- a/tests/load/1/math/packages.manifest +++ b/tests/load/1/math/packages.manifest @@ -53,9 +53,10 @@ A modern C++ library with easy to use linear algebra and lot of optimization tools. There are over 100 functions in total with an extensive test suite. The API is -similar to ~~mathlab~~ **MATLAB**. +similar to ~~mathlab~~ **MATLAB**.[^mathlab] Useful for conversion of research code into production environments. +[^mathlab]: MATLAB Capabilities: TODO \ description-type: text/markdown changes: \ @@ -84,7 +85,7 @@ tests: * libfoo-tests == 1.2.4 examples: libfoo-examples benchmarks: libfoo-benchmarks > 0.0.1 location: libfoo-1.2.4+1.tar.gz -sha256sum: 6692a487e0908598e36bdeb9c25ed1e4a35bb99587dbc475807d314fa0719ac6 +sha256sum: f99cb46b97d0e1dccbdd10571f1f649ac5bbb22d6c25adadbc579ffbbb89d31c : name: libfoo-benchmarks version: 1.2.4 diff --git a/tests/load/driver.cxx b/tests/load/driver.cxx index af21616..51627b7 100644 --- a/tests/load/driver.cxx +++ b/tests/load/driver.cxx @@ -725,12 +725,14 @@ test_pkg_repos (const cstrings& loader_args, assert (fpv5->topics == labels ({"math library", "math API", "libbaz fork"})); assert (fpv5->keywords == labels ({"c++", "foo", "math", "best"})); + assert (*fpv5->description == "A modern C++ library with easy to use linear algebra and lot " "of optimization\ntools.\n\nThere are over 100 functions in " "total with an extensive test suite. The API is\nsimilar to " - "~~mathlab~~ **MATLAB**.\n\nUseful for conversion of research " - "code into production environments."); + "~~mathlab~~ **MATLAB**.[^mathlab]\n\nUseful for conversion of " + "research code into production environments.\n" + "[^mathlab]: MATLAB Capabilities: TODO"); assert (fpv5->url && fpv5->url->string () == "http://www.example.com/foo/"); @@ -830,7 +832,7 @@ test_pkg_repos (const cstrings& loader_args, assert (check_location (fpv5)); assert (fpv5->sha256sum && *fpv5->sha256sum == - "6692a487e0908598e36bdeb9c25ed1e4a35bb99587dbc475807d314fa0719ac6"); + "f99cb46b97d0e1dccbdd10571f1f649ac5bbb22d6c25adadbc579ffbbb89d31c"); assert (fpv5->buildable); -- cgit v1.1