diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..62104894 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,27 @@ +--- +name: Bug report +about: Report a parsing error, unexpected output and other bugs +title: '' +labels: bug +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Attach a minimal markdown snippet that causes the bug to occur. This should be placed inside a fenced code block to escape GitHub's formatting. + +If your snippet contains fenced code blocks then you can escape them by adding more backticks to the enclosing block. See the [this GitHub article](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks#fenced-code-blocks) for an example. + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Debug info** +Version of library being used: + +Any extras being used: + +**Additional context** +Add any other context about the problem here. diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml index 1e57cd6a..ef965895 100644 --- a/.github/workflows/python.yaml +++ b/.github/workflows/python.yaml @@ -6,10 +6,14 @@ on: branches: [ master ] jobs: build: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: matrix: - python-version: [pypy3, 3.5, 3.6, 3.7, 3.8, 3.9] + python-version: ["3.5", "3.6", "3.7", "3.8", "3.9", "3.10"] + os: + - ubuntu-20.04 + - macos-latest + - windows-latest steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} @@ -19,7 +23,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install Pygments>=2.5.2 + pip install .[all] - name: Test run: | make testone diff --git a/CHANGES.md b/CHANGES.md index d79074c8..06cd3bf9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,8 +1,125 @@ # python-markdown2 Changelog -## python-markdown2 2.4.2 (not yet released) +## python-markdown2 2.4.13 + +- [pull #559] Allow cuddled tables (#557) +- [pull #560] Fix `markdown-in-html` not always splitting HTML tags into separate lines (#558) +- [pull #564] Fix incomplete comments in safe mode not being escaped (#563) +- [pull #566] Fix crash in `markdown-in-html` extra (#565) + + +## python-markdown2 2.4.12 + +- [pull #547] Update `markdown-in-html` extra to handle markdown on same line as HTML (#546) +- [pull #550] Fix tables with trailing whitespace not being recognized (#549) +- [pull #545] Fix multiple instances of strong emphasis (`**`) in one line (#541) +- [pull #556] Fix incorrect parsing of links after square brackets (#552) + +## python-markdown2 2.4.11 + +- [pull #524] Fix angles being escaped in style blocks (issue #523) +- [pull #527] Fix base64 images being corrupted in safe mode (issue #526) +- [pull #529] Add `breaks` extra with ability to hard break on backslashes (issue #525) +- [pull #532] Fix #493 persisting when `code-friendly` extra enabled +- [pull #535] Update `_slugify` to use utf-8 encoding (issue #534) +- [pull #536] Maintain order of appearance in footnotes +- [pull #538] Include HTML headers in TOC +- [pull #540] Add mechanism to prevent header ID counter resetting (issue #530) + +## python-markdown2 2.4.10 + +- [pull #520] Allow more relative links in safe mode (issue #517) +- [pull #521] Always restore hashed HTML blocks (issue #185) +- [pull #522] Add `middle-word-em` extra + + +## python-markdown2 2.4.9 + +- [pull #500] Add `` tag to html-classes extra +- [pull #501] Fix link patterns extra matching against internal hashes +- [pull #502] Replace deprecated `optparse` with `argparse` +- [pull #506] Fix `_uniform_outdent` failing with empty strings (issue #505) +- [pull #509] Fix HTML elements not unhashing correctly (issue 508) +- [pull #511] Remove deprecated `imp` module (issue #510) +- [pull #512] Allow link patterns to be passed via extras dict +- [pull #513] Fix relative links not working in safe mode (issue #254) + + +## python-markdown2 2.4.8 + +- [pull #499] Fix images not being procesed correctly (#498) + + +## python-markdown2 2.4.7 + +- [pull #483] Fix hashing nested HTML blocks +- [pull #486] Fix backslash being unable to escape raw HTML tags +- [pull #482] Add support for telegram spoiler in extras +- [pull #485] mermaid support +- [pull #487] Fix escaping ampersands in hrefs +- [pull #490] Fix indented codeblocks inside fences (#489) +- [pull #490] Remove `code-color` extra + + +## python-markdown2 2.4.6 + +- [pull #477] Feature wavedrom support +- [pull #480] Fix mixing ordered and un-ordered lists combining into single list type + + +## python-markdown2 2.4.5 + +- [pull #466] Add optional dependencies to `setup.py` + + +## python-markdown2 2.4.4 + +- [pull #439] Fix TypeError if html-classes extra is None +- [pull #441] Remove Python2 support +- [pull #445] Replace `` with `` in strike extra +- [pull #446] Fix link patterns extra applying within links +- [pull #443] create proper entry point +- [pull #449] Codespans inside link text issue344 +- [pull #451] Underline and HTML comments +- [pull #453] Links with brackets +- [pull #454] Fix emacs local variable one-liners +- [pull #457] Example of the current mixed-paragraph mode behavior in lists +- [pull #455] Fix code block indentation in lists +- [pull #434] Fix filter bypass leading to XSS (#362) +- [pull #464] Fix html-classes extra not applying to code spans +- [pull #462] Fix pygments block matching +- [pull #462] Fix pyshell blocks in blockquotes +- [pull #463] Fix multilevel lists +- [pull #468] Remove `_uniform_outdent_limit` function +- [pull #470] Add support for ordered lists that don't start at 1. (#469) +- [pull #472] Fix `AssertionError` with lazy numbered lists (issue #471) +- [pull #475] Add `

+ diff --git a/test/tm-cases/syntax_color.html b/test/tm-cases/syntax_color.html deleted file mode 100644 index ae9ea34d..00000000 --- a/test/tm-cases/syntax_color.html +++ /dev/null @@ -1,15 +0,0 @@ -

Here is some sample code:

- -
import sys
-def main(argv=sys.argv):
-    logging.basicConfig()
-    log.info('hi')
-
- -

and:

- -
use 'zlib'
-sub main(argv)
-    puts 'hi'
-end
-
diff --git a/test/tm-cases/syntax_color.opts b/test/tm-cases/syntax_color.opts deleted file mode 100644 index 95dfd418..00000000 --- a/test/tm-cases/syntax_color.opts +++ /dev/null @@ -1 +0,0 @@ -{"extras": ["code-color"]} diff --git a/test/tm-cases/syntax_color.tags b/test/tm-cases/syntax_color.tags deleted file mode 100644 index b9a5e485..00000000 --- a/test/tm-cases/syntax_color.tags +++ /dev/null @@ -1 +0,0 @@ -extra code-color pygments diff --git a/test/tm-cases/syntax_color.text b/test/tm-cases/syntax_color.text deleted file mode 100644 index b4b30e55..00000000 --- a/test/tm-cases/syntax_color.text +++ /dev/null @@ -1,15 +0,0 @@ -Here is some sample code: - - :::python - import sys - def main(argv=sys.argv): - logging.basicConfig() - log.info('hi') - -and: - - :::ruby - use 'zlib' - sub main(argv) - puts 'hi' - end diff --git a/test/tm-cases/syntax_color_opts.html b/test/tm-cases/syntax_color_opts.html deleted file mode 100644 index a44e49d2..00000000 --- a/test/tm-cases/syntax_color_opts.html +++ /dev/null @@ -1,15 +0,0 @@ -

Here is some sample code:

- -
import sys
-def main(argv=sys.argv):
-    logging.basicConfig()
-    log.info('hi')
-
- -

and:

- -
use 'zlib'
-sub main(argv)
-    puts 'hi'
-end
-
diff --git a/test/tm-cases/syntax_color_opts.opts b/test/tm-cases/syntax_color_opts.opts deleted file mode 100644 index 3c400432..00000000 --- a/test/tm-cases/syntax_color_opts.opts +++ /dev/null @@ -1 +0,0 @@ -{"extras": {"code-color": {"noclasses": True}}} diff --git a/test/tm-cases/syntax_color_opts.tags b/test/tm-cases/syntax_color_opts.tags deleted file mode 100644 index b9a5e485..00000000 --- a/test/tm-cases/syntax_color_opts.tags +++ /dev/null @@ -1 +0,0 @@ -extra code-color pygments diff --git a/test/tm-cases/syntax_color_opts.text b/test/tm-cases/syntax_color_opts.text deleted file mode 100644 index b4b30e55..00000000 --- a/test/tm-cases/syntax_color_opts.text +++ /dev/null @@ -1,15 +0,0 @@ -Here is some sample code: - - :::python - import sys - def main(argv=sys.argv): - logging.basicConfig() - log.info('hi') - -and: - - :::ruby - use 'zlib' - sub main(argv) - puts 'hi' - end diff --git a/test/tm-cases/tables.html b/test/tm-cases/tables.html index 0d9abca4..7a262d81 100644 --- a/test/tm-cases/tables.html +++ b/test/tm-cases/tables.html @@ -130,13 +130,28 @@

table with cuddled following content

Note: This passes GFM, but fails in PHP-Markdown.

-

FAIL: table with cuddled leading content

+

table with cuddled leading content

-

before -| Header 1 | Header 2 | -| -------- | -------- | -| Cell 1 | Cell 2 | -| Cell 3 | Cell 4 |

+

This would have failed in <=2.4.13

+ + + + + + + + + + + + + + + + + + +
Header 1Header 2
Cell 1Cell 2
Cell 3Cell 4

single column single leading bar

diff --git a/test/tm-cases/tables.text b/test/tm-cases/tables.text index 0b167420..0cd4e53c 100644 --- a/test/tm-cases/tables.text +++ b/test/tm-cases/tables.text @@ -50,9 +50,9 @@ after *Note:* This passes GFM, but fails in PHP-Markdown. -# FAIL: table with cuddled leading content +# table with cuddled leading content -before +This would have failed in <=2.4.13 | Header 1 | Header 2 | | -------- | -------- | | Cell 1 | Cell 2 | diff --git a/test/tm-cases/tg-spoiler.html b/test/tm-cases/tg-spoiler.html new file mode 100644 index 00000000..6d903764 --- /dev/null +++ b/test/tm-cases/tg-spoiler.html @@ -0,0 +1,5 @@ +

This is some Telegram spoiler text.

+ +

This is some Telegram spoiler with more words text.

+ +

This spoiler got more spoilers

diff --git a/test/tm-cases/tg-spoiler.opts b/test/tm-cases/tg-spoiler.opts new file mode 100644 index 00000000..e3da2c96 --- /dev/null +++ b/test/tm-cases/tg-spoiler.opts @@ -0,0 +1 @@ +{"extras": ["tg-spoiler"]} \ No newline at end of file diff --git a/test/tm-cases/tg-spoiler.tags b/test/tm-cases/tg-spoiler.tags new file mode 100644 index 00000000..46fef954 --- /dev/null +++ b/test/tm-cases/tg-spoiler.tags @@ -0,0 +1 @@ +extras tg-spoiler \ No newline at end of file diff --git a/test/tm-cases/tg-spoiler.text b/test/tm-cases/tg-spoiler.text new file mode 100644 index 00000000..d79cc57c --- /dev/null +++ b/test/tm-cases/tg-spoiler.text @@ -0,0 +1,5 @@ +This is some ||Telegram spoiler|| text. + +This is some || Telegram spoiler with more words || text. + +This ||spoiler || got more || spoilers|| \ No newline at end of file diff --git a/test/tm-cases/toc_4.html b/test/tm-cases/toc_4.html index f7900888..238c4ebe 100644 --- a/test/tm-cases/toc_4.html +++ b/test/tm-cases/toc_4.html @@ -1,6 +1,6 @@

Python

-

蟒蛇

+

蟒蛇

  • 外形特性
  • @@ -9,7 +9,7 @@

    蟒蛇

    Markdown

    -

    标记语言

    +

    标记语言

    • 类型
    • diff --git a/test/tm-cases/toc_4.toc_html b/test/tm-cases/toc_4.toc_html index a5543cd0..cd273f42 100644 --- a/test/tm-cases/toc_4.toc_html +++ b/test/tm-cases/toc_4.toc_html @@ -1,8 +1,8 @@ diff --git a/test/tm-cases/toc_duplicate_entries.html b/test/tm-cases/toc_duplicate_entries.html new file mode 100644 index 00000000..dc051bf7 --- /dev/null +++ b/test/tm-cases/toc_duplicate_entries.html @@ -0,0 +1,5 @@ +

      abc

      + +

      abc

      + +

      abc

      diff --git a/test/tm-cases/toc_duplicate_entries.opts b/test/tm-cases/toc_duplicate_entries.opts new file mode 100644 index 00000000..53a34fa2 --- /dev/null +++ b/test/tm-cases/toc_duplicate_entries.opts @@ -0,0 +1,6 @@ +{ + "extras": { + "toc": {"depth": 3}, + "header-ids": {"mixed": True} + } +} diff --git a/test/tm-cases/toc_duplicate_entries.text b/test/tm-cases/toc_duplicate_entries.text new file mode 100644 index 00000000..c4f0e0a4 --- /dev/null +++ b/test/tm-cases/toc_duplicate_entries.text @@ -0,0 +1,3 @@ +# abc +# abc +# abc diff --git a/test/tm-cases/toc_duplicate_entries.toc_html b/test/tm-cases/toc_duplicate_entries.toc_html new file mode 100644 index 00000000..72262013 --- /dev/null +++ b/test/tm-cases/toc_duplicate_entries.toc_html @@ -0,0 +1,5 @@ + diff --git a/test/tm-cases/trailing_table_whitespace.html b/test/tm-cases/trailing_table_whitespace.html new file mode 100644 index 00000000..e0a19866 --- /dev/null +++ b/test/tm-cases/trailing_table_whitespace.html @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + +
      ProsCons
      Unique and refreshing take on the genreMay not resonate with all viewers
      Cult classic statusOver-the-top humor may polarize audiences
      Influential in launching careersNiche appeal among comedy aficionados
      diff --git a/test/tm-cases/trailing_table_whitespace.opts b/test/tm-cases/trailing_table_whitespace.opts new file mode 100644 index 00000000..23983798 --- /dev/null +++ b/test/tm-cases/trailing_table_whitespace.opts @@ -0,0 +1 @@ +{"extras": ["tables"]} diff --git a/test/tm-cases/trailing_table_whitespace.text b/test/tm-cases/trailing_table_whitespace.text new file mode 100644 index 00000000..08748799 --- /dev/null +++ b/test/tm-cases/trailing_table_whitespace.text @@ -0,0 +1,5 @@ +| Pros | Cons | +|-----------------------------------------|------------------------------------------------| +| Unique and refreshing take on the genre | May not resonate with all viewers | +| Cult classic status | Over-the-top humor may polarize audiences | +| Influential in launching careers | Niche appeal among comedy aficionados | diff --git a/test/tm-cases/underline_html_comment.html b/test/tm-cases/underline_html_comment.html new file mode 100644 index 00000000..e780f603 --- /dev/null +++ b/test/tm-cases/underline_html_comment.html @@ -0,0 +1,13 @@ +

      + +

      + +

      + +

      This is an !underlined link¡: https://github.com. + +

      + +

      + +

      This is a sentence. [definitely]

      diff --git a/test/tm-cases/underline_html_comment.opts b/test/tm-cases/underline_html_comment.opts new file mode 100644 index 00000000..5722f05c --- /dev/null +++ b/test/tm-cases/underline_html_comment.opts @@ -0,0 +1 @@ +{"extras": ["underline"]} diff --git a/test/tm-cases/underline_html_comment.tags b/test/tm-cases/underline_html_comment.tags new file mode 100644 index 00000000..c166945c --- /dev/null +++ b/test/tm-cases/underline_html_comment.tags @@ -0,0 +1 @@ +extras underline diff --git a/test/tm-cases/underline_html_comment.text b/test/tm-cases/underline_html_comment.text new file mode 100644 index 00000000..0a8c7de0 --- /dev/null +++ b/test/tm-cases/underline_html_comment.text @@ -0,0 +1,13 @@ + + + + + + +This is an !--underlined link--¡: ----. + + + + + +This is a sentence. [--definitely--] diff --git a/test/tm-cases/wavedrom.html b/test/tm-cases/wavedrom.html new file mode 100644 index 00000000..158fa133 --- /dev/null +++ b/test/tm-cases/wavedrom.html @@ -0,0 +1,348 @@ +

      Here is a basic wavedrom diagram:

      + +
      Alfa +
      + +

      And here is a more complex one, inside of a list

      + +
        +
      • More complex diagram +
          +
        • Inside of nested list
          +
          pclkPclknclkNclkclk0clk1clk2clk3clk4 +
        • +
        • Making sure not to break indentation
        • +
      • +
      diff --git a/test/tm-cases/wavedrom.opts b/test/tm-cases/wavedrom.opts new file mode 100644 index 00000000..7085fe10 --- /dev/null +++ b/test/tm-cases/wavedrom.opts @@ -0,0 +1 @@ +{"extras": ["wavedrom"]} \ No newline at end of file diff --git a/test/tm-cases/wavedrom.tags b/test/tm-cases/wavedrom.tags new file mode 100644 index 00000000..270c2eef --- /dev/null +++ b/test/tm-cases/wavedrom.tags @@ -0,0 +1 @@ +extra wavedrom \ No newline at end of file diff --git a/test/tm-cases/wavedrom.text b/test/tm-cases/wavedrom.text new file mode 100644 index 00000000..f097e0cd --- /dev/null +++ b/test/tm-cases/wavedrom.text @@ -0,0 +1,24 @@ +Here is a basic wavedrom diagram: +```wavedrom +{ "signal": [{ "name": "Alfa", "wave": "01.zx=ud.23.456789" }] } +``` + +And here is a more complex one, inside of a list + +* More complex diagram + * Inside of nested list + ```wavedrom + { signal: [ + { name: "pclk", wave: 'p.......' }, + { name: "Pclk", wave: 'P.......' }, + { name: "nclk", wave: 'n.......' }, + { name: "Nclk", wave: 'N.......' }, + {}, + { name: 'clk0', wave: 'phnlPHNL' }, + { name: 'clk1', wave: 'xhlhLHl.' }, + { name: 'clk2', wave: 'hpHplnLn' }, + { name: 'clk3', wave: 'nhNhplPl' }, + { name: 'clk4', wave: 'xlh.L.Hx' }, + ]} + ``` + * Making sure not to break indentation \ No newline at end of file diff --git a/test/tm-cases/wavedrom_no_embed.html b/test/tm-cases/wavedrom_no_embed.html new file mode 100755 index 00000000..029850b6 --- /dev/null +++ b/test/tm-cases/wavedrom_no_embed.html @@ -0,0 +1,29 @@ +

      Here is a basic wavedrom diagram:

      + + + +

      And here is a more complex one, inside of a list

      + +
        +
      • More complex diagram +
          +
        • Inside of nested list
          +
        • +
        • Making sure not to break indentation
        • +
      • +
      diff --git a/test/tm-cases/wavedrom_no_embed.opts b/test/tm-cases/wavedrom_no_embed.opts new file mode 100644 index 00000000..ac599d07 --- /dev/null +++ b/test/tm-cases/wavedrom_no_embed.opts @@ -0,0 +1 @@ +{"extras": {"wavedrom": {"prefer_embed_svg": False}}} \ No newline at end of file diff --git a/test/tm-cases/wavedrom_no_embed.tags b/test/tm-cases/wavedrom_no_embed.tags new file mode 100644 index 00000000..270c2eef --- /dev/null +++ b/test/tm-cases/wavedrom_no_embed.tags @@ -0,0 +1 @@ +extra wavedrom \ No newline at end of file diff --git a/test/tm-cases/wavedrom_no_embed.text b/test/tm-cases/wavedrom_no_embed.text new file mode 100644 index 00000000..f097e0cd --- /dev/null +++ b/test/tm-cases/wavedrom_no_embed.text @@ -0,0 +1,24 @@ +Here is a basic wavedrom diagram: +```wavedrom +{ "signal": [{ "name": "Alfa", "wave": "01.zx=ud.23.456789" }] } +``` + +And here is a more complex one, inside of a list + +* More complex diagram + * Inside of nested list + ```wavedrom + { signal: [ + { name: "pclk", wave: 'p.......' }, + { name: "Pclk", wave: 'P.......' }, + { name: "nclk", wave: 'n.......' }, + { name: "Nclk", wave: 'N.......' }, + {}, + { name: 'clk0', wave: 'phnlPHNL' }, + { name: 'clk1', wave: 'xhlhLHl.' }, + { name: 'clk2', wave: 'hpHplnLn' }, + { name: 'clk3', wave: 'nhNhplPl' }, + { name: 'clk4', wave: 'xlh.L.Hx' }, + ]} + ``` + * Making sure not to break indentation \ No newline at end of file diff --git a/test/tm-cases/xss_issue_362.html b/test/tm-cases/xss_issue_362.html new file mode 100644 index 00000000..9d878bd3 --- /dev/null +++ b/test/tm-cases/xss_issue_362.html @@ -0,0 +1,2 @@ +

      <iframe +onload=alert()//

      diff --git a/test/tm-cases/xss_issue_362.opts b/test/tm-cases/xss_issue_362.opts new file mode 100644 index 00000000..8d202ad0 --- /dev/null +++ b/test/tm-cases/xss_issue_362.opts @@ -0,0 +1 @@ +{"safe_mode": True} \ No newline at end of file diff --git a/test/tm-cases/xss_issue_362.text b/test/tm-cases/xss_issue_362.text new file mode 100644 index 00000000..3016199a --- /dev/null +++ b/test/tm-cases/xss_issue_362.text @@ -0,0 +1,2 @@ +