From 53084e1ffa82323e37fe2d17a1b53d1dc66e5afd Mon Sep 17 00:00:00 2001 From: Taneli Hukkinen <3275109+hukkin@users.noreply.github.com> Date: Mon, 9 May 2022 02:10:18 +0300 Subject: [PATCH 01/18] =?UTF-8?q?=F0=9F=94=A7=20MAINTAIN:=20Update=20mypy'?= =?UTF-8?q?s=20additional=20dependencies=20(#217)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b9b3f0c0..fa85ca98 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -43,4 +43,4 @@ repos: rev: v0.942 hooks: - id: mypy - additional_dependencies: [attrs] + additional_dependencies: [mdurl] From 9be8e22c55a28a7408195ca4d88f8d69b4c7d7a7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 5 Jul 2022 01:09:19 +0200 Subject: [PATCH 02/18] [pre-commit.ci] pre-commit autoupdate (#215) --- .pre-commit-config.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fa85ca98..27170395 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,7 +16,7 @@ exclude: > repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.2.0 + rev: v4.3.0 hooks: - id: check-json - id: check-yaml @@ -29,18 +29,18 @@ repos: - id: isort - repo: https://github.com/psf/black - rev: 22.3.0 + rev: 22.6.0 hooks: - id: black - - repo: https://gitlab.com/pycqa/flake8 - rev: 3.9.2 + - repo: https://github.com/PyCQA/flake8 + rev: 4.0.1 hooks: - id: flake8 additional_dependencies: [flake8-bugbear==21.3.1] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.942 + rev: v0.961 hooks: - id: mypy additional_dependencies: [mdurl] From 9f642d0a542894115180da09820caa044b879f56 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 2 Aug 2022 23:06:47 +0200 Subject: [PATCH 03/18] [pre-commit.ci] pre-commit autoupdate (#220) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Chris Sewell --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 27170395..2cda2619 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,13 +34,13 @@ repos: - id: black - repo: https://github.com/PyCQA/flake8 - rev: 4.0.1 + rev: 5.0.2 hooks: - id: flake8 - additional_dependencies: [flake8-bugbear==21.3.1] + additional_dependencies: [flake8-bugbear~=22.7] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.961 + rev: v0.971 hooks: - id: mypy additional_dependencies: [mdurl] From 4e8947419b87f5d80fd46367e63ed2aa03307a46 Mon Sep 17 00:00:00 2001 From: Jakub Wilk Date: Tue, 24 Jan 2023 20:21:28 +0100 Subject: [PATCH 04/18] =?UTF-8?q?=F0=9F=93=9A=20DOCS:=20Fix=20typo=20(#230?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/using.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/using.md b/docs/using.md index 83872037..6bf09e46 100644 --- a/docs/using.md +++ b/docs/using.md @@ -330,7 +330,7 @@ md = MarkdownIt("commonmark", renderer_cls=MyRenderer) md.render("*a*") ``` -Plugins can support multiple render types, using the `__ouput__` attribute (this is currently a Python only feature). +Plugins can support multiple render types, using the `__output__` attribute (this is currently a Python only feature). ```{code-cell} python from markdown_it.renderer import RendererHTML From 9740e23579d13c0e78f8d8c4458bc96b2c2674c6 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Wed, 22 Feb 2023 04:55:38 +0100 Subject: [PATCH 05/18] =?UTF-8?q?=F0=9F=94=A7=20pre-commit=20autoupdate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .pre-commit-config.yaml | 10 +++++----- markdown_it/common/utils.py | 1 - markdown_it/helpers/parse_link_label.py | 1 - markdown_it/renderer.py | 3 +-- markdown_it/rules_block/blockquote.py | 2 -- markdown_it/rules_block/code.py | 1 - markdown_it/rules_block/fence.py | 1 - markdown_it/rules_block/heading.py | 1 - markdown_it/rules_block/hr.py | 1 - markdown_it/rules_block/lheading.py | 1 - markdown_it/rules_block/list.py | 4 ---- markdown_it/rules_block/paragraph.py | 1 - markdown_it/rules_block/reference.py | 1 - markdown_it/rules_block/state_block.py | 1 - markdown_it/rules_core/block.py | 1 - markdown_it/rules_core/normalize.py | 1 - markdown_it/rules_core/smartquotes.py | 1 - markdown_it/rules_inline/autolink.py | 1 - markdown_it/rules_inline/backticks.py | 1 - markdown_it/rules_inline/balance_pairs.py | 2 -- markdown_it/rules_inline/emphasis.py | 1 - markdown_it/rules_inline/entity.py | 1 - markdown_it/rules_inline/html_inline.py | 1 - markdown_it/rules_inline/image.py | 1 - markdown_it/rules_inline/link.py | 1 - markdown_it/rules_inline/strikethrough.py | 2 -- markdown_it/token.py | 1 - tests/test_port/test_references.py | 1 - 28 files changed, 6 insertions(+), 39 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2cda2619..50e8132a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,7 +16,7 @@ exclude: > repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.4.0 hooks: - id: check-json - id: check-yaml @@ -24,23 +24,23 @@ repos: - id: trailing-whitespace - repo: https://github.com/pycqa/isort - rev: 5.10.1 + rev: 5.12.0 hooks: - id: isort - repo: https://github.com/psf/black - rev: 22.6.0 + rev: 23.1.0 hooks: - id: black - repo: https://github.com/PyCQA/flake8 - rev: 5.0.2 + rev: 6.0.0 hooks: - id: flake8 additional_dependencies: [flake8-bugbear~=22.7] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.971 + rev: v1.0.1 hooks: - id: mypy additional_dependencies: [mdurl] diff --git a/markdown_it/common/utils.py b/markdown_it/common/utils.py index edc24ca5..9b7c4aeb 100644 --- a/markdown_it/common/utils.py +++ b/markdown_it/common/utils.py @@ -56,7 +56,6 @@ def arrayReplaceAt(src: list, pos: int, newElements: list) -> list: def isValidEntityCode(c: int) -> bool: - # broken sequence if c >= 0xD800 and c <= 0xDFFF: return False diff --git a/markdown_it/helpers/parse_link_label.py b/markdown_it/helpers/parse_link_label.py index 20e3c148..6ce8daf8 100644 --- a/markdown_it/helpers/parse_link_label.py +++ b/markdown_it/helpers/parse_link_label.py @@ -9,7 +9,6 @@ def parseLinkLabel(state: StateInline, start: int, disableNested: bool = False) -> int: - labelEnd = -1 oldPos = state.pos found = False diff --git a/markdown_it/renderer.py b/markdown_it/renderer.py index b8bfe4da..aa6272a3 100644 --- a/markdown_it/renderer.py +++ b/markdown_it/renderer.py @@ -18,7 +18,7 @@ class Renderer try: from typing import Protocol except ImportError: # Python <3.8 doesn't have `Protocol` in the stdlib - from typing_extensions import Protocol # type: ignore[misc] + from typing_extensions import Protocol # type: ignore class RendererProtocol(Protocol): @@ -82,7 +82,6 @@ def render( result = "" for i, token in enumerate(tokens): - if token.type == "inline": assert token.children is not None result += self.renderInline(token.children, options, env) diff --git a/markdown_it/rules_block/blockquote.py b/markdown_it/rules_block/blockquote.py index 6575731d..e00fbf61 100644 --- a/markdown_it/rules_block/blockquote.py +++ b/markdown_it/rules_block/blockquote.py @@ -10,7 +10,6 @@ def blockquote(state: StateBlock, startLine: int, endLine: int, silent: bool): - LOGGER.debug( "entering blockquote: %s, %s, %s, %s", state, startLine, endLine, silent ) @@ -129,7 +128,6 @@ def blockquote(state: StateBlock, startLine: int, endLine: int, silent: bool): # for (nextLine = startLine + 1; nextLine < endLine; nextLine++) { nextLine = startLine + 1 while nextLine < endLine: - # check if it's outdented, i.e. it's inside list item and indented # less than said list item: # diff --git a/markdown_it/rules_block/code.py b/markdown_it/rules_block/code.py index c4fdba33..a796608d 100644 --- a/markdown_it/rules_block/code.py +++ b/markdown_it/rules_block/code.py @@ -7,7 +7,6 @@ def code(state: StateBlock, startLine: int, endLine: int, silent: bool = False): - LOGGER.debug("entering code: %s, %s, %s, %s", state, startLine, endLine, silent) if state.sCount[startLine] - state.blkIndent < 4: diff --git a/markdown_it/rules_block/fence.py b/markdown_it/rules_block/fence.py index c4f5275d..fb3c6847 100644 --- a/markdown_it/rules_block/fence.py +++ b/markdown_it/rules_block/fence.py @@ -7,7 +7,6 @@ def fence(state: StateBlock, startLine: int, endLine: int, silent: bool): - LOGGER.debug("entering fence: %s, %s, %s, %s", state, startLine, endLine, silent) haveEndMarker = False diff --git a/markdown_it/rules_block/heading.py b/markdown_it/rules_block/heading.py index 8d4ef3e2..064d0702 100644 --- a/markdown_it/rules_block/heading.py +++ b/markdown_it/rules_block/heading.py @@ -10,7 +10,6 @@ def heading(state: StateBlock, startLine: int, endLine: int, silent: bool): - LOGGER.debug("entering heading: %s, %s, %s, %s", state, startLine, endLine, silent) pos = state.bMarks[startLine] + state.tShift[startLine] diff --git a/markdown_it/rules_block/hr.py b/markdown_it/rules_block/hr.py index 804cd9db..22c69722 100644 --- a/markdown_it/rules_block/hr.py +++ b/markdown_it/rules_block/hr.py @@ -11,7 +11,6 @@ def hr(state: StateBlock, startLine: int, endLine: int, silent: bool): - LOGGER.debug("entering hr: %s, %s, %s, %s", state, startLine, endLine, silent) pos = state.bMarks[startLine] + state.tShift[startLine] diff --git a/markdown_it/rules_block/lheading.py b/markdown_it/rules_block/lheading.py index f26e2af0..92632acc 100644 --- a/markdown_it/rules_block/lheading.py +++ b/markdown_it/rules_block/lheading.py @@ -8,7 +8,6 @@ def lheading(state: StateBlock, startLine: int, endLine: int, silent: bool): - LOGGER.debug("entering lheading: %s, %s, %s, %s", state, startLine, endLine, silent) level = None diff --git a/markdown_it/rules_block/list.py b/markdown_it/rules_block/list.py index a7617ad2..9cf8c402 100644 --- a/markdown_it/rules_block/list.py +++ b/markdown_it/rules_block/list.py @@ -10,7 +10,6 @@ # Search `[-+*][\n ]`, returns next pos after marker on success # or -1 on fail. def skipBulletListMarker(state: StateBlock, startLine: int): - pos = state.bMarks[startLine] + state.tShift[startLine] maximum = state.eMarks[startLine] @@ -33,7 +32,6 @@ def skipBulletListMarker(state: StateBlock, startLine: int): # Search `\d+[.)][\n ]`, returns next pos after marker on success # or -1 on fail. def skipOrderedListMarker(state: StateBlock, startLine: int): - start = state.bMarks[startLine] + state.tShift[startLine] pos = start maximum = state.eMarks[startLine] @@ -59,7 +57,6 @@ def skipOrderedListMarker(state: StateBlock, startLine: int): # /* 0 */ /* 9 */ if ch >= 0x30 and ch <= 0x39: - # List marker should have no more than 9 digits # (prevents integer overflow in browsers) if pos - start >= 10: @@ -97,7 +94,6 @@ def markTightParagraphs(state: StateBlock, idx: int): def list_block(state: StateBlock, startLine: int, endLine: int, silent: bool): - LOGGER.debug("entering list: %s, %s, %s, %s", state, startLine, endLine, silent) isTerminatingParagraph = False diff --git a/markdown_it/rules_block/paragraph.py b/markdown_it/rules_block/paragraph.py index 4fee83e9..fef7edf7 100644 --- a/markdown_it/rules_block/paragraph.py +++ b/markdown_it/rules_block/paragraph.py @@ -8,7 +8,6 @@ def paragraph(state: StateBlock, startLine: int, endLine: int, silent: bool = False): - LOGGER.debug( "entering paragraph: %s, %s, %s, %s", state, startLine, endLine, silent ) diff --git a/markdown_it/rules_block/reference.py b/markdown_it/rules_block/reference.py index 35adde2a..39e21eb6 100644 --- a/markdown_it/rules_block/reference.py +++ b/markdown_it/rules_block/reference.py @@ -7,7 +7,6 @@ def reference(state: StateBlock, startLine, _endLine, silent): - LOGGER.debug( "entering reference: %s, %s, %s, %s", state, startLine, _endLine, silent ) diff --git a/markdown_it/rules_block/state_block.py b/markdown_it/rules_block/state_block.py index 42b8fce3..c5589149 100644 --- a/markdown_it/rules_block/state_block.py +++ b/markdown_it/rules_block/state_block.py @@ -19,7 +19,6 @@ def __init__( tokens: list[Token], srcCharCode: tuple[int, ...] | None = None, ): - if srcCharCode is not None: self._src = src self.srcCharCode = srcCharCode diff --git a/markdown_it/rules_core/block.py b/markdown_it/rules_core/block.py index fa1c52c4..dc756418 100644 --- a/markdown_it/rules_core/block.py +++ b/markdown_it/rules_core/block.py @@ -3,7 +3,6 @@ def block(state: StateCore) -> None: - if state.inlineMode: token = Token("inline", "", 0) token.content = state.src diff --git a/markdown_it/rules_core/normalize.py b/markdown_it/rules_core/normalize.py index bf16fd7a..c9f8d0d5 100644 --- a/markdown_it/rules_core/normalize.py +++ b/markdown_it/rules_core/normalize.py @@ -9,7 +9,6 @@ def normalize(state: StateCore) -> None: - # Normalize newlines string = NEWLINES_RE.sub("\n", state.src) diff --git a/markdown_it/rules_core/smartquotes.py b/markdown_it/rules_core/smartquotes.py index 93f8be28..7a39fad4 100644 --- a/markdown_it/rules_core/smartquotes.py +++ b/markdown_it/rules_core/smartquotes.py @@ -195,7 +195,6 @@ def smartquotes(state: StateCore) -> None: return for token in state.tokens: - if token.type != "inline" or not QUOTE_RE.search(token.content): continue assert token.children is not None diff --git a/markdown_it/rules_inline/autolink.py b/markdown_it/rules_inline/autolink.py index a4ee61c3..11ac5905 100644 --- a/markdown_it/rules_inline/autolink.py +++ b/markdown_it/rules_inline/autolink.py @@ -10,7 +10,6 @@ def autolink(state: StateInline, silent: bool) -> bool: - pos = state.pos if state.srcCharCode[pos] != 0x3C: # /* < */ diff --git a/markdown_it/rules_inline/backticks.py b/markdown_it/rules_inline/backticks.py index 7bff12fe..5f1e0552 100644 --- a/markdown_it/rules_inline/backticks.py +++ b/markdown_it/rules_inline/backticks.py @@ -7,7 +7,6 @@ def backtick(state: StateInline, silent: bool) -> bool: - pos = state.pos ch = state.srcCharCode[pos] diff --git a/markdown_it/rules_inline/balance_pairs.py b/markdown_it/rules_inline/balance_pairs.py index db622f07..5423b5d6 100644 --- a/markdown_it/rules_inline/balance_pairs.py +++ b/markdown_it/rules_inline/balance_pairs.py @@ -4,7 +4,6 @@ def processDelimiters(state: StateInline, delimiters, *args): - openersBottom = {} maximum = len(delimiters) @@ -50,7 +49,6 @@ def processDelimiters(state: StateInline, delimiters, *args): continue if opener.open and opener.end < 0: - isOddMatch = False # from spec: diff --git a/markdown_it/rules_inline/emphasis.py b/markdown_it/rules_inline/emphasis.py index 9001b09e..5262430b 100644 --- a/markdown_it/rules_inline/emphasis.py +++ b/markdown_it/rules_inline/emphasis.py @@ -39,7 +39,6 @@ def tokenize(state: StateInline, silent: bool): def _postProcess(state, delimiters): - i = len(delimiters) - 1 while i >= 0: startDelim = delimiters[i] diff --git a/markdown_it/rules_inline/entity.py b/markdown_it/rules_inline/entity.py index 883a9666..08d271ed 100644 --- a/markdown_it/rules_inline/entity.py +++ b/markdown_it/rules_inline/entity.py @@ -10,7 +10,6 @@ def entity(state: StateInline, silent: bool): - pos = state.pos maximum = state.posMax diff --git a/markdown_it/rules_inline/html_inline.py b/markdown_it/rules_inline/html_inline.py index 295cc5c7..b875e884 100644 --- a/markdown_it/rules_inline/html_inline.py +++ b/markdown_it/rules_inline/html_inline.py @@ -10,7 +10,6 @@ def isLetter(ch: int): def html_inline(state: StateInline, silent: bool): - pos = state.pos if not state.md.options.get("html", None): diff --git a/markdown_it/rules_inline/image.py b/markdown_it/rules_inline/image.py index d2a08d47..d7215bdf 100644 --- a/markdown_it/rules_inline/image.py +++ b/markdown_it/rules_inline/image.py @@ -7,7 +7,6 @@ def image(state: StateInline, silent: bool): - label = None href = "" oldPos = state.pos diff --git a/markdown_it/rules_inline/link.py b/markdown_it/rules_inline/link.py index 2394d6c3..a6345152 100644 --- a/markdown_it/rules_inline/link.py +++ b/markdown_it/rules_inline/link.py @@ -5,7 +5,6 @@ def link(state: StateInline, silent: bool): - href = "" title = "" label = None diff --git a/markdown_it/rules_inline/strikethrough.py b/markdown_it/rules_inline/strikethrough.py index 107ea26b..9b062a66 100644 --- a/markdown_it/rules_inline/strikethrough.py +++ b/markdown_it/rules_inline/strikethrough.py @@ -53,7 +53,6 @@ def tokenize(state: StateInline, silent: bool): def _postProcess(state: StateInline, delimiters: list[Delimiter]): - loneMarkers = [] maximum = len(delimiters) @@ -89,7 +88,6 @@ def _postProcess(state: StateInline, delimiters: list[Delimiter]): state.tokens[endDelim.token - 1].type == "text" and state.tokens[endDelim.token - 1].content == "~" ): - loneMarkers.append(endDelim.token - 1) i += 1 diff --git a/markdown_it/token.py b/markdown_it/token.py index b20875b6..7a41a784 100644 --- a/markdown_it/token.py +++ b/markdown_it/token.py @@ -22,7 +22,6 @@ def convert_attrs(value: Any) -> Any: @dc.dataclass(**DATACLASS_KWARGS) class Token: - type: str """Type of the token (string, e.g. "paragraph_open")""" diff --git a/tests/test_port/test_references.py b/tests/test_port/test_references.py index 32e389de..75bf7130 100644 --- a/tests/test_port/test_references.py +++ b/tests/test_port/test_references.py @@ -2,7 +2,6 @@ def test_ref_definitions(): - md = MarkdownIt() src = "[a]: abc\n\n[b]: xyz\n\n[b]: ijk" env = {} From b6682498a7790cc16707e891e9b890dbcb6e3250 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Wed, 22 Feb 2023 04:57:45 +0100 Subject: [PATCH 06/18] =?UTF-8?q?=F0=9F=A7=AA=20TESTS=20unpin=20pytest-ben?= =?UTF-8?q?chmark?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e0017185..4c8a169a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -63,7 +63,7 @@ testing = [ benchmarking = [ "psutil", "pytest", - "pytest-benchmark~=3.2", + "pytest-benchmark", ] profiling = ["gprof2dot"] From 23f22bc1bc878e96f6d194b589d9dcdc44dc2e45 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Wed, 22 Feb 2023 05:00:28 +0100 Subject: [PATCH 07/18] =?UTF-8?q?=F0=9F=94=A7=20Add=20dependabot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/dependabot.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..786be571 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,19 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + commit-message: + prefix: ⬆️ + schedule: + interval: weekly + - package-ecosystem: pip + directory: / + commit-message: + prefix: ⬆️ + schedule: + interval: weekly From f83c969f7c44e033ec7398c38c49990f36962210 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 22 Feb 2023 05:08:13 +0100 Subject: [PATCH 08/18] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Bump=20r-lib/actions?= =?UTF-8?q?=20from=201=20to=202=20(#243)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/benchmark.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index ef5780b3..abf3f620 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -17,7 +17,7 @@ jobs: python-version: 3.8 - name: install pandoc - uses: r-lib/actions/setup-pandoc@v1 + uses: r-lib/actions/setup-pandoc@v2 with: pandoc-version: '2.6' From 2160a3daec2a7a007e5a7f5f941eaaad001a2d95 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Wed, 22 Feb 2023 05:16:34 +0100 Subject: [PATCH 09/18] =?UTF-8?q?=F0=9F=94=A7=20Bump=20GH=20actions=20(#24?= =?UTF-8?q?4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/benchmark.yml | 2 +- .github/workflows/tests.yml | 16 ++++++++-------- pyproject.toml | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index abf3f620..c2b82d33 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -12,7 +12,7 @@ jobs: - uses: actions/checkout@v2 - name: Set up Python 3.8 - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: 3.8 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e46c0847..64a068e3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,10 +21,10 @@ jobs: steps: - uses: actions/checkout@v2 - name: Set up Python 3.8 - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: '3.8' - - uses: pre-commit/action@v2.0.0 + - uses: pre-commit/action@v3.0.0 tests: @@ -36,7 +36,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -48,7 +48,7 @@ jobs: pytest tests/ --cov=markdown_it --cov-report=xml --cov-report=term-missing - name: Upload to Codecov if: matrix.python-version == '3.7' && github.repository == 'executablebooks/markdown-it-py' - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v3 with: name: markdown-it-py-pytests-py3.7 flags: pytests @@ -64,7 +64,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install markdown-it-py @@ -85,7 +85,7 @@ jobs: - uses: actions/checkout@v2 - name: Set up Python 3.8 - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: '3.8' @@ -98,7 +98,7 @@ jobs: run: tox -e py38-bench-core -- --benchmark-json bench-core.json - name: Upload data - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: bench-core path: bench-core.json @@ -114,7 +114,7 @@ jobs: - name: Checkout source uses: actions/checkout@v2 - name: Set up Python 3.8 - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: '3.8' - name: install flit diff --git a/pyproject.toml b/pyproject.toml index 4c8a169a..9a491e8b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,7 +35,7 @@ Homepage = "https://github.com/executablebooks/markdown-it-py" Documentation = "https://markdown-it-py.readthedocs.io" [project.optional-dependencies] -code_style = ["pre-commit==2.6"] +code_style = ["pre-commit~=3.0"] compare = [ "commonmark~=0.9.1", "markdown~=3.3.6", From c9f6856dcc3f5f73ce01571dd280d6139b0c1185 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Wed, 22 Feb 2023 05:22:38 +0100 Subject: [PATCH 10/18] =?UTF-8?q?=F0=9F=94=A7=20Update=20benchmark=20pkg?= =?UTF-8?q?=20versions=20(#245)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9a491e8b..76bb25f3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,11 +37,11 @@ Documentation = "https://markdown-it-py.readthedocs.io" [project.optional-dependencies] code_style = ["pre-commit~=3.0"] compare = [ - "commonmark~=0.9.1", - "markdown~=3.3.6", - "mistletoe~=0.8.1", - "mistune~=2.0.2", - "panflute~=2.1.3", + "commonmark~=0.9", + "markdown~=3.4", + "mistletoe~=1.0", + "mistune~=2.0", + "panflute~=2.3", ] linkify = ["linkify-it-py~=1.0"] plugins = ["mdit-py-plugins"] From 032c742671c4d6ad12ecd5cd072164e2f3812c12 Mon Sep 17 00:00:00 2001 From: holamgadol Date: Wed, 22 Feb 2023 07:34:12 +0300 Subject: [PATCH 11/18] =?UTF-8?q?=F0=9F=93=9A=20DOCS:=20Add=20section=20ab?= =?UTF-8?q?out=20markdown=20renderer=20(#227)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Chris Sewell --- docs/using.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/using.md b/docs/using.md index 6bf09e46..aa632574 100644 --- a/docs/using.md +++ b/docs/using.md @@ -397,3 +397,29 @@ md = MarkdownIt("commonmark") md.add_render_rule("link_open", render_blank_link) print(md.render("[a]\n\n[a]: b")) ``` + +### Markdown renderer + +You can also render a token stream directly to markdown via the `MDRenderer` class from [`mdformat`](https://github.com/executablebooks/mdformat): + +```{code-cell} python +from markdown_it import MarkdownIt +from mdformat.renderer import MDRenderer + +md = MarkdownIt("commonmark") + +source_markdown = """ +Here's some *text* + +1. a list + +> a *quote*""" + +tokens = md.parse(source_markdown) + +renderer = MDRenderer() +options = {} +env = {} + +output_markdown = renderer.render(tokens, options, env) +``` From 4670f0cdd7a9e8ab7523f51b0beb1d4ea27bb1b7 Mon Sep 17 00:00:00 2001 From: Taneli Hukkinen <3275109+hukkin@users.noreply.github.com> Date: Wed, 22 Feb 2023 06:36:36 +0200 Subject: [PATCH 12/18] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20UPGRADE:=20Allow=20l?= =?UTF-8?q?inkify-it-py=20v2=20(#218)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Chris Sewell --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 76bb25f3..5ac1ad27 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,7 +43,7 @@ compare = [ "mistune~=2.0", "panflute~=2.3", ] -linkify = ["linkify-it-py~=1.0"] +linkify = ["linkify-it-py>=1,<3"] plugins = ["mdit-py-plugins"] rtd = [ "attrs", From 2c93e0b6a8aec7e5a6e1bdef502de7d95ec2a192 Mon Sep 17 00:00:00 2001 From: redstoneleo Date: Wed, 22 Feb 2023 12:41:25 +0800 Subject: [PATCH 13/18] =?UTF-8?q?=F0=9F=93=9A=20DOCS:=20Update=20the=20exa?= =?UTF-8?q?mple=20(#229)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Chris Sewell --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 599c1f9f..789588fe 100644 --- a/README.md +++ b/README.md @@ -55,10 +55,9 @@ from mdit_py_plugins.front_matter import front_matter_plugin from mdit_py_plugins.footnote import footnote_plugin md = ( - MarkdownIt() + MarkdownIt('commonmark' ,{'breaks':True,'html':True}) .use(front_matter_plugin) .use(footnote_plugin) - .disable('image') .enable('table') ) text = (""" From ae03c6107dfa18e648f6fdd1280f5b89092d5d49 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Wed, 22 Feb 2023 05:56:39 +0100 Subject: [PATCH 14/18] =?UTF-8?q?=F0=9F=90=9B=20FIX:=20CVE-2023-26303=20(#?= =?UTF-8?q?246)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix unnecessary asserts, leading to crashes --- markdown_it/renderer.py | 20 ++++++++------------ markdown_it/rules_core/replacements.py | 3 ++- markdown_it/rules_core/smartquotes.py | 4 ++-- tests/test_port/fixtures/issue-fixes.md | 9 +++++++++ tests/test_port/test_fixtures.py | 1 + 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/markdown_it/renderer.py b/markdown_it/renderer.py index aa6272a3..81d0bc37 100644 --- a/markdown_it/renderer.py +++ b/markdown_it/renderer.py @@ -83,8 +83,8 @@ def render( for i, token in enumerate(tokens): if token.type == "inline": - assert token.children is not None - result += self.renderInline(token.children, options, env) + if token.children: + result += self.renderInline(token.children, options, env) elif token.type in self.rules: result += self.rules[token.type](tokens, i, options, env) else: @@ -206,8 +206,8 @@ def renderInlineAsText( if token.type == "text": result += token.content elif token.type == "image": - assert token.children is not None - result += self.renderInlineAsText(token.children, options, env) + if token.children: + result += self.renderInlineAsText(token.children, options, env) elif token.type == "softbreak": result += "\n" @@ -305,14 +305,10 @@ def image( # "alt" attr MUST be set, even if empty. Because it's mandatory and # should be placed on proper position for tests. - - assert ( - token.attrs and "alt" in token.attrs - ), '"image" token\'s attrs must contain `alt`' - - # Replace content with actual value - - token.attrSet("alt", self.renderInlineAsText(token.children, options, env)) + if token.children: + token.attrSet("alt", self.renderInlineAsText(token.children, options, env)) + else: + token.attrSet("alt", "") return self.renderToken(tokens, idx, options, env) diff --git a/markdown_it/rules_core/replacements.py b/markdown_it/rules_core/replacements.py index 45377d3e..5e9b7ae7 100644 --- a/markdown_it/rules_core/replacements.py +++ b/markdown_it/rules_core/replacements.py @@ -116,7 +116,8 @@ def replace(state: StateCore) -> None: for token in state.tokens: if token.type != "inline": continue - assert token.children is not None + if token.children is None: + continue if SCOPED_ABBR_RE.search(token.content): replace_scoped(token.children) diff --git a/markdown_it/rules_core/smartquotes.py b/markdown_it/rules_core/smartquotes.py index 7a39fad4..b11a5739 100644 --- a/markdown_it/rules_core/smartquotes.py +++ b/markdown_it/rules_core/smartquotes.py @@ -197,5 +197,5 @@ def smartquotes(state: StateCore) -> None: for token in state.tokens: if token.type != "inline" or not QUOTE_RE.search(token.content): continue - assert token.children is not None - process_inlines(token.children, state) + if token.children is not None: + process_inlines(token.children, state) diff --git a/tests/test_port/fixtures/issue-fixes.md b/tests/test_port/fixtures/issue-fixes.md index 0c693b04..319945af 100644 --- a/tests/test_port/fixtures/issue-fixes.md +++ b/tests/test_port/fixtures/issue-fixes.md @@ -36,3 +36,12 @@ .

💬

. + +Fix CVE-2023-26303 +. +![![]() +]([) +. +


+

+. diff --git a/tests/test_port/test_fixtures.py b/tests/test_port/test_fixtures.py index 5117c5e1..d2199caf 100644 --- a/tests/test_port/test_fixtures.py +++ b/tests/test_port/test_fixtures.py @@ -111,4 +111,5 @@ def test_strikethrough(line, title, input, expected): def test_issue_fixes(line, title, input, expected): md = MarkdownIt() text = md.render(input) + print(text) assert text.rstrip() == expected.rstrip() From cf8b2d8c561233d4c18c55e80b68c8d06850fda6 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Wed, 22 Feb 2023 06:32:13 +0100 Subject: [PATCH 15/18] =?UTF-8?q?=F0=9F=94=A7=20Create=20SECURITY.md=20(#2?= =?UTF-8?q?48)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SECURITY.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 SECURITY.md diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..aaa878f4 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,14 @@ +# Security Policy + +## Supported Versions + +We generally only support the latest major release, +although critical bug fixes can be released for older versions. + +## Reporting a Vulnerability + +To report a security issue, please email with a description of the issue, +the steps you took to create the issue, affected versions, and, if known, mitigations for the issue. +Our team will respond within 3 working days of your email. +If the issue is confirmed as a vulnerability, we will open a Security Advisory. +This project follows a 90 day disclosure timeline. From 6491bc2491a07a8072e5d40f27eab6430585c42c Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Wed, 22 Feb 2023 06:35:57 +0100 Subject: [PATCH 16/18] =?UTF-8?q?=F0=9F=93=9A=20Add=20email=20to=20securit?= =?UTF-8?q?y=20section=20(#249)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/other.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/other.md b/docs/other.md index 4d77360f..cfc5ba8c 100644 --- a/docs/other.md +++ b/docs/other.md @@ -21,7 +21,7 @@ for XSS: So, by default `markdown-it` should be safe. We care about it. -If you find a security problem - contact us via tracker or email. +If you find a security problem - contact us via . Such reports are fixed with top priority. ## Plugins From 53ca3e9c2b9e9b295f6abf7f4ad2730a9b70f68c Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Wed, 22 Feb 2023 06:39:56 +0100 Subject: [PATCH 17/18] =?UTF-8?q?=F0=9F=90=9B=20FIX:=20CLI=20crash=20on=20?= =?UTF-8?q?non-utf8=20character=20(#247)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addresses CVE-2023-26302 --- markdown_it/cli/parse.py | 2 +- tests/test_cli.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/markdown_it/cli/parse.py b/markdown_it/cli/parse.py index 2d74f55a..890d5de3 100644 --- a/markdown_it/cli/parse.py +++ b/markdown_it/cli/parse.py @@ -35,7 +35,7 @@ def convert_file(filename: str) -> None: Parse a Markdown file and dump the output to stdout. """ try: - with open(filename, "r") as fin: + with open(filename, "r", encoding="utf8", errors="ignore") as fin: rendered = MarkdownIt().render(fin.read()) print(rendered, end="") except OSError: diff --git a/tests/test_cli.py b/tests/test_cli.py index 57d6b938..c38e24fd 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -20,6 +20,13 @@ def test_parse_fail(): assert exc_info.value.code == 1 +def test_non_utf8(): + with tempfile.TemporaryDirectory() as tempdir: + path = pathlib.Path(tempdir).joinpath("test.md") + path.write_bytes(b"\x80abc") + assert parse.main([str(path)]) == 0 + + def test_print_heading(): with patch("builtins.print") as patched: parse.print_heading() From 73a01479212bfe2aea0b995b4d13c8ddca2e4265 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Wed, 22 Feb 2023 06:52:12 +0100 Subject: [PATCH 18/18] =?UTF-8?q?=F0=9F=9A=80=20RELEASE:=20v2.2.0=20(#250)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 25 +++++++++++++++++++++++++ markdown_it/__init__.py | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1aa4a725..fa8dc6b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,30 @@ # Change Log +## 2.2.0 - 2023-02-22 + +### What's Changed + +* ⬆️ UPGRADE: Allow linkify-it-py v2 by @hukkin in [#218](https://github.com/executablebooks/markdown-it-py/pull/218) +* 🐛 FIX: CVE-2023-26303 by @chrisjsewell in [#246](https://github.com/executablebooks/markdown-it-py/pull/246) +* 🐛 FIX: CLI crash on non-utf8 character by @chrisjsewell in [#247](https://github.com/executablebooks/markdown-it-py/pull/247) +* 📚 DOCS: Update the example by @redstoneleo in [#229](https://github.com/executablebooks/markdown-it-py/pull/229) +* 📚 DOCS: Add section about markdown renderer by @holamgadol in [#227](https://github.com/executablebooks/markdown-it-py/pull/227) +* 🔧 Create SECURITY.md by @chrisjsewell in [#248](https://github.com/executablebooks/markdown-it-py/pull/248) +* 🔧 MAINTAIN: Update mypy's additional dependencies by @hukkin in [#217](https://github.com/executablebooks/markdown-it-py/pull/217) +* Fix typo by @jwilk in [#230](https://github.com/executablebooks/markdown-it-py/pull/230) +* 🔧 Bump GH actions by @chrisjsewell in [#244](https://github.com/executablebooks/markdown-it-py/pull/244) +* 🔧 Update benchmark pkg versions by @chrisjsewell in [#245](https://github.com/executablebooks/markdown-it-py/pull/245) + +### New Contributors + +Thanks to 🎉 + +* @jwilk made their first contribution in [#230](https://github.com/executablebooks/markdown-it-py/pull/230) +* @holamgadol made their first contribution in [#227](https://github.com/executablebooks/markdown-it-py/pull/227) +* @redstoneleo made their first contribution in [#229](https://github.com/executablebooks/markdown-it-py/pull/229) + +**Full Changelog**: + ## 2.1.0 - 2022-04-15 This release is primarily to replace the `attrs` package dependency, diff --git a/markdown_it/__init__.py b/markdown_it/__init__.py index 5cc232a5..882a0c3e 100644 --- a/markdown_it/__init__.py +++ b/markdown_it/__init__.py @@ -1,5 +1,5 @@ """A Python port of Markdown-It""" __all__ = ("MarkdownIt",) -__version__ = "2.1.0" +__version__ = "2.2.0" from .main import MarkdownIt