Skip to content

Commit 1b1ef4d

Browse files
authored
Merge branch 'master' into patch-1
2 parents 22cf638 + 6649229 commit 1b1ef4d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+308
-422
lines changed

.github/workflows/tests.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
push:
88
branches: [master]
99
tags:
10-
- 'v*'
10+
- "v[0-9]+.[0-9]+.[0-9]+*"
1111
pull_request:
1212
schedule:
1313
- cron: '0 0 * * 0' # every week
@@ -113,19 +113,19 @@ jobs:
113113
steps:
114114
- name: Checkout source
115115
uses: actions/checkout@v2
116-
- name: Set up Python 3.7
116+
- name: Set up Python 3.8
117117
uses: actions/setup-python@v2
118118
with:
119-
python-version: '3.7'
120-
- name: Build package
119+
python-version: '3.8'
120+
- name: install flit
121121
run: |
122-
pip install build
123-
python -m build
124-
- name: Publish
125-
uses: pypa/gh-action-pypi-publish@v1.1.0
126-
with:
127-
user: __token__
128-
password: ${{ secrets.PYPI_KEY }}
122+
pip install flit~=3.4
123+
- name: Build and publish
124+
run: |
125+
flit publish
126+
env:
127+
FLIT_USERNAME: __token__
128+
FLIT_PASSWORD: ${{ secrets.PYPI_KEY }}
129129

130130
allgood:
131131
runs-on: ubuntu-latest

.pre-commit-config.yaml

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,40 +16,31 @@ exclude: >
1616
repos:
1717

1818
- repo: https://github.com/pre-commit/pre-commit-hooks
19-
rev: v3.4.0
19+
rev: v4.2.0
2020
hooks:
2121
- id: check-json
2222
- id: check-yaml
2323
- id: end-of-file-fixer
2424
- id: trailing-whitespace
2525

26-
- repo: https://github.com/mgedmin/check-manifest
27-
rev: "0.46"
26+
- repo: https://github.com/pycqa/isort
27+
rev: 5.10.1
2828
hooks:
29-
- id: check-manifest
30-
args: [--no-build-isolation]
31-
additional_dependencies: [setuptools>=46.4.0]
32-
33-
# this is not used for now,
34-
# since it converts markdown-it-py to markdown_it_py and removes comments
35-
# - repo: https://github.com/asottile/setup-cfg-fmt
36-
# rev: v1.17.0
37-
# hooks:
38-
# - id: setup-cfg-fmt
29+
- id: isort
3930

4031
- repo: https://github.com/psf/black
41-
rev: 20.8b1
32+
rev: 22.3.0
4233
hooks:
4334
- id: black
4435

4536
- repo: https://gitlab.com/pycqa/flake8
46-
rev: 3.9.1
37+
rev: 3.9.2
4738
hooks:
4839
- id: flake8
4940
additional_dependencies: [flake8-bugbear==21.3.1]
5041

5142
- repo: https://github.com/pre-commit/mirrors-mypy
52-
rev: v0.812
43+
rev: v0.942
5344
hooks:
5445
- id: mypy
5546
additional_dependencies: [attrs]

MANIFEST.in

Lines changed: 0 additions & 24 deletions
This file was deleted.

benchmarking/bench_core.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from pathlib import Path
2+
23
import pytest
34

45
import markdown_it

benchmarking/bench_packages.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from pathlib import Path
2-
import pytest
32
from shutil import which
43

4+
import pytest
5+
56

67
@pytest.fixture
78
def spec_text():

docs/_static/custom.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.code-cell > .highlight > pre {
2+
border-left-color: green;
3+
border-left-width: medium;
4+
border-left-style: solid;
5+
}

docs/architecture.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
# markdown-it design principles
44

5+
(md/data-flow)=
56
## Data flow
67

78
Input data is parsed via nested chains of rules. There are 3 nested chains -
@@ -157,10 +158,9 @@ renderer override, but can be more simple.
157158
You also can write your own renderer to generate other formats than HTML, such as
158159
JSON/XML... You can even use it to generate AST.
159160

160-
161161
## Summary
162162

163-
This was mentioned in [Data flow](#data-flow), but let's repeat sequence again:
163+
This was mentioned in [Data flow](md/data-flow), but let's repeat sequence again:
164164

165165
1. Blocks are parsed, and top level of token stream filled with block tokens.
166166
2. Content on inline containers is parsed, filling `.children` properties.

docs/conf.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,25 @@
3333
"sphinx.ext.autodoc",
3434
"sphinx.ext.viewcode",
3535
"sphinx.ext.intersphinx",
36-
"myst_nb",
36+
"myst_parser",
3737
"sphinx_copybutton",
38-
"sphinx_panels",
38+
"sphinx_design",
3939
]
4040

41-
# Add any paths that contain templates here, relative to this directory.
42-
templates_path = ["_templates"]
43-
4441
# List of patterns, relative to source directory, that match files and
4542
# directories to ignore when looking for source files.
4643
# This pattern also affects html_static_path and html_extra_path.
4744
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
4845

46+
nitpicky = True
4947
nitpick_ignore = [
5048
("py:class", "Match"),
49+
("py:class", "Path"),
5150
("py:class", "x in the interval [0, 1)."),
5251
("py:class", "markdown_it.helpers.parse_link_destination._Result"),
5352
("py:class", "markdown_it.helpers.parse_link_title._Result"),
5453
("py:class", "MarkdownIt"),
54+
("py:class", "RuleFunc"),
5555
("py:class", "_NodeType"),
5656
("py:class", "typing_extensions.Protocol"),
5757
]
@@ -70,7 +70,8 @@
7070
"repository_branch": "master",
7171
"path_to_docs": "docs",
7272
}
73-
panels_add_boostrap_css = False
73+
html_static_path = ["_static"]
74+
html_css_files = ["custom.css"]
7475

7576
# Add any paths that contain custom static files (such as style sheets) here,
7677
# relative to this directory. They are copied after the builtin static files,
@@ -91,6 +92,7 @@ def run_apidoc(app):
9192
"""
9293
import os
9394
import shutil
95+
9496
import sphinx
9597
from sphinx.ext import apidoc
9698

@@ -100,7 +102,7 @@ def run_apidoc(app):
100102
this_folder = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
101103
api_folder = os.path.join(this_folder, "api")
102104
module_path = os.path.normpath(os.path.join(this_folder, "../"))
103-
ignore_paths = ["../setup.py", "../conftest.py", "../tests", "../benchmarking"]
105+
ignore_paths = ["../profiler.py", "../conftest.py", "../tests", "../benchmarking"]
104106
ignore_paths = [
105107
os.path.normpath(os.path.join(this_folder, p)) for p in ignore_paths
106108
]
@@ -120,6 +122,7 @@ def run_apidoc(app):
120122

121123
argv = ["-M", "--separate", "-o", api_folder, module_path] + ignore_paths
122124

125+
apidoc.OPTIONS.append("ignore-module-all")
123126
apidoc.main(argv)
124127

125128
# we don't use this
@@ -131,3 +134,17 @@ def setup(app):
131134
"""Add functions to the Sphinx setup."""
132135
if os.environ.get("SKIP_APIDOC", None) is None:
133136
app.connect("builder-inited", run_apidoc)
137+
138+
from sphinx.directives.code import CodeBlock
139+
140+
class CodeCell(CodeBlock):
141+
"""Custom code block directive."""
142+
143+
def run(self):
144+
"""Run the directive."""
145+
self.options["class"] = ["code-cell"]
146+
return super().run()
147+
148+
# note, these could be run by myst-nb,
149+
# but currently this causes a circular dependency issue
150+
app.add_directive("code-cell", CodeCell)

docs/contributing.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ It can be setup by:
2929
Editors like VS Code also have automatic code reformat utilities, which can adhere to this standard.
3030

3131
All functions and class methods should be annotated with types and include a docstring.
32-
The preferred docstring format is outlined in `markdown-it-py/docstring.fmt.mustache` and can be used automatically with the [autodocstring](https://marketplace.visualstudio.com/items?itemName=njpwerner.autodocstring) VS Code extension.
3332

3433
## Testing
3534

docstring.fmt.mustache

Lines changed: 0 additions & 20 deletions
This file was deleted.

markdown_it/cli/parse.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from markdown_it import __version__
1414
from markdown_it.main import MarkdownIt
1515

16-
1716
version_str = "markdown-it-py [version {}]".format(__version__)
1817

1918

markdown_it/common/normalize_url.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
from collections.abc import Callable
44
import re
5-
from urllib.parse import urlparse, urlunparse, quote, unquote # noqa: F401
5+
from urllib.parse import quote, unquote, urlparse, urlunparse # noqa: F401
66

77
import mdurl
88

99
from .. import _punycode
1010

11-
1211
RECODE_HOSTNAME_FOR = ("http:", "https:", "mailto:")
1312

1413

markdown_it/helpers/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Functions for parsing Links
22
"""
33
__all__ = ("parseLinkLabel", "parseLinkDestination", "parseLinkTitle")
4-
from .parse_link_label import parseLinkLabel
54
from .parse_link_destination import parseLinkDestination
5+
from .parse_link_label import parseLinkLabel
66
from .parse_link_title import parseLinkTitle

markdown_it/helpers/parse_link_destination.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Parse link destination
33
"""
44

5-
from ..common.utils import unescapeAll, charCodeAt
5+
from ..common.utils import charCodeAt, unescapeAll
66

77

88
class _Result:

markdown_it/helpers/parse_link_title.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Parse link title
22
"""
3-
from ..common.utils import unescapeAll, charCodeAt
3+
from ..common.utils import charCodeAt, unescapeAll
44

55

66
class _Result:

markdown_it/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
from __future__ import annotations
22

3-
from contextlib import contextmanager
43
from collections.abc import Callable, Generator, Iterable, Mapping, MutableMapping
4+
from contextlib import contextmanager
55
from typing import Any
66

77
from . import helpers, presets # noqa F401
88
from .common import normalize_url, utils # noqa F401
9-
from .token import Token
10-
from .parser_core import ParserCore # noqa F401
119
from .parser_block import ParserBlock # noqa F401
10+
from .parser_core import ParserCore # noqa F401
1211
from .parser_inline import ParserInline # noqa F401
13-
from .rules_core.state_core import StateCore
1412
from .renderer import RendererHTML, RendererProtocol
13+
from .rules_core.state_core import StateCore
14+
from .token import Token
1515
from .utils import OptionsDict
1616

1717
try:

markdown_it/parser_block.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
import logging
55

6+
from . import rules_block
67
from .ruler import Ruler
7-
from .token import Token
88
from .rules_block.state_block import StateBlock
9-
from . import rules_block
9+
from .token import Token
1010

1111
LOGGER = logging.getLogger(__name__)
1212

markdown_it/parser_core.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
"""
77
from __future__ import annotations
88

9-
from .ruler import Ruler, RuleFunc
9+
from .ruler import RuleFunc, Ruler
10+
from .rules_core import block, inline, linkify, normalize, replace, smartquotes
1011
from .rules_core.state_core import StateCore
11-
from .rules_core import normalize, block, inline, replace, smartquotes, linkify
12-
1312

1413
_rules: list[tuple[str, RuleFunc]] = [
1514
("normalize", normalize),

markdown_it/parser_inline.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
"""
33
from __future__ import annotations
44

5-
from .ruler import Ruler, RuleFunc
6-
from .token import Token
7-
from .rules_inline.state_inline import StateInline
85
from . import rules_inline
6+
from .ruler import RuleFunc, Ruler
7+
from .rules_inline.state_inline import StateInline
8+
from .token import Token
99

1010
# Parser rules
1111
_rules: list[tuple[str, RuleFunc]] = [

markdown_it/renderer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Renderer
1111
import inspect
1212
from typing import Any, ClassVar
1313

14-
from .common.utils import unescapeAll, escapeHtml
14+
from .common.utils import escapeHtml, unescapeAll
1515
from .token import Token
1616
from .utils import OptionsDict
1717

0 commit comments

Comments
 (0)