From eb4001955cdb7cbeb241706d72bfea79b64f385c Mon Sep 17 00:00:00 2001 From: Lionel Besson Date: Mon, 19 Apr 2021 17:52:59 +0200 Subject: [PATCH] integrate c2c_markdown into v6_api (#1043) * integrate c2c_markdown into v6_api * update bleach version --- c2corg_api/markdown/README.md | 25 ++ c2corg_api/markdown/__init__.py | 184 ++++++++++ c2corg_api/markdown/alerts.py | 73 ++++ .../markdown/emoji_databases/__init__.py | 0 .../emoji_databases/c2c_activities.py | 65 ++++ .../markdown/emoji_databases/c2c_waypoints.py | 169 +++++++++ c2corg_api/markdown/emojis.py | 105 ++++++ c2corg_api/markdown/header.py | 67 ++++ c2corg_api/markdown/img.py | 99 ++++++ c2corg_api/markdown/ltag.py | 336 ++++++++++++++++++ c2corg_api/markdown/nbsp.py | 39 ++ c2corg_api/markdown/ptag.py | 43 +++ c2corg_api/markdown/toc.py | 116 ++++++ c2corg_api/markdown/video.py | 107 ++++++ c2corg_api/markdown/wikilinks.py | 67 ++++ c2corg_api/tests/markdown/__init__.py | 1 + .../tests/markdown/alerts/Fat finger.html | 1 + .../tests/markdown/alerts/Fat finger.md | 1 + c2corg_api/tests/markdown/alerts/Formats.html | 3 + c2corg_api/tests/markdown/alerts/Formats.md | 1 + .../tests/markdown/alerts/Not after.html | 4 + c2corg_api/tests/markdown/alerts/Not after.md | 2 + .../alerts/Not before and not after.html | 5 + .../alerts/Not before and not after.md | 3 + .../tests/markdown/alerts/Not before.html | 4 + .../tests/markdown/alerts/Not before.md | 2 + .../tests/markdown/alerts/Not stacked.html | 21 ++ .../tests/markdown/alerts/Not stacked.md | 7 + .../markdown/alerts/Trailing spaces 1.html | 3 + .../markdown/alerts/Trailing spaces 1.md | 1 + .../markdown/alerts/Trailing spaces 2.html | 3 + .../markdown/alerts/Trailing spaces 2.md | 1 + .../markdown/alerts/Trailing spaces 3.html | 3 + .../markdown/alerts/Trailing spaces 3.md | 1 + .../markdown/alerts/Trailing spaces 4.html | 2 + .../markdown/alerts/Trailing spaces 4.md | 1 + .../tests/markdown/alerts/Two lines.html | 4 + c2corg_api/tests/markdown/alerts/Two lines.md | 2 + .../tests/markdown/alerts/Two paragraphs.html | 4 + .../tests/markdown/alerts/Two paragraphs.md | 3 + c2corg_api/tests/markdown/alerts/alerts.html | 9 + c2corg_api/tests/markdown/alerts/alerts.md | 6 + c2corg_api/tests/markdown/alerts/images.html | 3 + c2corg_api/tests/markdown/alerts/images.md | 1 + .../tests/markdown/alerts/inside lists.html | 5 + .../tests/markdown/alerts/inside lists.md | 1 + .../tests/markdown/alerts/inside quotes.html | 5 + .../tests/markdown/alerts/inside quotes.md | 1 + c2corg_api/tests/markdown/alerts/lists.html | 6 + c2corg_api/tests/markdown/alerts/lists.md | 2 + .../tests/markdown/alerts/not in code.html | 2 + .../tests/markdown/alerts/not in code.md | 1 + c2corg_api/tests/markdown/alerts/quotes.html | 6 + c2corg_api/tests/markdown/alerts/quotes.md | 2 + c2corg_api/tests/markdown/emojis/code.html | 3 + c2corg_api/tests/markdown/emojis/code.md | 3 + .../tests/markdown/emojis/simple emojis.html | 3 + .../tests/markdown/emojis/simple emojis.md | 3 + .../tests/markdown/generics/sample.html | 66 ++++ c2corg_api/tests/markdown/generics/sample.md | 64 ++++ .../markdown/headers/Emphasis on h5.html | 1 + .../tests/markdown/headers/Emphasis on h5.md | 1 + .../tests/markdown/headers/Emphasis.html | 1 + c2corg_api/tests/markdown/headers/Emphasis.md | 1 + .../tests/markdown/headers/Strange title.html | 1 + .../tests/markdown/headers/Strange title.md | 1 + .../tests/markdown/headers/standard link.html | 1 + .../tests/markdown/headers/standard link.md | 1 + .../markdown/headers/standard link2.html | 1 + .../tests/markdown/headers/standard link2.md | 1 + .../markdown/headers/standard link3.html | 1 + .../tests/markdown/headers/standard link3.md | 1 + .../markdown/headers/standard link4.html | 1 + .../tests/markdown/headers/standard link4.md | 1 + .../markdown/headers/standard link5.html | 1 + .../tests/markdown/headers/standard link5.md | 1 + .../markdown/headers/standard link6.html | 1 + .../tests/markdown/headers/standard link6.md | 1 + .../markdown/headers/standard link7.html | 1 + .../tests/markdown/headers/standard link7.md | 1 + .../markdown/headers/strange separator.html | 1 + .../markdown/headers/strange separator.md | 1 + .../headers/with id and emphasis.html | 1 + .../markdown/headers/with id and emphasis.md | 1 + .../tests/markdown/headers/with id.html | 1 + c2corg_api/tests/markdown/headers/with id.md | 1 + .../tests/markdown/headers/with node.html | 1 + .../tests/markdown/headers/with node.md | 1 + .../tests/markdown/img_tag/Do not parse.html | 3 + .../tests/markdown/img_tag/Do not parse.md | 3 + .../Inside a paragraph, do not parse.html | 1 + .../Inside a paragraph, do not parse.md | 1 + c2corg_api/tests/markdown/img_tag/basic.html | 1 + c2corg_api/tests/markdown/img_tag/basic.md | 1 + .../even new line changes nothing.html | 2 + .../img_tag/even new line changes nothing.md | 2 + .../markdown/img_tag/figure after p.html | 2 + .../tests/markdown/img_tag/figure after p.md | 2 + ...igure between p, and with empty lines.html | 3 + .../figure between p, and with empty lines.md | 5 + .../markdown/img_tag/figure between p.html | 3 + .../markdown/img_tag/figure between p.md | 3 + c2corg_api/tests/markdown/img_tag/img.html | 2 + c2corg_api/tests/markdown/img_tag/img.md | 3 + .../img_tag/two images, two figures.html | 2 + .../img_tag/two images, two figures.md | 1 + .../tests/markdown/links/autolink1.html | 1 + c2corg_api/tests/markdown/links/autolink1.md | 1 + .../tests/markdown/links/autolink2.html | 1 + c2corg_api/tests/markdown/links/autolink2.md | 1 + .../tests/markdown/links/autolink3.html | 1 + c2corg_api/tests/markdown/links/autolink3.md | 1 + .../tests/markdown/links/autolink4.html | 1 + c2corg_api/tests/markdown/links/autolink4.md | 1 + .../tests/markdown/links/autolink5.html | 1 + c2corg_api/tests/markdown/links/autolink5.md | 1 + .../tests/markdown/links/autolink6.html | 1 + c2corg_api/tests/markdown/links/autolink6.md | 1 + .../tests/markdown/links/wikilink-anchor.html | 1 + .../tests/markdown/links/wikilink-anchor.md | 1 + .../markdown/links/wikilink-bad-anchor.html | 1 + .../markdown/links/wikilink-bad-anchor.md | 1 + .../tests/markdown/links/wikilink-bad-id.html | 1 + .../tests/markdown/links/wikilink-bad-id.md | 1 + .../markdown/links/wikilink-bad-lanf.html | 1 + .../tests/markdown/links/wikilink-bad-lanf.md | 1 + .../markdown/links/wikilink-bad-slug.html | 1 + .../tests/markdown/links/wikilink-bad-slug.md | 1 + .../tests/markdown/links/wikilink-lang.html | 1 + .../tests/markdown/links/wikilink-lang.md | 1 + .../tests/markdown/links/wikilink-simple.html | 1 + .../tests/markdown/links/wikilink-simple.md | 1 + .../tests/markdown/links/wikilink-slug.html | 1 + .../tests/markdown/links/wikilink-slug.md | 1 + .../markdown/links/wikilink-whatever.html | 1 + .../tests/markdown/links/wikilink-whatever.md | 1 + .../tests/markdown/links/wikilinks.html | 1 + c2corg_api/tests/markdown/links/wikilinks.md | 1 + .../links/wikilinks_with_underscore.html | 1 + .../links/wikilinks_with_underscore.md | 1 + .../markdown/ltags/Absolute numbering.html | 14 + .../markdown/ltags/Absolute numbering.md | 2 + .../tests/markdown/ltags/Does it see all.html | 12 + .../tests/markdown/ltags/Does it see all.md | 1 + .../markdown/ltags/Format in the middle.html | 7 + .../markdown/ltags/Format in the middle.md | 1 + .../ltags/Header and simple Ltags.html | 16 + .../markdown/ltags/Header and simple Ltags.md | 3 + .../tests/markdown/ltags/L# in cell.html | 10 + c2corg_api/tests/markdown/ltags/L# in cell.md | 1 + .../ltags/LTag containing a wikilink.html | 12 + .../ltags/LTag containing a wikilink.md | 2 + .../LTags and RTags separated by text.html | 26 ++ .../LTags and RTags separated by text.md | 9 + .../ltags/Mal formated first cell #2.html | 8 + .../ltags/Mal formated first cell #2.md | 1 + .../ltags/Mal formated first cell #3.html | 8 + .../ltags/Mal formated first cell #3.md | 1 + .../ltags/Mal formated first cell.html | 8 + .../markdown/ltags/Mal formated first cell.md | 1 + .../tests/markdown/ltags/Simple LTag.html | 12 + .../tests/markdown/ltags/Simple LTag.md | 2 + .../markdown/ltags/Text in the middle.html | 16 + .../markdown/ltags/Text in the middle.md | 4 + .../ltags/Two LTags separated by text.html | 26 ++ .../ltags/Two LTags separated by text.md | 9 + .../markdown/ltags/Unsupported LTag.html | 16 + .../tests/markdown/ltags/Unsupported LTag.md | 3 + .../markdown/ltags/absolutes with label.html | 16 + .../markdown/ltags/absolutes with label.md | 4 + .../ltags/absolutes without labels.html | 16 + .../ltags/absolutes without labels.md | 4 + .../markdown/ltags/middle numbering.html | 16 + .../tests/markdown/ltags/middle numbering.md | 4 + .../tests/markdown/ltags/raw table.html | 7 + c2corg_api/tests/markdown/ltags/raw table.md | 7 + .../tests/markdown/ltags/strange spaces.html | 8 + .../tests/markdown/ltags/strange spaces.md | 1 + .../tests/markdown/ltags/tilde in a cell.html | 8 + .../tests/markdown/ltags/tilde in a cell.md | 1 + .../markdown/ltags/very simple LTag.html | 10 + .../tests/markdown/ltags/very simple LTag.md | 2 + .../markdown/ltags/wrong multi pitch.html | 7 + .../tests/markdown/ltags/wrong multi pitch.md | 1 + c2corg_api/tests/markdown/nbsp/code.html | 3 + c2corg_api/tests/markdown/nbsp/code.md | 3 + c2corg_api/tests/markdown/nbsp/main.html | 1 + c2corg_api/tests/markdown/nbsp/main.md | 1 + .../nbsp/narrow unbreakable spaces.html | 1 + .../nbsp/narrow unbreakable spaces.md | 1 + .../tests/markdown/nbsp/with_inline.html | 1 + c2corg_api/tests/markdown/nbsp/with_inline.md | 1 + c2corg_api/tests/markdown/ptag/base.html | 1 + c2corg_api/tests/markdown/ptag/base.md | 1 + c2corg_api/tests/markdown/test_exceptions.py | 45 +++ c2corg_api/tests/markdown/test_format.py | 32 ++ .../tests/markdown/toc/Not emphasis.html | 6 + c2corg_api/tests/markdown/toc/Not emphasis.md | 2 + c2corg_api/tests/markdown/toc/id.html | 6 + c2corg_api/tests/markdown/toc/id.md | 2 + c2corg_api/tests/markdown/toc/not toc.html | 2 + c2corg_api/tests/markdown/toc/not toc.md | 2 + .../markdown/toc/toc 2 and 3, but not 4.html | 11 + .../markdown/toc/toc 2 and 3, but not 4.md | 4 + .../tests/markdown/toc/toc 2 and 3.html | 10 + c2corg_api/tests/markdown/toc/toc 2 and 3.md | 3 + c2corg_api/tests/markdown/toc/toc.html | 6 + c2corg_api/tests/markdown/toc/toc.md | 2 + c2corg_api/tests/markdown/toc/weird 1.html | 1 + c2corg_api/tests/markdown/toc/weird 1.md | 1 + c2corg_api/tests/markdown/toc/weird 2.html | 1 + c2corg_api/tests/markdown/toc/weird 2.md | 1 + c2corg_api/tests/markdown/toc/weird 3.html | 1 + c2corg_api/tests/markdown/toc/weird 3.md | 2 + c2corg_api/tests/markdown/toc/weird 4.html | 6 + c2corg_api/tests/markdown/toc/weird 4.md | 2 + c2corg_api/tests/markdown/toc/weird 5.html | 6 + c2corg_api/tests/markdown/toc/weird 5.md | 2 + c2corg_api/tests/markdown/video/Vimeo.html | 1 + c2corg_api/tests/markdown/video/Vimeo.md | 1 + .../markdown/video/dailymotion short.html | 1 + .../tests/markdown/video/dailymotion short.md | 1 + .../tests/markdown/video/dailymotion.html | 1 + .../tests/markdown/video/dailymotion.md | 1 + .../tests/markdown/video/not valid url.html | 1 + .../tests/markdown/video/not valid url.md | 1 + .../tests/markdown/video/youtube short.html | 1 + .../tests/markdown/video/youtube short.md | 1 + c2corg_api/tests/markdown/video/youtube.html | 1 + c2corg_api/tests/markdown/video/youtube.md | 1 + .../tests/markdown/weirds/bleach bug.html | 1 + .../tests/markdown/weirds/bleach bug.md | 1 + .../tests/markdown/weirds/markdwon bug.html | 1 + .../tests/markdown/weirds/markdwon bug.md | 1 + c2corg_api/views/markdown.py | 2 +- requirements.txt | 6 +- 236 files changed, 2405 insertions(+), 4 deletions(-) create mode 100644 c2corg_api/markdown/README.md create mode 100644 c2corg_api/markdown/__init__.py create mode 100644 c2corg_api/markdown/alerts.py create mode 100644 c2corg_api/markdown/emoji_databases/__init__.py create mode 100644 c2corg_api/markdown/emoji_databases/c2c_activities.py create mode 100644 c2corg_api/markdown/emoji_databases/c2c_waypoints.py create mode 100644 c2corg_api/markdown/emojis.py create mode 100644 c2corg_api/markdown/header.py create mode 100644 c2corg_api/markdown/img.py create mode 100644 c2corg_api/markdown/ltag.py create mode 100644 c2corg_api/markdown/nbsp.py create mode 100644 c2corg_api/markdown/ptag.py create mode 100644 c2corg_api/markdown/toc.py create mode 100644 c2corg_api/markdown/video.py create mode 100644 c2corg_api/markdown/wikilinks.py create mode 100644 c2corg_api/tests/markdown/__init__.py create mode 100644 c2corg_api/tests/markdown/alerts/Fat finger.html create mode 100644 c2corg_api/tests/markdown/alerts/Fat finger.md create mode 100644 c2corg_api/tests/markdown/alerts/Formats.html create mode 100644 c2corg_api/tests/markdown/alerts/Formats.md create mode 100644 c2corg_api/tests/markdown/alerts/Not after.html create mode 100644 c2corg_api/tests/markdown/alerts/Not after.md create mode 100644 c2corg_api/tests/markdown/alerts/Not before and not after.html create mode 100644 c2corg_api/tests/markdown/alerts/Not before and not after.md create mode 100644 c2corg_api/tests/markdown/alerts/Not before.html create mode 100644 c2corg_api/tests/markdown/alerts/Not before.md create mode 100644 c2corg_api/tests/markdown/alerts/Not stacked.html create mode 100644 c2corg_api/tests/markdown/alerts/Not stacked.md create mode 100644 c2corg_api/tests/markdown/alerts/Trailing spaces 1.html create mode 100644 c2corg_api/tests/markdown/alerts/Trailing spaces 1.md create mode 100644 c2corg_api/tests/markdown/alerts/Trailing spaces 2.html create mode 100644 c2corg_api/tests/markdown/alerts/Trailing spaces 2.md create mode 100644 c2corg_api/tests/markdown/alerts/Trailing spaces 3.html create mode 100644 c2corg_api/tests/markdown/alerts/Trailing spaces 3.md create mode 100644 c2corg_api/tests/markdown/alerts/Trailing spaces 4.html create mode 100644 c2corg_api/tests/markdown/alerts/Trailing spaces 4.md create mode 100644 c2corg_api/tests/markdown/alerts/Two lines.html create mode 100644 c2corg_api/tests/markdown/alerts/Two lines.md create mode 100644 c2corg_api/tests/markdown/alerts/Two paragraphs.html create mode 100644 c2corg_api/tests/markdown/alerts/Two paragraphs.md create mode 100644 c2corg_api/tests/markdown/alerts/alerts.html create mode 100644 c2corg_api/tests/markdown/alerts/alerts.md create mode 100644 c2corg_api/tests/markdown/alerts/images.html create mode 100644 c2corg_api/tests/markdown/alerts/images.md create mode 100644 c2corg_api/tests/markdown/alerts/inside lists.html create mode 100644 c2corg_api/tests/markdown/alerts/inside lists.md create mode 100644 c2corg_api/tests/markdown/alerts/inside quotes.html create mode 100644 c2corg_api/tests/markdown/alerts/inside quotes.md create mode 100644 c2corg_api/tests/markdown/alerts/lists.html create mode 100644 c2corg_api/tests/markdown/alerts/lists.md create mode 100644 c2corg_api/tests/markdown/alerts/not in code.html create mode 100644 c2corg_api/tests/markdown/alerts/not in code.md create mode 100644 c2corg_api/tests/markdown/alerts/quotes.html create mode 100644 c2corg_api/tests/markdown/alerts/quotes.md create mode 100644 c2corg_api/tests/markdown/emojis/code.html create mode 100644 c2corg_api/tests/markdown/emojis/code.md create mode 100644 c2corg_api/tests/markdown/emojis/simple emojis.html create mode 100644 c2corg_api/tests/markdown/emojis/simple emojis.md create mode 100644 c2corg_api/tests/markdown/generics/sample.html create mode 100644 c2corg_api/tests/markdown/generics/sample.md create mode 100644 c2corg_api/tests/markdown/headers/Emphasis on h5.html create mode 100644 c2corg_api/tests/markdown/headers/Emphasis on h5.md create mode 100644 c2corg_api/tests/markdown/headers/Emphasis.html create mode 100644 c2corg_api/tests/markdown/headers/Emphasis.md create mode 100644 c2corg_api/tests/markdown/headers/Strange title.html create mode 100644 c2corg_api/tests/markdown/headers/Strange title.md create mode 100644 c2corg_api/tests/markdown/headers/standard link.html create mode 100644 c2corg_api/tests/markdown/headers/standard link.md create mode 100644 c2corg_api/tests/markdown/headers/standard link2.html create mode 100644 c2corg_api/tests/markdown/headers/standard link2.md create mode 100644 c2corg_api/tests/markdown/headers/standard link3.html create mode 100644 c2corg_api/tests/markdown/headers/standard link3.md create mode 100644 c2corg_api/tests/markdown/headers/standard link4.html create mode 100644 c2corg_api/tests/markdown/headers/standard link4.md create mode 100644 c2corg_api/tests/markdown/headers/standard link5.html create mode 100644 c2corg_api/tests/markdown/headers/standard link5.md create mode 100644 c2corg_api/tests/markdown/headers/standard link6.html create mode 100644 c2corg_api/tests/markdown/headers/standard link6.md create mode 100644 c2corg_api/tests/markdown/headers/standard link7.html create mode 100644 c2corg_api/tests/markdown/headers/standard link7.md create mode 100644 c2corg_api/tests/markdown/headers/strange separator.html create mode 100644 c2corg_api/tests/markdown/headers/strange separator.md create mode 100644 c2corg_api/tests/markdown/headers/with id and emphasis.html create mode 100644 c2corg_api/tests/markdown/headers/with id and emphasis.md create mode 100644 c2corg_api/tests/markdown/headers/with id.html create mode 100644 c2corg_api/tests/markdown/headers/with id.md create mode 100644 c2corg_api/tests/markdown/headers/with node.html create mode 100644 c2corg_api/tests/markdown/headers/with node.md create mode 100644 c2corg_api/tests/markdown/img_tag/Do not parse.html create mode 100644 c2corg_api/tests/markdown/img_tag/Do not parse.md create mode 100644 c2corg_api/tests/markdown/img_tag/Inside a paragraph, do not parse.html create mode 100644 c2corg_api/tests/markdown/img_tag/Inside a paragraph, do not parse.md create mode 100644 c2corg_api/tests/markdown/img_tag/basic.html create mode 100644 c2corg_api/tests/markdown/img_tag/basic.md create mode 100644 c2corg_api/tests/markdown/img_tag/even new line changes nothing.html create mode 100644 c2corg_api/tests/markdown/img_tag/even new line changes nothing.md create mode 100644 c2corg_api/tests/markdown/img_tag/figure after p.html create mode 100644 c2corg_api/tests/markdown/img_tag/figure after p.md create mode 100644 c2corg_api/tests/markdown/img_tag/figure between p, and with empty lines.html create mode 100644 c2corg_api/tests/markdown/img_tag/figure between p, and with empty lines.md create mode 100644 c2corg_api/tests/markdown/img_tag/figure between p.html create mode 100644 c2corg_api/tests/markdown/img_tag/figure between p.md create mode 100644 c2corg_api/tests/markdown/img_tag/img.html create mode 100644 c2corg_api/tests/markdown/img_tag/img.md create mode 100644 c2corg_api/tests/markdown/img_tag/two images, two figures.html create mode 100644 c2corg_api/tests/markdown/img_tag/two images, two figures.md create mode 100644 c2corg_api/tests/markdown/links/autolink1.html create mode 100644 c2corg_api/tests/markdown/links/autolink1.md create mode 100644 c2corg_api/tests/markdown/links/autolink2.html create mode 100644 c2corg_api/tests/markdown/links/autolink2.md create mode 100644 c2corg_api/tests/markdown/links/autolink3.html create mode 100644 c2corg_api/tests/markdown/links/autolink3.md create mode 100644 c2corg_api/tests/markdown/links/autolink4.html create mode 100644 c2corg_api/tests/markdown/links/autolink4.md create mode 100644 c2corg_api/tests/markdown/links/autolink5.html create mode 100644 c2corg_api/tests/markdown/links/autolink5.md create mode 100644 c2corg_api/tests/markdown/links/autolink6.html create mode 100644 c2corg_api/tests/markdown/links/autolink6.md create mode 100644 c2corg_api/tests/markdown/links/wikilink-anchor.html create mode 100644 c2corg_api/tests/markdown/links/wikilink-anchor.md create mode 100644 c2corg_api/tests/markdown/links/wikilink-bad-anchor.html create mode 100644 c2corg_api/tests/markdown/links/wikilink-bad-anchor.md create mode 100644 c2corg_api/tests/markdown/links/wikilink-bad-id.html create mode 100644 c2corg_api/tests/markdown/links/wikilink-bad-id.md create mode 100644 c2corg_api/tests/markdown/links/wikilink-bad-lanf.html create mode 100644 c2corg_api/tests/markdown/links/wikilink-bad-lanf.md create mode 100644 c2corg_api/tests/markdown/links/wikilink-bad-slug.html create mode 100644 c2corg_api/tests/markdown/links/wikilink-bad-slug.md create mode 100644 c2corg_api/tests/markdown/links/wikilink-lang.html create mode 100644 c2corg_api/tests/markdown/links/wikilink-lang.md create mode 100644 c2corg_api/tests/markdown/links/wikilink-simple.html create mode 100644 c2corg_api/tests/markdown/links/wikilink-simple.md create mode 100644 c2corg_api/tests/markdown/links/wikilink-slug.html create mode 100644 c2corg_api/tests/markdown/links/wikilink-slug.md create mode 100644 c2corg_api/tests/markdown/links/wikilink-whatever.html create mode 100644 c2corg_api/tests/markdown/links/wikilink-whatever.md create mode 100644 c2corg_api/tests/markdown/links/wikilinks.html create mode 100644 c2corg_api/tests/markdown/links/wikilinks.md create mode 100644 c2corg_api/tests/markdown/links/wikilinks_with_underscore.html create mode 100644 c2corg_api/tests/markdown/links/wikilinks_with_underscore.md create mode 100644 c2corg_api/tests/markdown/ltags/Absolute numbering.html create mode 100644 c2corg_api/tests/markdown/ltags/Absolute numbering.md create mode 100644 c2corg_api/tests/markdown/ltags/Does it see all.html create mode 100644 c2corg_api/tests/markdown/ltags/Does it see all.md create mode 100644 c2corg_api/tests/markdown/ltags/Format in the middle.html create mode 100644 c2corg_api/tests/markdown/ltags/Format in the middle.md create mode 100644 c2corg_api/tests/markdown/ltags/Header and simple Ltags.html create mode 100644 c2corg_api/tests/markdown/ltags/Header and simple Ltags.md create mode 100644 c2corg_api/tests/markdown/ltags/L# in cell.html create mode 100644 c2corg_api/tests/markdown/ltags/L# in cell.md create mode 100644 c2corg_api/tests/markdown/ltags/LTag containing a wikilink.html create mode 100644 c2corg_api/tests/markdown/ltags/LTag containing a wikilink.md create mode 100644 c2corg_api/tests/markdown/ltags/LTags and RTags separated by text.html create mode 100644 c2corg_api/tests/markdown/ltags/LTags and RTags separated by text.md create mode 100644 c2corg_api/tests/markdown/ltags/Mal formated first cell #2.html create mode 100644 c2corg_api/tests/markdown/ltags/Mal formated first cell #2.md create mode 100644 c2corg_api/tests/markdown/ltags/Mal formated first cell #3.html create mode 100644 c2corg_api/tests/markdown/ltags/Mal formated first cell #3.md create mode 100644 c2corg_api/tests/markdown/ltags/Mal formated first cell.html create mode 100644 c2corg_api/tests/markdown/ltags/Mal formated first cell.md create mode 100644 c2corg_api/tests/markdown/ltags/Simple LTag.html create mode 100644 c2corg_api/tests/markdown/ltags/Simple LTag.md create mode 100644 c2corg_api/tests/markdown/ltags/Text in the middle.html create mode 100644 c2corg_api/tests/markdown/ltags/Text in the middle.md create mode 100644 c2corg_api/tests/markdown/ltags/Two LTags separated by text.html create mode 100644 c2corg_api/tests/markdown/ltags/Two LTags separated by text.md create mode 100644 c2corg_api/tests/markdown/ltags/Unsupported LTag.html create mode 100644 c2corg_api/tests/markdown/ltags/Unsupported LTag.md create mode 100644 c2corg_api/tests/markdown/ltags/absolutes with label.html create mode 100644 c2corg_api/tests/markdown/ltags/absolutes with label.md create mode 100644 c2corg_api/tests/markdown/ltags/absolutes without labels.html create mode 100644 c2corg_api/tests/markdown/ltags/absolutes without labels.md create mode 100644 c2corg_api/tests/markdown/ltags/middle numbering.html create mode 100644 c2corg_api/tests/markdown/ltags/middle numbering.md create mode 100644 c2corg_api/tests/markdown/ltags/raw table.html create mode 100644 c2corg_api/tests/markdown/ltags/raw table.md create mode 100644 c2corg_api/tests/markdown/ltags/strange spaces.html create mode 100644 c2corg_api/tests/markdown/ltags/strange spaces.md create mode 100644 c2corg_api/tests/markdown/ltags/tilde in a cell.html create mode 100644 c2corg_api/tests/markdown/ltags/tilde in a cell.md create mode 100644 c2corg_api/tests/markdown/ltags/very simple LTag.html create mode 100644 c2corg_api/tests/markdown/ltags/very simple LTag.md create mode 100644 c2corg_api/tests/markdown/ltags/wrong multi pitch.html create mode 100644 c2corg_api/tests/markdown/ltags/wrong multi pitch.md create mode 100644 c2corg_api/tests/markdown/nbsp/code.html create mode 100644 c2corg_api/tests/markdown/nbsp/code.md create mode 100644 c2corg_api/tests/markdown/nbsp/main.html create mode 100644 c2corg_api/tests/markdown/nbsp/main.md create mode 100644 c2corg_api/tests/markdown/nbsp/narrow unbreakable spaces.html create mode 100644 c2corg_api/tests/markdown/nbsp/narrow unbreakable spaces.md create mode 100644 c2corg_api/tests/markdown/nbsp/with_inline.html create mode 100644 c2corg_api/tests/markdown/nbsp/with_inline.md create mode 100644 c2corg_api/tests/markdown/ptag/base.html create mode 100644 c2corg_api/tests/markdown/ptag/base.md create mode 100644 c2corg_api/tests/markdown/test_exceptions.py create mode 100644 c2corg_api/tests/markdown/test_format.py create mode 100644 c2corg_api/tests/markdown/toc/Not emphasis.html create mode 100644 c2corg_api/tests/markdown/toc/Not emphasis.md create mode 100644 c2corg_api/tests/markdown/toc/id.html create mode 100644 c2corg_api/tests/markdown/toc/id.md create mode 100644 c2corg_api/tests/markdown/toc/not toc.html create mode 100644 c2corg_api/tests/markdown/toc/not toc.md create mode 100644 c2corg_api/tests/markdown/toc/toc 2 and 3, but not 4.html create mode 100644 c2corg_api/tests/markdown/toc/toc 2 and 3, but not 4.md create mode 100644 c2corg_api/tests/markdown/toc/toc 2 and 3.html create mode 100644 c2corg_api/tests/markdown/toc/toc 2 and 3.md create mode 100644 c2corg_api/tests/markdown/toc/toc.html create mode 100644 c2corg_api/tests/markdown/toc/toc.md create mode 100644 c2corg_api/tests/markdown/toc/weird 1.html create mode 100644 c2corg_api/tests/markdown/toc/weird 1.md create mode 100644 c2corg_api/tests/markdown/toc/weird 2.html create mode 100644 c2corg_api/tests/markdown/toc/weird 2.md create mode 100644 c2corg_api/tests/markdown/toc/weird 3.html create mode 100644 c2corg_api/tests/markdown/toc/weird 3.md create mode 100644 c2corg_api/tests/markdown/toc/weird 4.html create mode 100644 c2corg_api/tests/markdown/toc/weird 4.md create mode 100644 c2corg_api/tests/markdown/toc/weird 5.html create mode 100644 c2corg_api/tests/markdown/toc/weird 5.md create mode 100644 c2corg_api/tests/markdown/video/Vimeo.html create mode 100644 c2corg_api/tests/markdown/video/Vimeo.md create mode 100644 c2corg_api/tests/markdown/video/dailymotion short.html create mode 100644 c2corg_api/tests/markdown/video/dailymotion short.md create mode 100644 c2corg_api/tests/markdown/video/dailymotion.html create mode 100644 c2corg_api/tests/markdown/video/dailymotion.md create mode 100644 c2corg_api/tests/markdown/video/not valid url.html create mode 100644 c2corg_api/tests/markdown/video/not valid url.md create mode 100644 c2corg_api/tests/markdown/video/youtube short.html create mode 100644 c2corg_api/tests/markdown/video/youtube short.md create mode 100644 c2corg_api/tests/markdown/video/youtube.html create mode 100644 c2corg_api/tests/markdown/video/youtube.md create mode 100644 c2corg_api/tests/markdown/weirds/bleach bug.html create mode 100644 c2corg_api/tests/markdown/weirds/bleach bug.md create mode 100644 c2corg_api/tests/markdown/weirds/markdwon bug.html create mode 100644 c2corg_api/tests/markdown/weirds/markdwon bug.md diff --git a/c2corg_api/markdown/README.md b/c2corg_api/markdown/README.md new file mode 100644 index 000000000..6ca16834f --- /dev/null +++ b/c2corg_api/markdown/README.md @@ -0,0 +1,25 @@ +# Parsing the custom formating syntax of camptocamp.org + +## Syntax + +Camptocamp.org markdown to format the documents text attributes. It uses base features of [Python-Markdown](https://github.com/waylan/Python-Markdown). + +Upon these features, other custom tags are added: + +* LTag `L# | 6a | tremendous pitch` +* Emojis `:smile:` +* images `[img=123]Legend[/img]` +* toc `[toc]` +* alerts `!!!! This is an alert banner` +* wikilinks `[[routes/123|Walker ridge]]` +* custom headers `## Approach # 10 mn` +* ptag (hard new line) `[p]` +* video `[video]https://youtube.com/123[/video]` + +## Sanitizer + +Output is cleaned from any XSS injection using [Mozilla Bleach](https://github.com/mozilla/bleach) + +## Rialability + +This parser has been tested and fuzzed (~100,000,000 tests). Issues have also been found in python markdown and bleach: [1](https://github.com/mozilla/bleach/issues/352), [2](https://github.com/Python-Markdown/markdown/issues/643), [3](https://github.com/Python-Markdown/markdown/issues/640) and [4](https://github.com/Python-Markdown/markdown/issues/639) :sunglasses:. diff --git a/c2corg_api/markdown/__init__.py b/c2corg_api/markdown/__init__.py new file mode 100644 index 000000000..5db320275 --- /dev/null +++ b/c2corg_api/markdown/__init__.py @@ -0,0 +1,184 @@ +import markdown +import bleach +import binascii +import os +from threading import RLock + +from c2corg_api.markdown.wikilinks import C2CWikiLinkExtension +from c2corg_api.markdown.img import C2CImageExtension +from c2corg_api.markdown.video import C2CVideoExtension +from c2corg_api.markdown.ltag import C2CLTagExtension +from c2corg_api.markdown.header import C2CHeaderExtension +from c2corg_api.markdown.ptag import C2CPTagExtension +from c2corg_api.markdown.alerts import AlertExtension +from c2corg_api.markdown.toc import C2CTocExtension +from c2corg_api.markdown.emojis import C2CEmojiExtension +from c2corg_api.markdown.nbsp import C2CNbspExtension +from markdown.extensions.nl2br import Nl2BrExtension + + +def _get_secret(): + return binascii.hexlify(os.urandom(32)).decode('ascii') + + +_PARSER_EXCEPTION_MESSAGE = """ +
+Parser error, please send a mail to +dev@camptocamp.org +or post a message on + +forum. +
+""" # noqa + +# RLock because this lock can be released +# only by the thread who acquires it. +_parser_lock = RLock() + +_markdown_parser = None +_cleaner = None +_iframe_secret_tag = "iframe_" + _get_secret() + +""" +_***_secret_tag is used as a private key to replace critical HTML node and +attributes. The key point is this : the parser will use them. bleach will +remove all critical nodes. Then, a very end parser replace secret_tag by good +HTML node/attribute + +PEP 506 : +os.urandom is the safe way to generate private data, where random module only +generate random data without entropy. Hexlify() and ascii() convert it to +lower case string. Once V6_ui will be into python 3.6 or higher, we will use +secrets module. + +How to hack C2C ? if you want to inject an iframe, you will need to know the +value of _iframe_secret_tag present into server memory. +""" + + +def _get_cleaner(): + global _cleaner + + if not _cleaner: + allowed_tags = bleach.ALLOWED_TAGS + [ + # headers + "h1", "h2", "h3", "h4", "h5", "h6", + + # blocks + "div", "p", "pre", "hr", "center", + + # inline nodes + "span", "br", "sub", "sup", "s", "del", "ins", "small", + + # images + "figure", "img", "figcaption", + + _iframe_secret_tag, + + # tables + "table", "tr", "td", "th", "tbody" + ] + + allowed_attributes = dict(bleach.ALLOWED_ATTRIBUTES) + allowed_extra_attributes = { + "a": [ + "c2c:role", + "c2c:document-type", + "c2c:document-id", + "c2c:lang", + "c2c:slug", + "c2c:anchor" + ], + "h1": ["id", "c2c:role"], + "h2": ["id", "c2c:role"], + "h3": ["id", "c2c:role"], + "h4": ["id", "c2c:role"], + "h5": ["id", "c2c:role"], + "h6": ["id", "c2c:role"], + "table": ["c2c:role"], + "div": ["class", "style", "c2c:role"], + "td": ["colspan"], + "span": ["class", "translate", "id", "c2c:role"], + _iframe_secret_tag: ["src"], + "figure": ["c2c:position", "c2c:role", "c2c:size"], + "img": [ + "alt", + "c2c:document-id", + "c2c:role", + "c2c:size", + "c2c:url-proxy", + "c2c:svg-name", + "c2c:emoji-db" + ], + } + + for key in allowed_extra_attributes: + if key not in allowed_attributes: + allowed_attributes[key] = [] + + allowed_attributes[key] += allowed_extra_attributes[key] + + _cleaner = bleach.Cleaner(tags=allowed_tags, + attributes=allowed_attributes, + styles=bleach.ALLOWED_STYLES + ["clear"], + protocols=bleach.ALLOWED_PROTOCOLS, + strip=False, + strip_comments=True) + + return _cleaner + + +def _get_markdown_parser(): + global _markdown_parser + if not _markdown_parser: + extensions = [ + C2CWikiLinkExtension(), + C2CImageExtension(), + Nl2BrExtension(), + C2CTocExtension(marker='[toc]', baselevel=2), + C2CVideoExtension(iframe_secret_tag=_iframe_secret_tag), + C2CLTagExtension(), + C2CHeaderExtension(), + C2CPTagExtension(), + AlertExtension(), + C2CEmojiExtension(), + C2CNbspExtension(), + ] + _markdown_parser = markdown.Markdown(output_format='xhtml5', + extensions=extensions, + enable_attributes=False) + return _markdown_parser + + +def parse_code(text): + """ + Get markdown, and returns HTML. + This function is thread-safe + """ + + # we need parsing to be thread safe because + # L numbering, and Markdown() has internal global variables + + # for explanation about Lock context manager usage + # see https://docs.python.org/3/library/threading.html + # on paragraph 17.1.10 (with statement) + with _parser_lock: + parser = _get_markdown_parser() + cleaner = _get_cleaner() + + # reset parser state. Otherwise, internals parser cache grows + # indefinitely, and performance decreases over time + parser.reset() + + try: + text = parser.convert(text) + + # we keep clean function into thread safe part, + # because we are not sure of this function + text = cleaner.clean(text=text) + except: # noqa + text = _PARSER_EXCEPTION_MESSAGE + + text = text.replace(_iframe_secret_tag, "iframe") + + return text diff --git a/c2corg_api/markdown/alerts.py b/c2corg_api/markdown/alerts.py new file mode 100644 index 000000000..051a604c4 --- /dev/null +++ b/c2corg_api/markdown/alerts.py @@ -0,0 +1,73 @@ +from markdown.extensions import Extension +from markdown.blockprocessors import BlockProcessor +from markdown import util +import re + + +class AlertProcessor(BlockProcessor): + RE = re.compile(r'(^|\n)[ ]{0,3}(!{2,4})(([^!]|$).*)') + + roles = { + "!!": "info", + "!!!": "warning", + "!!!!": "danger", + } + + def test(self, parent, block): + return bool(self.RE.search(block)) + + def run(self, parent, blocks): + block = blocks.pop(0) + m = self.RE.search(block) + level = m.group(2) + tester = re.compile("^[ ]{0,3}" + level + "([^!]|$)") + + before = block[:m.start()] # Lines before blockquote + # Pass lines before alert banner + self.parser.parseBlocks(parent, [before]) + + after = block[m.start():].split('\n') + if len(after[0]) == 0: + after.pop(0) + + block = [] + + # get all lines starting with the same prefix + while len(after): + is_same_level = bool(tester.search(after[0])) + if is_same_level: + block.append(after.pop(0)) + else: + break + + # Remove `!!!` from begining of each line. + block = '\n'.join([self.clean(line) for line in block]) + + quote = util.etree.SubElement(parent, 'div') + quote.set("c2c:role", self.roles[level]) + # Recursively parse block with div as parent. + self.parser.parseChunk(quote, block) + + # and continue parsing next part of the block + self.parser.parseBlocks(parent, ["\n".join(after)]) + + def clean(self, line): + """ Remove ``!`` from beginning of a line. """ + m = self.RE.match(line) + if line.strip() in ("!!", "!!!", "!!!!"): + return "" + elif m: + return m.group(3) + else: + return line + + +class AlertExtension(Extension): + def extendMarkdown(self, md, md_globals): # noqa + md.parser.blockprocessors.add('c2calert', + AlertProcessor(md.parser), + "#{1,6})' + r'(?P
.*?)' + r'(?P#+[^#]*?)?' + r'(?P\{#[\w-]+\})?' + r'(\n|$)') + + def test(self, parent, block): + return bool(self.RE.search(block)) + + def run(self, parent, blocks): + block = blocks.pop(0) + m = self.RE.search(block) + if m: + before = block[:m.start()] # All lines before header + after = block[m.end():] # All lines after header + if before: + # As the header was not the first line of the block and the + # lines before the header must be parsed first, + # recursively parse this lines as a block. + self.parser.parseBlocks(parent, [before]) + # Create header using named groups from RE + h = util.etree.SubElement(parent, 'h%d' % len(m.group('level'))) + h.text = m.group('header').strip() + + if m.group("fixed_id"): + h.set('id', m.group("fixed_id")[2:-1]) + + if m.group('emphasis'): + emphasis_text = m.group('emphasis').strip("# ") + if len(emphasis_text) != 0: + emphasis = util.etree.SubElement(h, 'span') + emphasis.set('c2c:role', 'header-emphasis') + emphasis.text = ' ' + emphasis_text + + if after: + # Insert remaining lines as first block for future parsing. + blocks.insert(0, after) + else: # pragma: no cover + # This should never happen, but just in case... + logger.warn("We've got a problem header: %r" % block) + + +class C2CHeaderExtension(markdown.Extension): + def extendMarkdown(self, md, md_globals): # noqa + md.parser.blockprocessors.add( + 'header_emphasis', + C2CHeaderProcessor(md.parser), + "()(/)?]()?([/img])? +to advanced HTML img tags. +''' + +from markdown.extensions import Extension +from markdown.blockprocessors import BlockProcessor +from markdown.util import etree + +import re + +# \w\W pattern is a trick for capturing all, including new spaces +IMG_RE = r'(?:^|\n)\[img=(\d+)([a-z_ ]*)(/\]|\]([\w\W]*?)\[/img\])' + + +class C2CImageExtension(Extension): + def extendMarkdown(self, md, md_globals): # noqa + self.md = md + md.parser.blockprocessors.add('c2cimgblock', + C2CImageBlock(md.parser, + self.getConfigs()), + " (s0, s1), (s2, s3), (s4, s5), ... + """ + a = iter(iterable) + return zip(a, a) + + +def _get_ltag_pattern(): + """ + Build the big ugly fat regexp for L# numbering. It's based on named + patterns : (P?pattern) and decomposed part by part. + + Please have a look on + https://forum.camptocamp.org/t/question-l/207148/69 + """ + p = "(?P<{}>{})".format + + # small patterns used more than once + raw_label = r"[a-zA-Z'\"][a-zA-Z'\"\d_]*" + + # let's build multi pitch pattern, like L#1-2 or L#12bis-14 + multi_pitch_label = p("multi_pitch_label", raw_label) + first_offset = p("first_offset", r"\d+") + last_offset = p("last_offset", r"\d+") + first_pitch = p("first_pitch", first_offset + multi_pitch_label + "?") + last_pitch = p("last_pitch", last_offset) + multi_pitch = p("multi_pitch", first_pitch + "-" + last_pitch) + + # mono pitch, like L#, L#12 or L#13bis + mono_pitch_label = p("mono_pitch_label", raw_label) + mono_pitch_value = p("mono_pitch_value", r"\d*") + mono_pitch = p("mono_pitch", mono_pitch_value + mono_pitch_label + "?") + + numbering = p("numbering", multi_pitch + "|" + mono_pitch) + + text_in_the_middle = p("text_in_the_middle", "~") + header = p("header", "=") + + typ = p("type", "[LR]") + + text = "(" + header + "|" + text_in_the_middle + "|" + numbering + ")" + + return p("ltag", typ + "#" + text) + + +class LTagNumbering(object): + """ + The aim of this class is to store and handle everything about numbering. + This class replaces markdown L# values by numeric values, and changes + it's state if necessary. + + This class owns a one way switch called "supported", initially set to + True. If it sees an unsupported pattern, it toggles it to False and + convert any L# pattern to L#Whatever + """ + + # regular expression used to perform the syntax analysis + PATTERN = re.compile(_get_ltag_pattern()) + + # helper for final formatting + FORMAT = ('' + '{type}' + '{text}').format + FORMAT_UNMATCHED = '{}'.format + + def __init__(self, markdown): + + self.get_placeholder = markdown.htmlStash.store + + # Values for relative patterns + self.value = {"R": 0, "L": 0} + + # One way switch + self.supported = True + + # If no relative pattern is present, then labels are allowed + # As now, the only relative pattern handled is a simple L# + self.allow_labels = True + + # if numbering contains a label, then relatives patterns + # are no more allowed anymore + self.contains_label = False + + def handle_unmatched(self, match): + return self.get_placeholder(self.FORMAT_UNMATCHED(match.group(0))) + + def compute(self, markdown, row_type, is_first_cell): + """ + Replace all L# patterns by good numbering values. it tests that first + cell perfectly match pattern. If an error occurs or a unsupported + pattern is found, it will returns raw pattern inside a block + """ + if not markdown: + return markdown + + # test that first cell content perfectly match pattern + # it's caller roles to check there is only text in this cell + if is_first_cell and not self.PATTERN.fullmatch(markdown): + self.supported = False + + if not self.supported: + return self.PATTERN.sub(self.handle_unmatched, markdown) + + # this function does not belong to self, because it + # must access to row_type and is_first_cell + def handle_match(match): + + if match.group("header") is not None: # means L#= + result = "" if is_first_cell else match.group(0) + + elif match.group("text_in_the_middle") is not None: + result = match.group(0) + + elif match.group("multi_pitch") is not None: + result = self.handle_multipitch(match, is_first_cell) + + elif match.group("mono_pitch") is not None: + result = self.handle_monopitch(match, row_type, is_first_cell) + + else: + raise NotImplementedError("Should not happen!?") + + return self.get_placeholder(result) + + try: + return self.PATTERN.sub(handle_match, markdown) + + except (NotImplementedError, AssertionError): + self.supported = False + return self.PATTERN.sub(self.handle_unmatched, markdown) + + def compute_label(self, raw_label): + """ + Get L# label, and check supported use case + """ + + if raw_label is not None: + assert self.allow_labels, "Can't handle label" + + self.contains_label = True + else: + raw_label = "" + + return raw_label + + def handle_multipitch(self, match, is_first_cell): + """ + Can be : + + L#1-4 + L#1bis-4 + """ + label = self.compute_label(match.group("multi_pitch_label")) + + typ = match.group("type") + first_offset = match.group("first_offset") + last_offset = match.group("last_offset") + + if is_first_cell: # first cell impacts numbering + self.value[typ] = int(last_offset) + + text = "".join((first_offset, label, "-", last_offset, label)) + + return self.FORMAT(type=typ, text=text) + + def handle_monopitch(self, match, row_type, is_first_cell): + """ + Can be : + + L# + L#12 + L#13bis + """ + + label = self.compute_label(match.group("mono_pitch_label")) + typ = match.group("type") + value = match.group("mono_pitch_value") + + if value.isdigit(): + # Fixed number : L#12 + # and label : L#12bis + + if is_first_cell: # first cell impacts numbering + self.value[typ] = int(value) + + return self.FORMAT(type=typ, text=value + label) + + elif len(value) == 0: # Simple use case : L# + self.allow_labels = False + assert not self.contains_label, "Not yet supported" + + value = self.value[typ if is_first_cell else row_type] + + if is_first_cell: # first cell impacts numbering + value += 1 + self.value[typ] = value + + return self.FORMAT(type=typ, text=str(value)) + + else: + raise NotImplementedError("Should not happen") + + +class LTagProcessor(BlockProcessor): + """ + This process will render a L# block into a table. + It does NOT handle any numbering stuff, as this numbering is global, + and will be handled by TreeProcessor + """ + + RE_TESTER = re.compile(r"(?:^|\n) {0,3}([LR]#)") + RE_PIPE_SAVER = re.compile(r'(\|)(?![^|]*\]\])') + CELL_SEPARATOR = '__--|--__' + + def test(self, parent, block): + return bool(self.RE_TESTER.search(block)) + + def run(self, parent, blocks): + + # Split different L# blocks + rows = self.RE_TESTER.split(blocks.pop(0)) + + before_ltag = rows.pop(0) # First lines without L# are sent to parser + if len(before_ltag) != 0: + self.parser.parseBlocks(parent, [before_ltag]) + + # Build XML elements + table = etree.SubElement(parent, 'table', {'c2c:role': 'ltag', + 'class': 'ltag'}) + tbody = etree.SubElement(table, 'tbody') + + col_count = 0 + colspan_rows = [] + + # Build as list of LTagRow classes. + # pairwise is due to result of re.split() function : + # ["L#", content1, "L#, content2 ... + for tag, content in _pairwise(rows): + row = self._build_row(tag + content, tbody, colspan_rows) + col_count = max(col_count, len(row)) + + # Done at the very end, because column count isn't known before + for row in colspan_rows: + row[0].set('colspan', str(col_count)) + + def _build_row(self, markdown, tbody, colspan_rows): + """ + This function will split row's markdown into a list of cells, + and return row object + """ + + row = etree.SubElement(tbody, 'tr', {"tag": markdown[0]}) + marker = markdown[2:3] + + if marker == "~": # the pattern L#~ + cell = etree.SubElement(row, "td") + cell.text = markdown[3:].strip(" \n") + colspan_rows.append(row) + + else: + cell_node_name = "th" if marker == "=" else "td" # the pattern L#= + + # replace separator by cell_separator to protect links + markdown = self.RE_PIPE_SAVER.sub(self.CELL_SEPARATOR, markdown) + + # and split markdown + for cell_markdown in markdown.split(self.CELL_SEPARATOR): + cell = etree.SubElement(row, cell_node_name) + cell.text = cell_markdown.strip(" \n\xa0") + + return row + + +class LtagTreeprocessor(Treeprocessor): + """ + The post processor. It search for any L# pattern present in + table.ltag objects, and replace them with good numbering result + """ + + def run(self, root): + + numbering = LTagNumbering(self.markdown) + + def compute(node, first_cell): + if node.tag not in ("code", "pre"): + node.text = numbering.compute(node.text, row_type, first_cell) + + for child in node: + compute(child, False) + child.tail = numbering.compute(child.tail, row_type, False) + + for row in root.findall("table[@class='ltag']/tbody/tr"): + is_text_in_the_middle = row[0].get("colspan") is not None + + row_type = row.get("tag") + + for i, cell in enumerate(row): + is_first_cell = i == 0 and not is_text_in_the_middle + + if is_first_cell and len(cell) != 0: + numbering.supported = False + + compute(cell, is_first_cell) + + return root + + +class C2CLTagExtension(Extension): + """ Add tables to Markdown. """ + + def extendMarkdown(self, md, md_globals): # noqa + """ Add an instance of TableProcessor to BlockParser. """ + if '|' not in md.ESCAPED_CHARS: + md.ESCAPED_CHARS.append('|') + + md.parser.blockprocessors.add('ltag', + LTagProcessor(md.parser), + 'emphasis2') + + md.inlinePatterns.add('c2c_nnbsp', + NarrowNbspPattern(r'([\w\d] [;?!])', md), + '>emphasis2') + + +def makeExtension(*args, **kwargs): # noqa + return C2CNbspExtension(*args, **kwargs) diff --git a/c2corg_api/markdown/ptag.py b/c2corg_api/markdown/ptag.py new file mode 100644 index 000000000..a375af1c4 --- /dev/null +++ b/c2corg_api/markdown/ptag.py @@ -0,0 +1,43 @@ +''' +c2corg p Extension for Python-Markdown +============================================== + +Converts tags [p] to div with clear:both +''' + +from markdown.extensions import Extension +from markdown.blockprocessors import BlockProcessor +from markdown.util import etree +import re + +P_RE = r'(?:\n|^)\[p\](?:\n|$)' + + +class C2CPTagExtension(Extension): + def extendMarkdown(self, md, md_globals): # noqa + md.parser.blockprocessors.add('c2cptag', + C2CPTag(md.parser), + " +for documentation. + +Oringinal code Copyright 2008 [Jack Miller](http://codezen.org) + +All changes Copyright 2008-2014 The Python Markdown Project + +License: [BSD](http://www.opensource.org/licenses/bsd-license.php) + +Modified for C2C : remove title emphasis, and only include <4 levels +""" + +from markdown.extensions.toc import (TocExtension, TocTreeprocessor, + string_type, stashedHTML2text, + unique, nest_toc_tokens) + + +class C2CTocTreeprocessor(TocTreeprocessor): + # once https://github.com/Python-Markdown/markdown/issues/639 + # is fixed, you can remove this two function + + def iterparent(self, node): + ''' Iterator wrapper to get parent and child all at once. ''' + + # We do not allow the marker inside a header as that + # would causes an enless loop of placing a new TOC + # inside previously generated TOC. + for child in node: + if not self.header_rgx.match(child.tag) and \ + child.tag not in ['pre', 'code']: + yield node, child + for p, c in self.iterparent(child): + yield p, c + + def replace_marker(self, root, elem): + ''' Replace marker with elem. ''' + for (p, c) in self.iterparent(root): + text = ''.join(c.itertext()).strip() + if not text: + continue + + # To keep the output from screwing up the + # validation by putting a
inside of a

+ # we actually replace the

in its entirety. + if c.text and c.text.strip() == self.marker and len(c) == 0: + for i in range(len(p)): + if p[i] == c: + p[i] = elem + break + + def run(self, doc): + + def not_emphasis(elt): + return elt.attrib.get("c2c:role") != "header-emphasis" + + # Get a list of id attributes + used_ids = set() + for el in doc.iter(): + if "id" in el.attrib: + used_ids.add(el.attrib["id"]) + + toc_tokens = [] + for el in doc.iter(): + if isinstance(el.tag, string_type) and \ + self.header_rgx.match(el.tag): + self.set_level(el) + + # modification for camptocamp + # orginal line was : + # text = ''.join(el.itertext()).strip() + + text = ''.join([elt.text for elt in el.iter() + if elt.text and not_emphasis(elt)]) + + # Do not override pre-existing ids + if "id" not in el.attrib: + innertext = stashedHTML2text(text, self.markdown) + el.attrib["id"] = unique(self.slugify(innertext, self.sep), + used_ids) + + level = int(el.tag[-1]) + if level < 5: # test for camptocamp + toc_tokens.append({ + 'level': level, + 'id': el.attrib["id"], + 'name': text + }) + + if self.use_anchors: + self.add_anchor(el, el.attrib["id"]) + if self.use_permalinks: + self.add_permalink(el, el.attrib["id"]) + + div = self.build_toc_div(nest_toc_tokens(toc_tokens)) + div.attrib["c2c:role"] = "toc" + del div.attrib["class"] + if self.marker: + self.replace_marker(doc, div) + + # serialize and attach to markdown instance. + toc = self.markdown.serializer(div) + for pp in self.markdown.postprocessors.values(): + toc = pp.run(toc) + self.markdown.toc = toc + + +class C2CTocExtension(TocExtension): + TreeProcessorClass = C2CTocTreeprocessor + + +def makeExtension(*args, **kwargs): # noqa + return C2CTocExtension(*args, **kwargs) diff --git a/c2corg_api/markdown/video.py b/c2corg_api/markdown/video.py new file mode 100644 index 000000000..d5044e3a0 --- /dev/null +++ b/c2corg_api/markdown/video.py @@ -0,0 +1,107 @@ +''' +c2corg video Extension for Python-Markdown +============================================== + +Converts video tags to advanced HTML video tags. +''' + +from markdown.extensions import Extension +from markdown.blockprocessors import BlockProcessor +from markdown.util import etree +import re + + +class C2CVideoExtension(Extension): + def __init__(self, *args, **kwargs): + self._iframe_secret_tag = kwargs.pop("iframe_secret_tag") + super(C2CVideoExtension, self).__init__(*args, **kwargs) + + def extendMarkdown(self, md, md_globals): # noqa + + processors = md.parser.blockprocessors + + for processor in (C2CYoutubeVideoBlock, + C2CYoutubeShortVideoBlock, + C2CDailymotionVideoBlock, + C2CDailymotionShortVideoBlock, + C2CVimeoVideoBlock): + processors.add(processor.__name__, + processor(md.parser, self._iframe_secret_tag), + "label + +Inspired from https://github.com/waylan/Python-Markdown/blob/master +/markdown/extensions/wikilinks.py +''' + +from markdown.extensions import Extension +from markdown.inlinepatterns import Pattern +from markdown.util import etree + +# document_type/document_id(/lang(/slug))(#anchor) + +DOCUMENT_RE = r'(?P[a-z]+)/(?P\d+)' +LANG_SLUG_RE = r'(/(?P[a-z]{2})(/(?P[a-z0-9\-]+))?)?' +ANCHOR_RE = r'(#(?P[a-z0-9\-_]+))?' +LABEL_RE = r'(?P

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/Fat finger.md b/c2corg_api/tests/markdown/alerts/Fat finger.md new file mode 100644 index 000000000..08e98323b --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/Fat finger.md @@ -0,0 +1 @@ +!!!!! x \ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/Formats.html b/c2corg_api/tests/markdown/alerts/Formats.html new file mode 100644 index 000000000..3b372f612 --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/Formats.html @@ -0,0 +1,3 @@ +
+

format works greatly code

+
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/Formats.md b/c2corg_api/tests/markdown/alerts/Formats.md new file mode 100644 index 000000000..3310217af --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/Formats.md @@ -0,0 +1 @@ +!!! *format* **works** ***greatly*** `code` \ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/Not after.html b/c2corg_api/tests/markdown/alerts/Not after.html new file mode 100644 index 000000000..7c8b0cef5 --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/Not after.html @@ -0,0 +1,4 @@ +
+

a

+
+

a

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/Not after.md b/c2corg_api/tests/markdown/alerts/Not after.md new file mode 100644 index 000000000..f43bfbcc6 --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/Not after.md @@ -0,0 +1,2 @@ +!!!a +a \ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/Not before and not after.html b/c2corg_api/tests/markdown/alerts/Not before and not after.html new file mode 100644 index 000000000..bbe7d0c06 --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/Not before and not after.html @@ -0,0 +1,5 @@ +

a

+
+

a

+
+

a

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/Not before and not after.md b/c2corg_api/tests/markdown/alerts/Not before and not after.md new file mode 100644 index 000000000..bd4c0dd20 --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/Not before and not after.md @@ -0,0 +1,3 @@ +a +!!!a +a \ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/Not before.html b/c2corg_api/tests/markdown/alerts/Not before.html new file mode 100644 index 000000000..d157c82e6 --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/Not before.html @@ -0,0 +1,4 @@ +

a

+
+

a

+
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/Not before.md b/c2corg_api/tests/markdown/alerts/Not before.md new file mode 100644 index 000000000..97a17c15a --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/Not before.md @@ -0,0 +1,2 @@ +a +!!!a \ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/Not stacked.html b/c2corg_api/tests/markdown/alerts/Not stacked.html new file mode 100644 index 000000000..fad35065d --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/Not stacked.html @@ -0,0 +1,21 @@ +
+

Stacked

+
+
+

banners

+
+
+

must

+
+
+

not

+
+
+

be

+
+
+

merged

+
+
+

!

+
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/Not stacked.md b/c2corg_api/tests/markdown/alerts/Not stacked.md new file mode 100644 index 000000000..b79bf5e00 --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/Not stacked.md @@ -0,0 +1,7 @@ +!! Stacked +!!! banners +!! must +!!!! not +!!! be +!!!! merged +!! ! \ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/Trailing spaces 1.html b/c2corg_api/tests/markdown/alerts/Trailing spaces 1.html new file mode 100644 index 000000000..095bde8ec --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/Trailing spaces 1.html @@ -0,0 +1,3 @@ +
+

1

+
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/Trailing spaces 1.md b/c2corg_api/tests/markdown/alerts/Trailing spaces 1.md new file mode 100644 index 000000000..994e2a257 --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/Trailing spaces 1.md @@ -0,0 +1 @@ + !!! 1 \ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/Trailing spaces 2.html b/c2corg_api/tests/markdown/alerts/Trailing spaces 2.html new file mode 100644 index 000000000..1e3cce3a4 --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/Trailing spaces 2.html @@ -0,0 +1,3 @@ +
+

2

+
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/Trailing spaces 2.md b/c2corg_api/tests/markdown/alerts/Trailing spaces 2.md new file mode 100644 index 000000000..e68026f92 --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/Trailing spaces 2.md @@ -0,0 +1 @@ + !!! 2 \ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/Trailing spaces 3.html b/c2corg_api/tests/markdown/alerts/Trailing spaces 3.html new file mode 100644 index 000000000..d3f604f64 --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/Trailing spaces 3.html @@ -0,0 +1,3 @@ +
+

3

+
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/Trailing spaces 3.md b/c2corg_api/tests/markdown/alerts/Trailing spaces 3.md new file mode 100644 index 000000000..a15ff3132 --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/Trailing spaces 3.md @@ -0,0 +1 @@ + !!! 3 \ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/Trailing spaces 4.html b/c2corg_api/tests/markdown/alerts/Trailing spaces 4.html new file mode 100644 index 000000000..75d29969e --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/Trailing spaces 4.html @@ -0,0 +1,2 @@ +
!!!    4
+
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/Trailing spaces 4.md b/c2corg_api/tests/markdown/alerts/Trailing spaces 4.md new file mode 100644 index 000000000..9d2a34af1 --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/Trailing spaces 4.md @@ -0,0 +1 @@ + !!! 4 \ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/Two lines.html b/c2corg_api/tests/markdown/alerts/Two lines.html new file mode 100644 index 000000000..2b3ba3830 --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/Two lines.html @@ -0,0 +1,4 @@ +
+

a
+b

+
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/Two lines.md b/c2corg_api/tests/markdown/alerts/Two lines.md new file mode 100644 index 000000000..007a0b8db --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/Two lines.md @@ -0,0 +1,2 @@ +!!!a +!!!b \ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/Two paragraphs.html b/c2corg_api/tests/markdown/alerts/Two paragraphs.html new file mode 100644 index 000000000..d1e50487d --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/Two paragraphs.html @@ -0,0 +1,4 @@ +
+

a

+

b

+
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/Two paragraphs.md b/c2corg_api/tests/markdown/alerts/Two paragraphs.md new file mode 100644 index 000000000..2a928e184 --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/Two paragraphs.md @@ -0,0 +1,3 @@ +!!!a +!!! +!!!b \ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/alerts.html b/c2corg_api/tests/markdown/alerts/alerts.html new file mode 100644 index 000000000..0c1b2aab4 --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/alerts.html @@ -0,0 +1,9 @@ +
+

Information

+
+
+

Warning

+
+
+

Danger

+
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/alerts.md b/c2corg_api/tests/markdown/alerts/alerts.md new file mode 100644 index 000000000..f141ce327 --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/alerts.md @@ -0,0 +1,6 @@ +!!Information + +!!!Warning + +!!!!Danger + diff --git a/c2corg_api/tests/markdown/alerts/images.html b/c2corg_api/tests/markdown/alerts/images.html new file mode 100644 index 000000000..a721170f8 --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/images.html @@ -0,0 +1,3 @@ +
+
123
+
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/images.md b/c2corg_api/tests/markdown/alerts/images.md new file mode 100644 index 000000000..5da252ae9 --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/images.md @@ -0,0 +1 @@ +!!![img=123/] \ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/inside lists.html b/c2corg_api/tests/markdown/alerts/inside lists.html new file mode 100644 index 000000000..06df0724c --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/inside lists.html @@ -0,0 +1,5 @@ +
    +
  • +
    coucou
    +
  • +
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/inside lists.md b/c2corg_api/tests/markdown/alerts/inside lists.md new file mode 100644 index 000000000..d669af87b --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/inside lists.md @@ -0,0 +1 @@ +* !! coucou \ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/inside quotes.html b/c2corg_api/tests/markdown/alerts/inside quotes.html new file mode 100644 index 000000000..8bc07b575 --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/inside quotes.html @@ -0,0 +1,5 @@ +
+
+

coucou

+
+
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/inside quotes.md b/c2corg_api/tests/markdown/alerts/inside quotes.md new file mode 100644 index 000000000..61f033af8 --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/inside quotes.md @@ -0,0 +1 @@ +> !! coucou \ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/lists.html b/c2corg_api/tests/markdown/alerts/lists.html new file mode 100644 index 000000000..a5157347c --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/lists.html @@ -0,0 +1,6 @@ +
+
    +
  • also
  • +
  • lists
  • +
+
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/lists.md b/c2corg_api/tests/markdown/alerts/lists.md new file mode 100644 index 000000000..1a64fe9c5 --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/lists.md @@ -0,0 +1,2 @@ +!!!! * also +!!!! * lists \ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/not in code.html b/c2corg_api/tests/markdown/alerts/not in code.html new file mode 100644 index 000000000..e697cb6ab --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/not in code.html @@ -0,0 +1,2 @@ +
!!!! code
+
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/not in code.md b/c2corg_api/tests/markdown/alerts/not in code.md new file mode 100644 index 000000000..4f492a945 --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/not in code.md @@ -0,0 +1 @@ + !!!! code \ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/quotes.html b/c2corg_api/tests/markdown/alerts/quotes.html new file mode 100644 index 000000000..dce0cf24c --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/quotes.html @@ -0,0 +1,6 @@ +
+
+

also
+ quotes

+
+
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/alerts/quotes.md b/c2corg_api/tests/markdown/alerts/quotes.md new file mode 100644 index 000000000..3c7737ed5 --- /dev/null +++ b/c2corg_api/tests/markdown/alerts/quotes.md @@ -0,0 +1,2 @@ +!!!! > also +!!!! quotes \ No newline at end of file diff --git a/c2corg_api/tests/markdown/emojis/code.html b/c2corg_api/tests/markdown/emojis/code.html new file mode 100644 index 000000000..78dd710b8 --- /dev/null +++ b/c2corg_api/tests/markdown/emojis/code.html @@ -0,0 +1,3 @@ +

Do not parse inlines :smile: code, neither block :

+
:smile:
+
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/emojis/code.md b/c2corg_api/tests/markdown/emojis/code.md new file mode 100644 index 000000000..05a57a5e9 --- /dev/null +++ b/c2corg_api/tests/markdown/emojis/code.md @@ -0,0 +1,3 @@ +Do not parse inlines `:smile:` code, neither block : + + :smile: \ No newline at end of file diff --git a/c2corg_api/tests/markdown/emojis/simple emojis.html b/c2corg_api/tests/markdown/emojis/simple emojis.html new file mode 100644 index 000000000..0bb12c620 --- /dev/null +++ b/c2corg_api/tests/markdown/emojis/simple emojis.html @@ -0,0 +1,3 @@ +

Activity : :paragliding:
+base : 😄
+waypoint : :access:

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/emojis/simple emojis.md b/c2corg_api/tests/markdown/emojis/simple emojis.md new file mode 100644 index 000000000..d59576ed0 --- /dev/null +++ b/c2corg_api/tests/markdown/emojis/simple emojis.md @@ -0,0 +1,3 @@ +Activity : :paragliding: +base : :smile: +waypoint : :access: \ No newline at end of file diff --git a/c2corg_api/tests/markdown/generics/sample.html b/c2corg_api/tests/markdown/generics/sample.html new file mode 100644 index 000000000..576a0245b --- /dev/null +++ b/c2corg_api/tests/markdown/generics/sample.html @@ -0,0 +1,66 @@ +

[b]Old bold BBcode en gras[/b]
+old [url=http://example.com]bbcode link[/url]

+

wiki link before [[/whatever|another one]] that follows.
+Some bold text and italic and small text
+italic âccentuated content
+markdown link
+Use the printf() function.
+and
is allowed

+

address@example.com

+
image
image
+
+
+

[video]wrong url[/video]

+
+

quote

+
+
+

lists

+
    +
  • Here
  • +
  • is
      +
    • a
    • +
    +
  • +
  • list
  • +
+

and

+
    +
  • Another
  • +
  • list.
  • +
+

and

+
    +
  1. numbered list
  2. +
  3. with autonumber
  4. +
+

"Slope": > 30° and < 35°

+

Some pitches definition

+ + + + + + + + + + + + + +
L15bNice slab with a slightly harder move
L25aLightly protected, carrying a cam or two could help
+
+

quote

+
+
Code with <span>a span</span>
+Code with <patate>unknown tag</patate>
+
+<script> alert("beach") </script> + +

span

+

<patate>unknown tag</patate>

+<iframe>iframe</iframe> + +

a est superieur > à b

+

This is an example reference-style link.

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/generics/sample.md b/c2corg_api/tests/markdown/generics/sample.md new file mode 100644 index 000000000..9a6b8d0c2 --- /dev/null +++ b/c2corg_api/tests/markdown/generics/sample.md @@ -0,0 +1,64 @@ +[b]Old bold BBcode en gras[/b] +old [url=http://example.com]bbcode link[/url] + +[[waypoints/12345/fr/some-slug|wiki link]] before [[/whatever|another one]] that follows. +Some **bold text** and *italic* and small text +*italic âccentuated content* +[markdown link](https://example.com?a=b&c=d) +Use the `printf()` function. +and
is allowed + + + +[img=123]image[/img] + +[video]http://www.youtube.com/watch?v=qEpdQDqaQdo[/video] + +[video]wrong url[/video] + +> quote + +---- + +### lists + +* Here +* is + * a +* list + +and + +- Another +- list. + +and + +1. numbered list +* with autonumber + +"Slope": > 30° and < 35° + +Some pitches definition + +L# | 5b | Nice slab with a slightly harder move +L# | 5a | Lightly protected, carrying a cam or two could help + +> quote + + Code with a span + Code with unknown tag + + + +span + +unknown tag + + + +a est superieur > à b + +This is [an example][id] reference-style link. + +[id]: http://example.com/ "Optional Title Here" \ No newline at end of file diff --git a/c2corg_api/tests/markdown/headers/Emphasis on h5.html b/c2corg_api/tests/markdown/headers/Emphasis on h5.html new file mode 100644 index 000000000..525f609bf --- /dev/null +++ b/c2corg_api/tests/markdown/headers/Emphasis on h5.html @@ -0,0 +1 @@ +
Title emphasis
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/headers/Emphasis on h5.md b/c2corg_api/tests/markdown/headers/Emphasis on h5.md new file mode 100644 index 000000000..3fdfa7436 --- /dev/null +++ b/c2corg_api/tests/markdown/headers/Emphasis on h5.md @@ -0,0 +1 @@ +#### Title # emphasis \ No newline at end of file diff --git a/c2corg_api/tests/markdown/headers/Emphasis.html b/c2corg_api/tests/markdown/headers/Emphasis.html new file mode 100644 index 000000000..e8e0d5b86 --- /dev/null +++ b/c2corg_api/tests/markdown/headers/Emphasis.html @@ -0,0 +1 @@ +

Title emphasis

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/headers/Emphasis.md b/c2corg_api/tests/markdown/headers/Emphasis.md new file mode 100644 index 000000000..6d935ce45 --- /dev/null +++ b/c2corg_api/tests/markdown/headers/Emphasis.md @@ -0,0 +1 @@ +## Title # emphasis \ No newline at end of file diff --git a/c2corg_api/tests/markdown/headers/Strange title.html b/c2corg_api/tests/markdown/headers/Strange title.html new file mode 100644 index 000000000..9912f3a03 --- /dev/null +++ b/c2corg_api/tests/markdown/headers/Strange title.html @@ -0,0 +1 @@ +

Title with # inside emphasis

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/headers/Strange title.md b/c2corg_api/tests/markdown/headers/Strange title.md new file mode 100644 index 000000000..eade9f2e0 --- /dev/null +++ b/c2corg_api/tests/markdown/headers/Strange title.md @@ -0,0 +1 @@ +## Title with # inside #### emphasis \ No newline at end of file diff --git a/c2corg_api/tests/markdown/headers/standard link.html b/c2corg_api/tests/markdown/headers/standard link.html new file mode 100644 index 000000000..7def7a85b --- /dev/null +++ b/c2corg_api/tests/markdown/headers/standard link.html @@ -0,0 +1 @@ +

Title

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/headers/standard link.md b/c2corg_api/tests/markdown/headers/standard link.md new file mode 100644 index 000000000..127d3fc96 --- /dev/null +++ b/c2corg_api/tests/markdown/headers/standard link.md @@ -0,0 +1 @@ +## Title \ No newline at end of file diff --git a/c2corg_api/tests/markdown/headers/standard link2.html b/c2corg_api/tests/markdown/headers/standard link2.html new file mode 100644 index 000000000..7def7a85b --- /dev/null +++ b/c2corg_api/tests/markdown/headers/standard link2.html @@ -0,0 +1 @@ +

Title

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/headers/standard link2.md b/c2corg_api/tests/markdown/headers/standard link2.md new file mode 100644 index 000000000..2ea7981f2 --- /dev/null +++ b/c2corg_api/tests/markdown/headers/standard link2.md @@ -0,0 +1 @@ +## Title # \ No newline at end of file diff --git a/c2corg_api/tests/markdown/headers/standard link3.html b/c2corg_api/tests/markdown/headers/standard link3.html new file mode 100644 index 000000000..7def7a85b --- /dev/null +++ b/c2corg_api/tests/markdown/headers/standard link3.html @@ -0,0 +1 @@ +

Title

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/headers/standard link3.md b/c2corg_api/tests/markdown/headers/standard link3.md new file mode 100644 index 000000000..82da5c8b6 --- /dev/null +++ b/c2corg_api/tests/markdown/headers/standard link3.md @@ -0,0 +1 @@ +## Title ## \ No newline at end of file diff --git a/c2corg_api/tests/markdown/headers/standard link4.html b/c2corg_api/tests/markdown/headers/standard link4.html new file mode 100644 index 000000000..7def7a85b --- /dev/null +++ b/c2corg_api/tests/markdown/headers/standard link4.html @@ -0,0 +1 @@ +

Title

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/headers/standard link4.md b/c2corg_api/tests/markdown/headers/standard link4.md new file mode 100644 index 000000000..d25adee16 --- /dev/null +++ b/c2corg_api/tests/markdown/headers/standard link4.md @@ -0,0 +1 @@ +## Title ### \ No newline at end of file diff --git a/c2corg_api/tests/markdown/headers/standard link5.html b/c2corg_api/tests/markdown/headers/standard link5.html new file mode 100644 index 000000000..735f1c496 --- /dev/null +++ b/c2corg_api/tests/markdown/headers/standard link5.html @@ -0,0 +1 @@ +

Title

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/headers/standard link5.md b/c2corg_api/tests/markdown/headers/standard link5.md new file mode 100644 index 000000000..d6fb72430 --- /dev/null +++ b/c2corg_api/tests/markdown/headers/standard link5.md @@ -0,0 +1 @@ +### Title \ No newline at end of file diff --git a/c2corg_api/tests/markdown/headers/standard link6.html b/c2corg_api/tests/markdown/headers/standard link6.html new file mode 100644 index 000000000..9962c77fc --- /dev/null +++ b/c2corg_api/tests/markdown/headers/standard link6.html @@ -0,0 +1 @@ +
Title
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/headers/standard link6.md b/c2corg_api/tests/markdown/headers/standard link6.md new file mode 100644 index 000000000..933da60a6 --- /dev/null +++ b/c2corg_api/tests/markdown/headers/standard link6.md @@ -0,0 +1 @@ +#### Title \ No newline at end of file diff --git a/c2corg_api/tests/markdown/headers/standard link7.html b/c2corg_api/tests/markdown/headers/standard link7.html new file mode 100644 index 000000000..26df2b2e0 --- /dev/null +++ b/c2corg_api/tests/markdown/headers/standard link7.html @@ -0,0 +1 @@ +
Title
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/headers/standard link7.md b/c2corg_api/tests/markdown/headers/standard link7.md new file mode 100644 index 000000000..c274294b1 --- /dev/null +++ b/c2corg_api/tests/markdown/headers/standard link7.md @@ -0,0 +1 @@ +##### Title \ No newline at end of file diff --git a/c2corg_api/tests/markdown/headers/strange separator.html b/c2corg_api/tests/markdown/headers/strange separator.html new file mode 100644 index 000000000..e8e0d5b86 --- /dev/null +++ b/c2corg_api/tests/markdown/headers/strange separator.html @@ -0,0 +1 @@ +

Title emphasis

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/headers/strange separator.md b/c2corg_api/tests/markdown/headers/strange separator.md new file mode 100644 index 000000000..44f36f72b --- /dev/null +++ b/c2corg_api/tests/markdown/headers/strange separator.md @@ -0,0 +1 @@ +## Title #### emphasis \ No newline at end of file diff --git a/c2corg_api/tests/markdown/headers/with id and emphasis.html b/c2corg_api/tests/markdown/headers/with id and emphasis.html new file mode 100644 index 000000000..d2b9ec650 --- /dev/null +++ b/c2corg_api/tests/markdown/headers/with id and emphasis.html @@ -0,0 +1 @@ +

Title # x y

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/headers/with id and emphasis.md b/c2corg_api/tests/markdown/headers/with id and emphasis.md new file mode 100644 index 000000000..c1310331a --- /dev/null +++ b/c2corg_api/tests/markdown/headers/with id and emphasis.md @@ -0,0 +1 @@ +## Title # x # y {#coucou} \ No newline at end of file diff --git a/c2corg_api/tests/markdown/headers/with id.html b/c2corg_api/tests/markdown/headers/with id.html new file mode 100644 index 000000000..61441ea15 --- /dev/null +++ b/c2corg_api/tests/markdown/headers/with id.html @@ -0,0 +1 @@ +

Title

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/headers/with id.md b/c2corg_api/tests/markdown/headers/with id.md new file mode 100644 index 000000000..17c0d0e44 --- /dev/null +++ b/c2corg_api/tests/markdown/headers/with id.md @@ -0,0 +1 @@ +## Title {#coucou} \ No newline at end of file diff --git a/c2corg_api/tests/markdown/headers/with node.html b/c2corg_api/tests/markdown/headers/with node.html new file mode 100644 index 000000000..4d6a930e8 --- /dev/null +++ b/c2corg_api/tests/markdown/headers/with node.html @@ -0,0 +1 @@ +

Title :hiking:

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/headers/with node.md b/c2corg_api/tests/markdown/headers/with node.md new file mode 100644 index 000000000..ca9b989b3 --- /dev/null +++ b/c2corg_api/tests/markdown/headers/with node.md @@ -0,0 +1 @@ +## Title :hiking: \ No newline at end of file diff --git a/c2corg_api/tests/markdown/img_tag/Do not parse.html b/c2corg_api/tests/markdown/img_tag/Do not parse.html new file mode 100644 index 000000000..edf446b07 --- /dev/null +++ b/c2corg_api/tests/markdown/img_tag/Do not parse.html @@ -0,0 +1,3 @@ +

En code [img=123/].

+
 [img=123/]
+
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/img_tag/Do not parse.md b/c2corg_api/tests/markdown/img_tag/Do not parse.md new file mode 100644 index 000000000..4cd9d4d91 --- /dev/null +++ b/c2corg_api/tests/markdown/img_tag/Do not parse.md @@ -0,0 +1,3 @@ +En code `[img=123/]`. + + [img=123/] \ No newline at end of file diff --git a/c2corg_api/tests/markdown/img_tag/Inside a paragraph, do not parse.html b/c2corg_api/tests/markdown/img_tag/Inside a paragraph, do not parse.html new file mode 100644 index 000000000..4158fe4d7 --- /dev/null +++ b/c2corg_api/tests/markdown/img_tag/Inside a paragraph, do not parse.html @@ -0,0 +1 @@ +

a [img=123/] b

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/img_tag/Inside a paragraph, do not parse.md b/c2corg_api/tests/markdown/img_tag/Inside a paragraph, do not parse.md new file mode 100644 index 000000000..4b79a7d23 --- /dev/null +++ b/c2corg_api/tests/markdown/img_tag/Inside a paragraph, do not parse.md @@ -0,0 +1 @@ +a [img=123/] b \ No newline at end of file diff --git a/c2corg_api/tests/markdown/img_tag/basic.html b/c2corg_api/tests/markdown/img_tag/basic.html new file mode 100644 index 000000000..84863b7eb --- /dev/null +++ b/c2corg_api/tests/markdown/img_tag/basic.html @@ -0,0 +1 @@ +
123
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/img_tag/basic.md b/c2corg_api/tests/markdown/img_tag/basic.md new file mode 100644 index 000000000..bb07eb627 --- /dev/null +++ b/c2corg_api/tests/markdown/img_tag/basic.md @@ -0,0 +1 @@ +[img=123/] diff --git a/c2corg_api/tests/markdown/img_tag/even new line changes nothing.html b/c2corg_api/tests/markdown/img_tag/even new line changes nothing.html new file mode 100644 index 000000000..aeb2313fd --- /dev/null +++ b/c2corg_api/tests/markdown/img_tag/even new line changes nothing.html @@ -0,0 +1,2 @@ +
123
+
123
diff --git a/c2corg_api/tests/markdown/img_tag/even new line changes nothing.md b/c2corg_api/tests/markdown/img_tag/even new line changes nothing.md new file mode 100644 index 000000000..7a377eac1 --- /dev/null +++ b/c2corg_api/tests/markdown/img_tag/even new line changes nothing.md @@ -0,0 +1,2 @@ +[img=123/] +[img=123/] \ No newline at end of file diff --git a/c2corg_api/tests/markdown/img_tag/figure after p.html b/c2corg_api/tests/markdown/img_tag/figure after p.html new file mode 100644 index 000000000..9a04c20d0 --- /dev/null +++ b/c2corg_api/tests/markdown/img_tag/figure after p.html @@ -0,0 +1,2 @@ +

a

+
123
diff --git a/c2corg_api/tests/markdown/img_tag/figure after p.md b/c2corg_api/tests/markdown/img_tag/figure after p.md new file mode 100644 index 000000000..da966d019 --- /dev/null +++ b/c2corg_api/tests/markdown/img_tag/figure after p.md @@ -0,0 +1,2 @@ +a +[img=123/] \ No newline at end of file diff --git a/c2corg_api/tests/markdown/img_tag/figure between p, and with empty lines.html b/c2corg_api/tests/markdown/img_tag/figure between p, and with empty lines.html new file mode 100644 index 000000000..cbc2abfb2 --- /dev/null +++ b/c2corg_api/tests/markdown/img_tag/figure between p, and with empty lines.html @@ -0,0 +1,3 @@ +

a

+
123
+

b

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/img_tag/figure between p, and with empty lines.md b/c2corg_api/tests/markdown/img_tag/figure between p, and with empty lines.md new file mode 100644 index 000000000..2550bd3f3 --- /dev/null +++ b/c2corg_api/tests/markdown/img_tag/figure between p, and with empty lines.md @@ -0,0 +1,5 @@ +a + +[img=123/] + +b \ No newline at end of file diff --git a/c2corg_api/tests/markdown/img_tag/figure between p.html b/c2corg_api/tests/markdown/img_tag/figure between p.html new file mode 100644 index 000000000..cbc2abfb2 --- /dev/null +++ b/c2corg_api/tests/markdown/img_tag/figure between p.html @@ -0,0 +1,3 @@ +

a

+
123
+

b

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/img_tag/figure between p.md b/c2corg_api/tests/markdown/img_tag/figure between p.md new file mode 100644 index 000000000..236b412ae --- /dev/null +++ b/c2corg_api/tests/markdown/img_tag/figure between p.md @@ -0,0 +1,3 @@ +a +[img=123/] +b \ No newline at end of file diff --git a/c2corg_api/tests/markdown/img_tag/img.html b/c2corg_api/tests/markdown/img_tag/img.html new file mode 100644 index 000000000..810a790cd --- /dev/null +++ b/c2corg_api/tests/markdown/img_tag/img.html @@ -0,0 +1,2 @@ +

[img=123]strange

+

legend[/img]

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/img_tag/img.md b/c2corg_api/tests/markdown/img_tag/img.md new file mode 100644 index 000000000..31e44ef0b --- /dev/null +++ b/c2corg_api/tests/markdown/img_tag/img.md @@ -0,0 +1,3 @@ +[img=123]strange + +legend[/img] \ No newline at end of file diff --git a/c2corg_api/tests/markdown/img_tag/two images, two figures.html b/c2corg_api/tests/markdown/img_tag/two images, two figures.html new file mode 100644 index 000000000..aeb2313fd --- /dev/null +++ b/c2corg_api/tests/markdown/img_tag/two images, two figures.html @@ -0,0 +1,2 @@ +
123
+
123
diff --git a/c2corg_api/tests/markdown/img_tag/two images, two figures.md b/c2corg_api/tests/markdown/img_tag/two images, two figures.md new file mode 100644 index 000000000..0107fc4c4 --- /dev/null +++ b/c2corg_api/tests/markdown/img_tag/two images, two figures.md @@ -0,0 +1 @@ +[img=123/][img=123/] \ No newline at end of file diff --git a/c2corg_api/tests/markdown/links/autolink1.html b/c2corg_api/tests/markdown/links/autolink1.html new file mode 100644 index 000000000..0baa54776 --- /dev/null +++ b/c2corg_api/tests/markdown/links/autolink1.html @@ -0,0 +1 @@ +

A raw URL http://www.example.com in some text

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/links/autolink1.md b/c2corg_api/tests/markdown/links/autolink1.md new file mode 100644 index 000000000..c5189533a --- /dev/null +++ b/c2corg_api/tests/markdown/links/autolink1.md @@ -0,0 +1 @@ +A raw URL http://www.example.com in some text \ No newline at end of file diff --git a/c2corg_api/tests/markdown/links/autolink2.html b/c2corg_api/tests/markdown/links/autolink2.html new file mode 100644 index 000000000..368549ed7 --- /dev/null +++ b/c2corg_api/tests/markdown/links/autolink2.html @@ -0,0 +1 @@ +

A raw URL https://www.example.com in some text

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/links/autolink2.md b/c2corg_api/tests/markdown/links/autolink2.md new file mode 100644 index 000000000..1b6e64f54 --- /dev/null +++ b/c2corg_api/tests/markdown/links/autolink2.md @@ -0,0 +1 @@ +A raw URL https://www.example.com in some text \ No newline at end of file diff --git a/c2corg_api/tests/markdown/links/autolink3.html b/c2corg_api/tests/markdown/links/autolink3.html new file mode 100644 index 000000000..a760b6cca --- /dev/null +++ b/c2corg_api/tests/markdown/links/autolink3.html @@ -0,0 +1 @@ +

A raw URL www.example.com in some text

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/links/autolink3.md b/c2corg_api/tests/markdown/links/autolink3.md new file mode 100644 index 000000000..b12f2c225 --- /dev/null +++ b/c2corg_api/tests/markdown/links/autolink3.md @@ -0,0 +1 @@ +A raw URL www.example.com in some text \ No newline at end of file diff --git a/c2corg_api/tests/markdown/links/autolink4.html b/c2corg_api/tests/markdown/links/autolink4.html new file mode 100644 index 000000000..c296840c8 --- /dev/null +++ b/c2corg_api/tests/markdown/links/autolink4.html @@ -0,0 +1 @@ +

Already converted links such as a link are not impacted.

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/links/autolink4.md b/c2corg_api/tests/markdown/links/autolink4.md new file mode 100644 index 000000000..a2028fb20 --- /dev/null +++ b/c2corg_api/tests/markdown/links/autolink4.md @@ -0,0 +1 @@ +Already converted links such as a link are not impacted. \ No newline at end of file diff --git a/c2corg_api/tests/markdown/links/autolink5.html b/c2corg_api/tests/markdown/links/autolink5.html new file mode 100644 index 000000000..2ada622bd --- /dev/null +++ b/c2corg_api/tests/markdown/links/autolink5.html @@ -0,0 +1 @@ +

Even that one www.example.com is not impacted.

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/links/autolink5.md b/c2corg_api/tests/markdown/links/autolink5.md new file mode 100644 index 000000000..ef1a97b69 --- /dev/null +++ b/c2corg_api/tests/markdown/links/autolink5.md @@ -0,0 +1 @@ +Even that one www.example.com is not impacted. \ No newline at end of file diff --git a/c2corg_api/tests/markdown/links/autolink6.html b/c2corg_api/tests/markdown/links/autolink6.html new file mode 100644 index 000000000..b7afb4ef4 --- /dev/null +++ b/c2corg_api/tests/markdown/links/autolink6.html @@ -0,0 +1 @@ +

Here is a link-like in labels www.domain.fr and http://domain.fr.

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/links/autolink6.md b/c2corg_api/tests/markdown/links/autolink6.md new file mode 100644 index 000000000..5513f6dd8 --- /dev/null +++ b/c2corg_api/tests/markdown/links/autolink6.md @@ -0,0 +1 @@ +Here is a link-like in labels [www.domain.fr](http://domain.fr) and [http://domain.fr](http://domain.fr). diff --git a/c2corg_api/tests/markdown/links/wikilink-anchor.html b/c2corg_api/tests/markdown/links/wikilink-anchor.html new file mode 100644 index 000000000..8b3bbe7d8 --- /dev/null +++ b/c2corg_api/tests/markdown/links/wikilink-anchor.html @@ -0,0 +1 @@ +

anchor

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/links/wikilink-anchor.md b/c2corg_api/tests/markdown/links/wikilink-anchor.md new file mode 100644 index 000000000..4c85ef0b6 --- /dev/null +++ b/c2corg_api/tests/markdown/links/wikilink-anchor.md @@ -0,0 +1 @@ +[[articles/1234#anch-or|anchor]] \ No newline at end of file diff --git a/c2corg_api/tests/markdown/links/wikilink-bad-anchor.html b/c2corg_api/tests/markdown/links/wikilink-bad-anchor.html new file mode 100644 index 000000000..122904346 --- /dev/null +++ b/c2corg_api/tests/markdown/links/wikilink-bad-anchor.html @@ -0,0 +1 @@ +

[[articles/1234/fr#AnChor|bad anchor]]

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/links/wikilink-bad-anchor.md b/c2corg_api/tests/markdown/links/wikilink-bad-anchor.md new file mode 100644 index 000000000..69ebb4c75 --- /dev/null +++ b/c2corg_api/tests/markdown/links/wikilink-bad-anchor.md @@ -0,0 +1 @@ +[[articles/1234/fr#AnChor|bad anchor]] \ No newline at end of file diff --git a/c2corg_api/tests/markdown/links/wikilink-bad-id.html b/c2corg_api/tests/markdown/links/wikilink-bad-id.html new file mode 100644 index 000000000..b585f79ed --- /dev/null +++ b/c2corg_api/tests/markdown/links/wikilink-bad-id.html @@ -0,0 +1 @@ +

[[articles/id|bad id]]

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/links/wikilink-bad-id.md b/c2corg_api/tests/markdown/links/wikilink-bad-id.md new file mode 100644 index 000000000..e2ea32ecc --- /dev/null +++ b/c2corg_api/tests/markdown/links/wikilink-bad-id.md @@ -0,0 +1 @@ +[[articles/id|bad id]] \ No newline at end of file diff --git a/c2corg_api/tests/markdown/links/wikilink-bad-lanf.html b/c2corg_api/tests/markdown/links/wikilink-bad-lanf.html new file mode 100644 index 000000000..bb09aeb50 --- /dev/null +++ b/c2corg_api/tests/markdown/links/wikilink-bad-lanf.html @@ -0,0 +1 @@ +

[[articles/1234/a23|mini]]

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/links/wikilink-bad-lanf.md b/c2corg_api/tests/markdown/links/wikilink-bad-lanf.md new file mode 100644 index 000000000..9b067a9eb --- /dev/null +++ b/c2corg_api/tests/markdown/links/wikilink-bad-lanf.md @@ -0,0 +1 @@ +[[articles/1234/a23|mini]] \ No newline at end of file diff --git a/c2corg_api/tests/markdown/links/wikilink-bad-slug.html b/c2corg_api/tests/markdown/links/wikilink-bad-slug.html new file mode 100644 index 000000000..622386982 --- /dev/null +++ b/c2corg_api/tests/markdown/links/wikilink-bad-slug.html @@ -0,0 +1 @@ +

[[articles/1234/BAD-Slug|bad slug]]

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/links/wikilink-bad-slug.md b/c2corg_api/tests/markdown/links/wikilink-bad-slug.md new file mode 100644 index 000000000..7e12d30ee --- /dev/null +++ b/c2corg_api/tests/markdown/links/wikilink-bad-slug.md @@ -0,0 +1 @@ +[[articles/1234/BAD-Slug|bad slug]] \ No newline at end of file diff --git a/c2corg_api/tests/markdown/links/wikilink-lang.html b/c2corg_api/tests/markdown/links/wikilink-lang.html new file mode 100644 index 000000000..37b02e247 --- /dev/null +++ b/c2corg_api/tests/markdown/links/wikilink-lang.html @@ -0,0 +1 @@ +

lang

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/links/wikilink-lang.md b/c2corg_api/tests/markdown/links/wikilink-lang.md new file mode 100644 index 000000000..ea6072b6a --- /dev/null +++ b/c2corg_api/tests/markdown/links/wikilink-lang.md @@ -0,0 +1 @@ +[[articles/1234/eu|lang]] \ No newline at end of file diff --git a/c2corg_api/tests/markdown/links/wikilink-simple.html b/c2corg_api/tests/markdown/links/wikilink-simple.html new file mode 100644 index 000000000..cc907d805 --- /dev/null +++ b/c2corg_api/tests/markdown/links/wikilink-simple.html @@ -0,0 +1 @@ +

mini

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/links/wikilink-simple.md b/c2corg_api/tests/markdown/links/wikilink-simple.md new file mode 100644 index 000000000..0950efa11 --- /dev/null +++ b/c2corg_api/tests/markdown/links/wikilink-simple.md @@ -0,0 +1 @@ +[[articles/1234|mini]] \ No newline at end of file diff --git a/c2corg_api/tests/markdown/links/wikilink-slug.html b/c2corg_api/tests/markdown/links/wikilink-slug.html new file mode 100644 index 000000000..101680f69 --- /dev/null +++ b/c2corg_api/tests/markdown/links/wikilink-slug.html @@ -0,0 +1 @@ +

slug

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/links/wikilink-slug.md b/c2corg_api/tests/markdown/links/wikilink-slug.md new file mode 100644 index 000000000..9def942e0 --- /dev/null +++ b/c2corg_api/tests/markdown/links/wikilink-slug.md @@ -0,0 +1 @@ +[[articles/1234/en/sl-ug|slug]] \ No newline at end of file diff --git a/c2corg_api/tests/markdown/links/wikilink-whatever.html b/c2corg_api/tests/markdown/links/wikilink-whatever.html new file mode 100644 index 000000000..950121948 --- /dev/null +++ b/c2corg_api/tests/markdown/links/wikilink-whatever.html @@ -0,0 +1 @@ +

[[/whatever|whatever]]

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/links/wikilink-whatever.md b/c2corg_api/tests/markdown/links/wikilink-whatever.md new file mode 100644 index 000000000..d39545214 --- /dev/null +++ b/c2corg_api/tests/markdown/links/wikilink-whatever.md @@ -0,0 +1 @@ +[[/whatever|whatever]] \ No newline at end of file diff --git a/c2corg_api/tests/markdown/links/wikilinks.html b/c2corg_api/tests/markdown/links/wikilinks.html new file mode 100644 index 000000000..ee4c2a0a3 --- /dev/null +++ b/c2corg_api/tests/markdown/links/wikilinks.html @@ -0,0 +1 @@ +

Some text and a wiki link before [[/whatever|another one]] that follows.

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/links/wikilinks.md b/c2corg_api/tests/markdown/links/wikilinks.md new file mode 100644 index 000000000..508de405d --- /dev/null +++ b/c2corg_api/tests/markdown/links/wikilinks.md @@ -0,0 +1 @@ +Some text and a [[waypoints/12345/fr/some-slug|wiki link]] before [[/whatever|another one]] that follows. \ No newline at end of file diff --git a/c2corg_api/tests/markdown/links/wikilinks_with_underscore.html b/c2corg_api/tests/markdown/links/wikilinks_with_underscore.html new file mode 100644 index 000000000..46ea4ad70 --- /dev/null +++ b/c2corg_api/tests/markdown/links/wikilinks_with_underscore.html @@ -0,0 +1 @@ +

VTT

diff --git a/c2corg_api/tests/markdown/links/wikilinks_with_underscore.md b/c2corg_api/tests/markdown/links/wikilinks_with_underscore.md new file mode 100644 index 000000000..5cf13385a --- /dev/null +++ b/c2corg_api/tests/markdown/links/wikilinks_with_underscore.md @@ -0,0 +1 @@ +[[articles/922056/fr#mtb-exposition_rating|VTT]] \ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/Absolute numbering.html b/c2corg_api/tests/markdown/ltags/Absolute numbering.html new file mode 100644 index 000000000..7c4ed99e0 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/Absolute numbering.html @@ -0,0 +1,14 @@ + + + + + + + + + + + + + +
L15aL2 and L3 are joined to L1
L45b+Awesome pitch !
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/Absolute numbering.md b/c2corg_api/tests/markdown/ltags/Absolute numbering.md new file mode 100644 index 000000000..c58822e08 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/Absolute numbering.md @@ -0,0 +1,2 @@ +L# | 5a | L#2 and L#3 are joined to L# +L#4| 5b+ | Awesome pitch ! \ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/Does it see all.html b/c2corg_api/tests/markdown/ltags/Does it see all.html new file mode 100644 index 000000000..9b8042d73 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/Does it see all.html @@ -0,0 +1,12 @@ + + + + + + + + + + + +
L1L2x L1L1 xL1L#
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/Does it see all.md b/c2corg_api/tests/markdown/ltags/Does it see all.md new file mode 100644 index 000000000..724c1de63 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/Does it see all.md @@ -0,0 +1 @@ +L#1 | L#2 | **x** L# | L# **x** | **L#** | `L#` \ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/Format in the middle.html b/c2corg_api/tests/markdown/ltags/Format in the middle.html new file mode 100644 index 000000000..85aabd410 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/Format in the middle.html @@ -0,0 +1,7 @@ + + + + + + +
coucou
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/Format in the middle.md b/c2corg_api/tests/markdown/ltags/Format in the middle.md new file mode 100644 index 000000000..7f83eef25 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/Format in the middle.md @@ -0,0 +1 @@ +L#~ **coucou** \ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/Header and simple Ltags.html b/c2corg_api/tests/markdown/ltags/Header and simple Ltags.html new file mode 100644 index 000000000..0e617bf33 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/Header and simple Ltags.html @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + +
Numerotation
L11
L22
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/Header and simple Ltags.md b/c2corg_api/tests/markdown/ltags/Header and simple Ltags.md new file mode 100644 index 000000000..e81be4022 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/Header and simple Ltags.md @@ -0,0 +1,3 @@ +L#= | Numerotation +L# |1 +L#| 2 \ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/L# in cell.html b/c2corg_api/tests/markdown/ltags/L# in cell.html new file mode 100644 index 000000000..a2045eb37 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/L# in cell.html @@ -0,0 +1,10 @@ + + + + + + + + + +
L1L1-2,L3bis,L4bis,
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/L# in cell.md b/c2corg_api/tests/markdown/ltags/L# in cell.md new file mode 100644 index 000000000..f8a5dbc85 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/L# in cell.md @@ -0,0 +1 @@ +L#1 | L#1-2, | L#3bis, | L#4bis, \ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/LTag containing a wikilink.html b/c2corg_api/tests/markdown/ltags/LTag containing a wikilink.html new file mode 100644 index 000000000..1c1fa1dff --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/LTag containing a wikilink.html @@ -0,0 +1,12 @@ + + + + + + + + + + + +
L11
L22 text
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/LTag containing a wikilink.md b/c2corg_api/tests/markdown/ltags/LTag containing a wikilink.md new file mode 100644 index 000000000..9dc735211 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/LTag containing a wikilink.md @@ -0,0 +1,2 @@ +L# |1 +L#| 2 [[waypoints/106822|text]] \ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/LTags and RTags separated by text.html b/c2corg_api/tests/markdown/ltags/LTags and RTags separated by text.html new file mode 100644 index 000000000..a8ca431a6 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/LTags and RTags separated by text.html @@ -0,0 +1,26 @@ +

Hello

+ + + + + + + + + + + +
L11
L22 then R2
+

Great !

+ + + + + + + + + + + +
R11
R22
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/LTags and RTags separated by text.md b/c2corg_api/tests/markdown/ltags/LTags and RTags separated by text.md new file mode 100644 index 000000000..ddcbe8db5 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/LTags and RTags separated by text.md @@ -0,0 +1,9 @@ +Hello + + L# |1 +L#| 2 then R# + +Great ! + +R# |1 +R#| 2 \ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/Mal formated first cell #2.html b/c2corg_api/tests/markdown/ltags/Mal formated first cell #2.html new file mode 100644 index 000000000..1d94a22ba --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/Mal formated first cell #2.html @@ -0,0 +1,8 @@ + + + + + + + +
L#1 -x
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/Mal formated first cell #2.md b/c2corg_api/tests/markdown/ltags/Mal formated first cell #2.md new file mode 100644 index 000000000..73a7e11ad --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/Mal formated first cell #2.md @@ -0,0 +1 @@ +L#1 - | x \ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/Mal formated first cell #3.html b/c2corg_api/tests/markdown/ltags/Mal formated first cell #3.html new file mode 100644 index 000000000..2c2aa8947 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/Mal formated first cell #3.html @@ -0,0 +1,8 @@ + + + + + + + +
L#1 -x
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/Mal formated first cell #3.md b/c2corg_api/tests/markdown/ltags/Mal formated first cell #3.md new file mode 100644 index 000000000..d4cf87226 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/Mal formated first cell #3.md @@ -0,0 +1 @@ +L#1 **-** | x \ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/Mal formated first cell.html b/c2corg_api/tests/markdown/ltags/Mal formated first cell.html new file mode 100644 index 000000000..4a3308a9c --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/Mal formated first cell.html @@ -0,0 +1,8 @@ + + + + + + + +
L# -x
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/Mal formated first cell.md b/c2corg_api/tests/markdown/ltags/Mal formated first cell.md new file mode 100644 index 000000000..1ab1243af --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/Mal formated first cell.md @@ -0,0 +1 @@ +L# - | x \ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/Simple LTag.html b/c2corg_api/tests/markdown/ltags/Simple LTag.html new file mode 100644 index 000000000..c7c1394ec --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/Simple LTag.html @@ -0,0 +1,12 @@ + + + + + + + + + + + +
L11
L22
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/Simple LTag.md b/c2corg_api/tests/markdown/ltags/Simple LTag.md new file mode 100644 index 000000000..ee803cc4a --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/Simple LTag.md @@ -0,0 +1,2 @@ +L# |1 +L#| 2 \ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/Text in the middle.html b/c2corg_api/tests/markdown/ltags/Text in the middle.html new file mode 100644 index 000000000..7fdbabd70 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/Text in the middle.html @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + +
L11
text in
+the middle
L22
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/Text in the middle.md b/c2corg_api/tests/markdown/ltags/Text in the middle.md new file mode 100644 index 000000000..1dafcffa6 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/Text in the middle.md @@ -0,0 +1,4 @@ +L# | 1 +L#~ text in +the middle +L# | 2 \ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/Two LTags separated by text.html b/c2corg_api/tests/markdown/ltags/Two LTags separated by text.html new file mode 100644 index 000000000..37c6ea378 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/Two LTags separated by text.html @@ -0,0 +1,26 @@ +

Hello

+ + + + + + + + + + + +
L11
L22
+

Great !

+ + + + + + + + + + + +
L33
L44
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/Two LTags separated by text.md b/c2corg_api/tests/markdown/ltags/Two LTags separated by text.md new file mode 100644 index 000000000..742fd7211 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/Two LTags separated by text.md @@ -0,0 +1,9 @@ +Hello + + L# |1 +L#| 2 + +Great ! + +L# |3 +L#| 4 \ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/Unsupported LTag.html b/c2corg_api/tests/markdown/ltags/Unsupported LTag.html new file mode 100644 index 000000000..a299da347 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/Unsupported LTag.html @@ -0,0 +1,16 @@ + + + + + + + +
L11
+ + + + + + + +
L#bis1bis
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/Unsupported LTag.md b/c2corg_api/tests/markdown/ltags/Unsupported LTag.md new file mode 100644 index 000000000..6112b0e00 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/Unsupported LTag.md @@ -0,0 +1,3 @@ +L# |1 + +L#bis| 1bis \ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/absolutes with label.html b/c2corg_api/tests/markdown/ltags/absolutes with label.html new file mode 100644 index 000000000..3415344d0 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/absolutes with label.html @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + +
L1
L3-4
L4bis
L6ter-9ter
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/absolutes with label.md b/c2corg_api/tests/markdown/ltags/absolutes with label.md new file mode 100644 index 000000000..c7ce870b0 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/absolutes with label.md @@ -0,0 +1,4 @@ +L#1 +L#3-4 +L#4bis +L#6ter-9 \ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/absolutes without labels.html b/c2corg_api/tests/markdown/ltags/absolutes without labels.html new file mode 100644 index 000000000..efde4b794 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/absolutes without labels.html @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + +
L1
L2
L3-4
L5
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/absolutes without labels.md b/c2corg_api/tests/markdown/ltags/absolutes without labels.md new file mode 100644 index 000000000..e773d7f0e --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/absolutes without labels.md @@ -0,0 +1,4 @@ +L#1 +L# +L#3-4 +L# \ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/middle numbering.html b/c2corg_api/tests/markdown/ltags/middle numbering.html new file mode 100644 index 000000000..c3e26f6b9 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/middle numbering.html @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + +
L1
R12
L1 R1 L#~
L12 R12 L#~
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/middle numbering.md b/c2corg_api/tests/markdown/ltags/middle numbering.md new file mode 100644 index 000000000..126752f49 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/middle numbering.md @@ -0,0 +1,4 @@ +L# +R#12 +L#~ L# R# L#~ +R#~ L# R# L#~ \ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/raw table.html b/c2corg_api/tests/markdown/ltags/raw table.html new file mode 100644 index 000000000..f01a17542 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/raw table.html @@ -0,0 +1,7 @@ + + + + + + +
coucou
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/raw table.md b/c2corg_api/tests/markdown/ltags/raw table.md new file mode 100644 index 000000000..f01a17542 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/raw table.md @@ -0,0 +1,7 @@ + + + + + + +
coucou
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/strange spaces.html b/c2corg_api/tests/markdown/ltags/strange spaces.html new file mode 100644 index 000000000..92a9903af --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/strange spaces.html @@ -0,0 +1,8 @@ + + + + + + + +
L1x
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/strange spaces.md b/c2corg_api/tests/markdown/ltags/strange spaces.md new file mode 100644 index 000000000..9bb013d06 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/strange spaces.md @@ -0,0 +1 @@ +L#   | x \ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/tilde in a cell.html b/c2corg_api/tests/markdown/ltags/tilde in a cell.html new file mode 100644 index 000000000..d8e007de3 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/tilde in a cell.html @@ -0,0 +1,8 @@ + + + + + + + +
L1L#~
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/tilde in a cell.md b/c2corg_api/tests/markdown/ltags/tilde in a cell.md new file mode 100644 index 000000000..d7b3b2256 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/tilde in a cell.md @@ -0,0 +1 @@ +L# | L#~ \ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/very simple LTag.html b/c2corg_api/tests/markdown/ltags/very simple LTag.html new file mode 100644 index 000000000..f0a885d17 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/very simple LTag.html @@ -0,0 +1,10 @@ + + + + + + + + + +
L1
L2
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/very simple LTag.md b/c2corg_api/tests/markdown/ltags/very simple LTag.md new file mode 100644 index 000000000..afb442ba5 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/very simple LTag.md @@ -0,0 +1,2 @@ +L# +L# \ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/wrong multi pitch.html b/c2corg_api/tests/markdown/ltags/wrong multi pitch.html new file mode 100644 index 000000000..5748ab348 --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/wrong multi pitch.html @@ -0,0 +1,7 @@ + + + + + + +
L#a-2
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/ltags/wrong multi pitch.md b/c2corg_api/tests/markdown/ltags/wrong multi pitch.md new file mode 100644 index 000000000..9e46a691e --- /dev/null +++ b/c2corg_api/tests/markdown/ltags/wrong multi pitch.md @@ -0,0 +1 @@ +L#a-2 \ No newline at end of file diff --git a/c2corg_api/tests/markdown/nbsp/code.html b/c2corg_api/tests/markdown/nbsp/code.html new file mode 100644 index 000000000..915ca76ab --- /dev/null +++ b/c2corg_api/tests/markdown/nbsp/code.html @@ -0,0 +1,3 @@ +

I know 123 cows

+
123 cows
+
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/nbsp/code.md b/c2corg_api/tests/markdown/nbsp/code.md new file mode 100644 index 000000000..4185edc6d --- /dev/null +++ b/c2corg_api/tests/markdown/nbsp/code.md @@ -0,0 +1,3 @@ +I know `123 cows` + + 123 cows \ No newline at end of file diff --git a/c2corg_api/tests/markdown/nbsp/main.html b/c2corg_api/tests/markdown/nbsp/main.html new file mode 100644 index 000000000..db15c3df5 --- /dev/null +++ b/c2corg_api/tests/markdown/nbsp/main.html @@ -0,0 +1 @@ +

I know 123 cows, I count 1, and 2 3 and I'm 3.

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/nbsp/main.md b/c2corg_api/tests/markdown/nbsp/main.md new file mode 100644 index 000000000..c53de16f9 --- /dev/null +++ b/c2corg_api/tests/markdown/nbsp/main.md @@ -0,0 +1 @@ +I know 123 cows, I count 1, and 2 3 and I'm 3. \ No newline at end of file diff --git a/c2corg_api/tests/markdown/nbsp/narrow unbreakable spaces.html b/c2corg_api/tests/markdown/nbsp/narrow unbreakable spaces.html new file mode 100644 index 000000000..fd7d657a4 --- /dev/null +++ b/c2corg_api/tests/markdown/nbsp/narrow unbreakable spaces.html @@ -0,0 +1 @@ +

a ! b ? c ;

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/nbsp/narrow unbreakable spaces.md b/c2corg_api/tests/markdown/nbsp/narrow unbreakable spaces.md new file mode 100644 index 000000000..387e07772 --- /dev/null +++ b/c2corg_api/tests/markdown/nbsp/narrow unbreakable spaces.md @@ -0,0 +1 @@ +a ! b ? c ; \ No newline at end of file diff --git a/c2corg_api/tests/markdown/nbsp/with_inline.html b/c2corg_api/tests/markdown/nbsp/with_inline.html new file mode 100644 index 000000000..2e23de6fc --- /dev/null +++ b/c2corg_api/tests/markdown/nbsp/with_inline.html @@ -0,0 +1 @@ +

some italic :

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/nbsp/with_inline.md b/c2corg_api/tests/markdown/nbsp/with_inline.md new file mode 100644 index 000000000..06354ca82 --- /dev/null +++ b/c2corg_api/tests/markdown/nbsp/with_inline.md @@ -0,0 +1 @@ +some _italic_ : \ No newline at end of file diff --git a/c2corg_api/tests/markdown/ptag/base.html b/c2corg_api/tests/markdown/ptag/base.html new file mode 100644 index 000000000..e071ab79c --- /dev/null +++ b/c2corg_api/tests/markdown/ptag/base.html @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/ptag/base.md b/c2corg_api/tests/markdown/ptag/base.md new file mode 100644 index 000000000..8115aad70 --- /dev/null +++ b/c2corg_api/tests/markdown/ptag/base.md @@ -0,0 +1 @@ +[p] \ No newline at end of file diff --git a/c2corg_api/tests/markdown/test_exceptions.py b/c2corg_api/tests/markdown/test_exceptions.py new file mode 100644 index 000000000..d90256802 --- /dev/null +++ b/c2corg_api/tests/markdown/test_exceptions.py @@ -0,0 +1,45 @@ +import unittest +import markdown +from markdown.extensions import Extension +from markdown.blockprocessors import BlockProcessor + +import c2corg_api.markdown as c2c_markdown + + +class FailingProcessor(BlockProcessor): + def test(self, parent, block): + return True + + def run(self, parent, blocks): + raise Exception("I should be invisible") + + +class FailingExtension(Extension): + def extendMarkdown(self, md, md_globals): # noqa + md.parser.blockprocessors.add('Failing', FailingProcessor(md.parser), + " + +
+

title 1 ## with strange emphasis

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/toc/Not emphasis.md b/c2corg_api/tests/markdown/toc/Not emphasis.md new file mode 100644 index 000000000..247e41652 --- /dev/null +++ b/c2corg_api/tests/markdown/toc/Not emphasis.md @@ -0,0 +1,2 @@ +[toc] +# title 1 ## with strange ## emphasis \ No newline at end of file diff --git a/c2corg_api/tests/markdown/toc/id.html b/c2corg_api/tests/markdown/toc/id.html new file mode 100644 index 000000000..e582128a5 --- /dev/null +++ b/c2corg_api/tests/markdown/toc/id.html @@ -0,0 +1,6 @@ +
+ +
+

title 1

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/toc/id.md b/c2corg_api/tests/markdown/toc/id.md new file mode 100644 index 000000000..48392aecd --- /dev/null +++ b/c2corg_api/tests/markdown/toc/id.md @@ -0,0 +1,2 @@ +[toc] +# title 1 {#coucou} \ No newline at end of file diff --git a/c2corg_api/tests/markdown/toc/not toc.html b/c2corg_api/tests/markdown/toc/not toc.html new file mode 100644 index 000000000..7fafa2c4b --- /dev/null +++ b/c2corg_api/tests/markdown/toc/not toc.html @@ -0,0 +1,2 @@ +

[toc]
+x

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/toc/not toc.md b/c2corg_api/tests/markdown/toc/not toc.md new file mode 100644 index 000000000..b7490eb62 --- /dev/null +++ b/c2corg_api/tests/markdown/toc/not toc.md @@ -0,0 +1,2 @@ +[toc] +x \ No newline at end of file diff --git a/c2corg_api/tests/markdown/toc/toc 2 and 3, but not 4.html b/c2corg_api/tests/markdown/toc/toc 2 and 3, but not 4.html new file mode 100644 index 000000000..c3740b5a6 --- /dev/null +++ b/c2corg_api/tests/markdown/toc/toc 2 and 3, but not 4.html @@ -0,0 +1,11 @@ +
+ +
+

title 2

+

title 3

+
title 4
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/toc/toc 2 and 3, but not 4.md b/c2corg_api/tests/markdown/toc/toc 2 and 3, but not 4.md new file mode 100644 index 000000000..964d0b119 --- /dev/null +++ b/c2corg_api/tests/markdown/toc/toc 2 and 3, but not 4.md @@ -0,0 +1,4 @@ +[toc] +## title 2 +### title 3 +#### title 4 \ No newline at end of file diff --git a/c2corg_api/tests/markdown/toc/toc 2 and 3.html b/c2corg_api/tests/markdown/toc/toc 2 and 3.html new file mode 100644 index 000000000..67e7b1a7e --- /dev/null +++ b/c2corg_api/tests/markdown/toc/toc 2 and 3.html @@ -0,0 +1,10 @@ +
+ +
+

title 2

+

title 3

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/toc/toc 2 and 3.md b/c2corg_api/tests/markdown/toc/toc 2 and 3.md new file mode 100644 index 000000000..3c312d9ad --- /dev/null +++ b/c2corg_api/tests/markdown/toc/toc 2 and 3.md @@ -0,0 +1,3 @@ +[toc] +## title 2 +### title 3 \ No newline at end of file diff --git a/c2corg_api/tests/markdown/toc/toc.html b/c2corg_api/tests/markdown/toc/toc.html new file mode 100644 index 000000000..18cb2e2b0 --- /dev/null +++ b/c2corg_api/tests/markdown/toc/toc.html @@ -0,0 +1,6 @@ +
+ +
+

title 1

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/toc/toc.md b/c2corg_api/tests/markdown/toc/toc.md new file mode 100644 index 000000000..564311998 --- /dev/null +++ b/c2corg_api/tests/markdown/toc/toc.md @@ -0,0 +1,2 @@ +[toc] +# title 1 \ No newline at end of file diff --git a/c2corg_api/tests/markdown/toc/weird 1.html b/c2corg_api/tests/markdown/toc/weird 1.html new file mode 100644 index 000000000..90c329a42 --- /dev/null +++ b/c2corg_api/tests/markdown/toc/weird 1.html @@ -0,0 +1 @@ +

[toc]

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/toc/weird 1.md b/c2corg_api/tests/markdown/toc/weird 1.md new file mode 100644 index 000000000..7b00d26cb --- /dev/null +++ b/c2corg_api/tests/markdown/toc/weird 1.md @@ -0,0 +1 @@ +# [toc] \ No newline at end of file diff --git a/c2corg_api/tests/markdown/toc/weird 2.html b/c2corg_api/tests/markdown/toc/weird 2.html new file mode 100644 index 000000000..723ce8981 --- /dev/null +++ b/c2corg_api/tests/markdown/toc/weird 2.html @@ -0,0 +1 @@ +

[toc]

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/toc/weird 2.md b/c2corg_api/tests/markdown/toc/weird 2.md new file mode 100644 index 000000000..320773509 --- /dev/null +++ b/c2corg_api/tests/markdown/toc/weird 2.md @@ -0,0 +1 @@ +# *[toc]* \ No newline at end of file diff --git a/c2corg_api/tests/markdown/toc/weird 3.html b/c2corg_api/tests/markdown/toc/weird 3.html new file mode 100644 index 000000000..723ce8981 --- /dev/null +++ b/c2corg_api/tests/markdown/toc/weird 3.html @@ -0,0 +1 @@ +

[toc]

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/toc/weird 3.md b/c2corg_api/tests/markdown/toc/weird 3.md new file mode 100644 index 000000000..a8ae4a545 --- /dev/null +++ b/c2corg_api/tests/markdown/toc/weird 3.md @@ -0,0 +1,2 @@ +*[toc]* += \ No newline at end of file diff --git a/c2corg_api/tests/markdown/toc/weird 4.html b/c2corg_api/tests/markdown/toc/weird 4.html new file mode 100644 index 000000000..bb8d0db7d --- /dev/null +++ b/c2corg_api/tests/markdown/toc/weird 4.html @@ -0,0 +1,6 @@ +
+ +
+

[toc]

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/toc/weird 4.md b/c2corg_api/tests/markdown/toc/weird 4.md new file mode 100644 index 000000000..4698b4b9c --- /dev/null +++ b/c2corg_api/tests/markdown/toc/weird 4.md @@ -0,0 +1,2 @@ +[toc] +# [toc] \ No newline at end of file diff --git a/c2corg_api/tests/markdown/toc/weird 5.html b/c2corg_api/tests/markdown/toc/weird 5.html new file mode 100644 index 000000000..b18c10e78 --- /dev/null +++ b/c2corg_api/tests/markdown/toc/weird 5.html @@ -0,0 +1,6 @@ +

[toc]

+
+ +
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/toc/weird 5.md b/c2corg_api/tests/markdown/toc/weird 5.md new file mode 100644 index 000000000..34f1de33c --- /dev/null +++ b/c2corg_api/tests/markdown/toc/weird 5.md @@ -0,0 +1,2 @@ +# [toc] +[toc] \ No newline at end of file diff --git a/c2corg_api/tests/markdown/video/Vimeo.html b/c2corg_api/tests/markdown/video/Vimeo.html new file mode 100644 index 000000000..16ede2191 --- /dev/null +++ b/c2corg_api/tests/markdown/video/Vimeo.html @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/video/Vimeo.md b/c2corg_api/tests/markdown/video/Vimeo.md new file mode 100644 index 000000000..663d56c1a --- /dev/null +++ b/c2corg_api/tests/markdown/video/Vimeo.md @@ -0,0 +1 @@ +[video]http://vimeo.com/8654134[/video] \ No newline at end of file diff --git a/c2corg_api/tests/markdown/video/dailymotion short.html b/c2corg_api/tests/markdown/video/dailymotion short.html new file mode 100644 index 000000000..4547f1eb9 --- /dev/null +++ b/c2corg_api/tests/markdown/video/dailymotion short.html @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/video/dailymotion short.md b/c2corg_api/tests/markdown/video/dailymotion short.md new file mode 100644 index 000000000..02a7afa12 --- /dev/null +++ b/c2corg_api/tests/markdown/video/dailymotion short.md @@ -0,0 +1 @@ +[video]http://dai.ly/x5b5r49[/video] \ No newline at end of file diff --git a/c2corg_api/tests/markdown/video/dailymotion.html b/c2corg_api/tests/markdown/video/dailymotion.html new file mode 100644 index 000000000..a8b2132eb --- /dev/null +++ b/c2corg_api/tests/markdown/video/dailymotion.html @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/video/dailymotion.md b/c2corg_api/tests/markdown/video/dailymotion.md new file mode 100644 index 000000000..9a4eb4a94 --- /dev/null +++ b/c2corg_api/tests/markdown/video/dailymotion.md @@ -0,0 +1 @@ +[video]http://www.dailymotion.com/video/x28z33_chinese-man[/video] \ No newline at end of file diff --git a/c2corg_api/tests/markdown/video/not valid url.html b/c2corg_api/tests/markdown/video/not valid url.html new file mode 100644 index 000000000..083e758d5 --- /dev/null +++ b/c2corg_api/tests/markdown/video/not valid url.html @@ -0,0 +1 @@ +

[video]XXX[/video]

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/video/not valid url.md b/c2corg_api/tests/markdown/video/not valid url.md new file mode 100644 index 000000000..446c544f5 --- /dev/null +++ b/c2corg_api/tests/markdown/video/not valid url.md @@ -0,0 +1 @@ +[video]XXX[/video] \ No newline at end of file diff --git a/c2corg_api/tests/markdown/video/youtube short.html b/c2corg_api/tests/markdown/video/youtube short.html new file mode 100644 index 000000000..2896dbb14 --- /dev/null +++ b/c2corg_api/tests/markdown/video/youtube short.html @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/video/youtube short.md b/c2corg_api/tests/markdown/video/youtube short.md new file mode 100644 index 000000000..bcdd47cfa --- /dev/null +++ b/c2corg_api/tests/markdown/video/youtube short.md @@ -0,0 +1 @@ +[video]http://youtu.be/3xMk3RNSbcc[/video] \ No newline at end of file diff --git a/c2corg_api/tests/markdown/video/youtube.html b/c2corg_api/tests/markdown/video/youtube.html new file mode 100644 index 000000000..2896dbb14 --- /dev/null +++ b/c2corg_api/tests/markdown/video/youtube.html @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/c2corg_api/tests/markdown/video/youtube.md b/c2corg_api/tests/markdown/video/youtube.md new file mode 100644 index 000000000..59d46bacb --- /dev/null +++ b/c2corg_api/tests/markdown/video/youtube.md @@ -0,0 +1 @@ +[video]http://www.youtube.com/watch?v=3xMk3RNSbcc&something[/video] \ No newline at end of file diff --git a/c2corg_api/tests/markdown/weirds/bleach bug.html b/c2corg_api/tests/markdown/weirds/bleach bug.html new file mode 100644 index 000000000..741e5eb8e --- /dev/null +++ b/c2corg_api/tests/markdown/weirds/bleach bug.html @@ -0,0 +1 @@ +

<d {c}>

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/weirds/bleach bug.md b/c2corg_api/tests/markdown/weirds/bleach bug.md new file mode 100644 index 000000000..eed4fa803 --- /dev/null +++ b/c2corg_api/tests/markdown/weirds/bleach bug.md @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/c2corg_api/tests/markdown/weirds/markdwon bug.html b/c2corg_api/tests/markdown/weirds/markdwon bug.html new file mode 100644 index 000000000..4fe436ea0 --- /dev/null +++ b/c2corg_api/tests/markdown/weirds/markdwon bug.html @@ -0,0 +1 @@ +

{@{=}

\ No newline at end of file diff --git a/c2corg_api/tests/markdown/weirds/markdwon bug.md b/c2corg_api/tests/markdown/weirds/markdwon bug.md new file mode 100644 index 000000000..2bcd2786b --- /dev/null +++ b/c2corg_api/tests/markdown/weirds/markdwon bug.md @@ -0,0 +1 @@ +{@{=} \ No newline at end of file diff --git a/c2corg_api/views/markdown.py b/c2corg_api/views/markdown.py index 59e6a9ccc..54de1132c 100644 --- a/c2corg_api/views/markdown.py +++ b/c2corg_api/views/markdown.py @@ -1,4 +1,4 @@ -from c2c_markdown import parse_code +from c2corg_api.markdown import parse_code # locale properties that must not be cooked by markdown parser NOT_MARKDOWN_PROPERTY = { diff --git a/requirements.txt b/requirements.txt index 4ef98f828..3a5ebc01f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ alembic==1.4.3 apscheduler==3.7.0 bcrypt==3.2.0 +bleach==3.3.0 colander==1.8.3 dogpile.cache==1.1.2 elasticsearch==2.4.1 @@ -9,9 +10,11 @@ geoalchemy2==0.4.2 geojson==2.5.0 geomet==0.3.0 kombu==5.0.2 +Markdown==2.6.11 phpserialize==1.3.0 # phpserialize is only required during the migration psycopg2==2.8.6 pyjwt==1.7.1 +pymdown-extensions==4.9.1 pyproj==3.0.1 pyramid-jwtauth==0.1.3 pyramid==1.7.3 @@ -39,9 +42,6 @@ git+https://github.com/tsauerwein/ColanderAlchemy.git@c2corg # needs: https://github.com/mozilla-services/cornice/pull/359 git+https://github.com/tsauerwein/cornice.git@nested-none-2.1.0-c2corg -# c2c_markdown repo... -git+https://github.com/c2corg/c2c_markdown.git@4c337e2 - # Discourse API client https://github.com/c2corg/pydiscourse/archive/ea03a3a.zip