diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index da6ae0ac..4fabee7e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,12 +9,19 @@ exclude: > test.*\.html| test.*\.xml| .*commonmark\.json| - benchmark/.*\.md| + benchmarking/.*\.md| .*/spec\.md )$ repos: + - repo: https://github.com/executablebooks/mdformat + rev: 0.7.4 + hooks: + - id: mdformat + args: [--number] + additional_dependencies: [mdformat-myst==0.1.2] + - repo: https://github.com/pre-commit/pre-commit-hooks rev: v3.4.0 hooks: diff --git a/CHANGELOG.md b/CHANGELOG.md index e0ef80ee..e5f870f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,8 +44,8 @@ There are four notable (and breaking) changes: This release brings Markdown-It-Py inline with Markdown-It v11.0.1 (2020-09-14), applying two fixes: -- Fix blockquote lazy newlines, [[#696](https://github.com/markdown-it/markdown-it/issues/696)]. -- Fix missed mappings for table rows, [[#705](https://github.com/markdown-it/markdown-it/issues/705)]. +- Fix blockquote lazy newlines, \[[#696](https://github.com/markdown-it/markdown-it/issues/696)\]. +- Fix missed mappings for table rows, \[[#705](https://github.com/markdown-it/markdown-it/issues/705)\]. Thanks to [@hukkinj1](https://github.com/hukkinj1)! @@ -135,19 +135,19 @@ md = MarkdownIt().use(tasklists_plugin) - ✨ NEW: Add simple typographic replacements, thanks to [@tsutsu3](https://github.com/tsutsu3): This allows you to add the `typographer` option to the parser, to replace particular text constructs: - - ``(c)``, ``(C)`` → © - - ``(tm)``, ``(TM)`` → ™ - - ``(r)``, ``(R)`` → ® - - ``(p)``, ``(P)`` → § - - ``+-`` → ± - - ``...`` → … - - ``?....`` → ?.. - - ``!....`` → !.. - - ``????????`` → ??? - - ``!!!!!`` → !!! - - ``,,,`` → , - - ``--`` → &ndash - - ``---`` → &mdash + - `(c)`, `(C)` → © + - `(tm)`, `(TM)` → ™ + - `(r)`, `(R)` → ® + - `(p)`, `(P)` → § + - `+-` → ± + - `...` → … + - `?....` → ?.. + - `!....` → !.. + - `????????` → ??? + - `!!!!!` → !!! + - `,,,` → , + - `--` → &ndash + - `---` → &mdash ```python md = MarkdownIt().enable("replacements") @@ -155,7 +155,9 @@ md = MarkdownIt().use(tasklists_plugin) ``` - 📚 DOCS: Improve documentation for CLI, thanks to [@westurner](https://github.com/westurner) + - 👌 IMPROVE: Use `re.sub()` instead of `re.subn()[0]`, thanks to [@hukkinj1](https://github.com/hukkinj1) + - 🐛 FIX: An exception raised by having multiple blank lines at the end of some files ## 0.5.5 - 2020-09-27 diff --git a/README.md b/README.md index 599c1f9f..1bd11507 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # markdown-it-py -[![Github-CI][github-ci]][github-link] +[![Github-CI]][github-link] [![Coverage Status][codecov-badge]][codecov-link] [![PyPI][pypi-badge]][pypi-link] [![Conda][conda-badge]][conda-link] @@ -127,22 +127,20 @@ Big thanks to the authors of [markdown-it]: Also [John MacFarlane](https://github.com/jgm) for his work on the CommonMark spec and reference implementations. -[github-ci]: https://github.com/executablebooks/markdown-it-py/workflows/Python%20package/badge.svg?branch=master -[github-link]: https://github.com/executablebooks/markdown-it-py -[pypi-badge]: https://img.shields.io/pypi/v/markdown-it-py.svg -[pypi-link]: https://pypi.org/project/markdown-it-py -[conda-badge]: https://anaconda.org/conda-forge/markdown-it-py/badges/version.svg -[conda-link]: https://anaconda.org/conda-forge/markdown-it-py -[codecov-badge]: https://codecov.io/gh/executablebooks/markdown-it-py/branch/master/graph/badge.svg -[codecov-link]: https://codecov.io/gh/executablebooks/markdown-it-py [black-badge]: https://img.shields.io/badge/code%20style-black-000000.svg [black-link]: https://github.com/ambv/black +[codecov-badge]: https://codecov.io/gh/executablebooks/markdown-it-py/branch/master/graph/badge.svg +[codecov-link]: https://codecov.io/gh/executablebooks/markdown-it-py +[conda-badge]: https://anaconda.org/conda-forge/markdown-it-py/badges/version.svg +[conda-link]: https://anaconda.org/conda-forge/markdown-it-py +[github-ci]: https://github.com/executablebooks/markdown-it-py/workflows/Python%20package/badge.svg?branch=master +[github-link]: https://github.com/executablebooks/markdown-it-py [install-badge]: https://img.shields.io/pypi/dw/markdown-it-py?label=pypi%20installs [install-link]: https://pypistats.org/packages/markdown-it-py - -[CommonMark spec]: http://spec.commonmark.org/ [markdown-it]: https://github.com/markdown-it/markdown-it [markdown-it-readme]: https://github.com/markdown-it/markdown-it/blob/master/README.md -[md-security]: https://markdown-it-py.readthedocs.io/en/latest/other.html [md-performance]: https://markdown-it-py.readthedocs.io/en/latest/other.html [md-plugins]: https://markdown-it-py.readthedocs.io/en/latest/plugins.html +[md-security]: https://markdown-it-py.readthedocs.io/en/latest/other.html +[pypi-badge]: https://img.shields.io/pypi/v/markdown-it-py.svg +[pypi-link]: https://pypi.org/project/markdown-it-py diff --git a/docs/architecture.md b/docs/architecture.md index bfc49c27..f6b1adc1 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -40,7 +40,6 @@ An `env` sandbox can be used alongside tokens to inject external variables for y Each chain (core / block / inline) uses an independent `state` object when parsing data, so that each parsing operation is independent and can be disabled on the fly. - ## Token stream Instead of traditional AST we use more low-level data representation - *tokens*. @@ -73,7 +72,6 @@ More details about tokens: - [Token source](https://github.com/executablebooks/markdown-it-py/tree/master/markdown_it/token.py) - [Live demo](https://markdown-it.github.io/) - type your text and click `debug` tab. - ## Rules Rules are functions, doing "magic" with parser `state` objects. A rule is associated with one or more *chains* and is unique. For instance, a `blockquote` token is associated with `blockquote`, `paragraph`, `heading` and `list` chains. @@ -93,7 +91,6 @@ Also, in complex cases you can try to ask for help in tracker. Condition is very simple - it should be clear from your ticket, that you studied docs, sources, and tried to do something yourself. We never reject with help to real developers. - ## Renderer After the token stream is generated, it's passed to a [renderer](https://github.com/executablebooks/markdown-it-py/tree/master/markdown_it/renderer.py). @@ -157,7 +154,6 @@ renderer override, but can be more simple. You also can write your own renderer to generate other formats than HTML, such as JSON/XML... You can even use it to generate AST. - ## Summary This was mentioned in [Data flow](#data-flow), but let's repeat sequence again: diff --git a/docs/contributing.md b/docs/contributing.md index 9469d0ee..04326054 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -68,14 +68,14 @@ For documentation build tests: Where possible try to port directly from that. It is usually better to modify existing code, instead of writing all from scratch. 2. Try to find the right place for your plugin rule: - - Will it conflict with existing markup (by priority)? - - If yes - you need to write an inline or block rule. - - If no - you can morph tokens within core chains. - - Remember that token morphing in core chains is always more simple than writing - block or inline rules, if you don't copy existing ones. However, - block and inline rules are usually faster. - - Sometimes, it's enough to only modify the renderer, for example, to add - header IDs or `target="_blank"` for the links. + - Will it conflict with existing markup (by priority)? + - If yes - you need to write an inline or block rule. + - If no - you can morph tokens within core chains. + - Remember that token morphing in core chains is always more simple than writing + block or inline rules, if you don't copy existing ones. However, + block and inline rules are usually faster. + - Sometimes, it's enough to only modify the renderer, for example, to add + header IDs or `target="_blank"` for the links. ## FAQ diff --git a/docs/index.md b/docs/index.md index de6ee1b5..29ee53f1 100644 --- a/docs/index.md +++ b/docs/index.md @@ -28,8 +28,9 @@ Also [John MacFarlane](https://github.com/jgm) for his work on the CommonMark sp - - CommonMark forum, good place to collaborate developers' efforts. ```{toctree} -:maxdepth: 2 - +--- +maxdepth: 2 +--- using architecture other diff --git a/docs/using.md b/docs/using.md index 5c977b5a..ca7748fa 100644 --- a/docs/using.md +++ b/docs/using.md @@ -124,19 +124,19 @@ The `smartquotes` and `replacements` components are intended to improve typograp `replacements` will replace particular text constructs: -- ``(c)``, ``(C)`` → © -- ``(tm)``, ``(TM)`` → ™ -- ``(r)``, ``(R)`` → ® -- ``(p)``, ``(P)`` → § -- ``+-`` → ± -- ``...`` → … -- ``?....`` → ?.. -- ``!....`` → !.. -- ``????????`` → ??? -- ``!!!!!`` → !!! -- ``,,,`` → , -- ``--`` → &ndash -- ``---`` → &mdash +- `(c)`, `(C)` → © +- `(tm)`, `(TM)` → ™ +- `(r)`, `(R)` → ® +- `(p)`, `(P)` → § +- `+-` → ± +- `...` → … +- `?....` → ?.. +- `!....` → !.. +- `????????` → ??? +- `!!!!!` → !!! +- `,,,` → , +- `--` → &ndash +- `---` → &mdash Both of these components require typography to be turned on, as well as the components enabled: