๐Ÿ”ง Include tests/ and tox.ini in the sdist (#426)

## Summary

Supersedes #420 by @BetterAndBetterII (GitHub refused to update that
fork branch because the merge would carry workflow-file changes); their
commits are carried here verbatim with authorship preserved (thank
you!). Closes #261, open since 2023 from a distro packager.

PyPI sdists shipped `tox.ini` but omitted `tests/`, so packagers could
not run the suite from the tarball. `tests/` is moved out of
`[tool.flit.sdist] exclude` and `tests/` plus `tox.ini` are explicitly
included; `docs/` and `benchmarking/` stay excluded.

## Commits

1. `fix: include tests/ (and tox.ini) in the flit sdist` and the
pre-commit.ci autofix โ€” the contributor's commits, unchanged.
2. `๐Ÿงช TEST: Assert sdist contents by building the sdist` โ€” the original
test only string-matched `pyproject.toml`. It now builds a real sdist
with `flit_core` (no network, ~0.15 s) and asserts
`markdown_it/__init__.py`, `tests/test_api/test_main.py` and `tox.ini`
are members and nothing under `docs/` or `benchmarking/` is. It skips
cleanly when `flit_core` is unavailable or when not run from a source
checkout. Verified negative: with the `include` reverted, the test fails
on `tests/test_api/test_main.py`.

## Verification

- 994 tests pass; the sdist test runs (not skipped) with flit_core
4.0.2, which is what `pyproject.toml` now allows after #414.
- All pre-commit hooks pass under the new pins.
- No changelog entry in the commits; suggest adding one at release time
under ๐Ÿ”ง.

---------

Co-authored-by: Yuzhong Zhang <BetterAndBetterII@users.noreply.github.com>
GitOrigin-RevId: 2700cc3c3c46f8c23bfaa71b2c582b7b991fd6c6
Change-Id: I839d06433110ff5a2528a3d22a6914cebd0dcd36
1 file changed
tree: f9f70e7e94371d66190ea1f90307284f304305a1
  1. .github/
  2. docs/
  3. markdown_it/
  4. scripts/
  5. .gitignore
  6. .pre-commit-config.yaml
  7. .readthedocs.yml
  8. AGENTS.md
  9. CHANGELOG.md
  10. codecov.yml
  11. LICENSE
  12. LICENSE.markdown-it
  13. pyproject.toml
  14. README.md
  15. SECURITY.md
  16. tox.ini
README.md

markdown-it-py

Github-CI Coverage Status PyPI Conda PyPI - Downloads

Markdown parser done right.

This is a Python port of markdown-it, and some of its associated plugins. For more details see: https://markdown-it-py.readthedocs.io.

For details on markdown-it itself, see:

See also: markdown-it-pyrs for an experimental Rust binding, for even more speed!

Installation

PIP

pip install markdown-it-py[plugins]

or with extras

pip install markdown-it-py[linkify,plugins]

Conda

conda install -c conda-forge markdown-it-py

or with extras

conda install -c conda-forge markdown-it-py linkify-it-py mdit-py-plugins

Usage

Python API Usage

Render markdown to HTML with markdown-it-py and a custom configuration with and without plugins and features:

from markdown_it import MarkdownIt
from mdit_py_plugins.front_matter import front_matter_plugin
from mdit_py_plugins.footnote import footnote_plugin

md = (
    MarkdownIt("commonmark", {"breaks": True, "html": True})
    .use(front_matter_plugin)
    .use(footnote_plugin)
    .enable("table")
)
text = """
---
a: 1
---

a | b
- | -
1 | 2

A footnote [^1]

[^1]: some details
"""
tokens = md.parse(text)
html_text = md.render(text)

## To export the html to a file, uncomment the lines below:
# from pathlib import Path
# Path("output.html").write_text(html_text)

Command-line Usage

Render markdown to HTML with markdown-it-py from the command-line:

usage: markdown-it [-h] [-v] [--stdin] [--enable-tables] [filenames ...]

Parse one or more markdown files, convert each to HTML, and print to stdout

positional arguments:
  filenames        specify an optional list of files to convert

options:
  -h, --help       show this help message and exit
  -v, --version    show program's version number and exit
  --stdin          read Markdown from standard input
  --enable-tables  enable table parsing

Interactive:

  $ markdown-it
  markdown-it-py [version 0.0.0] (interactive)
  Type Ctrl-D to complete input, or Ctrl-C to exit.
  >>> # Example
  ... > markdown *input*
  ...
  <h1>Example</h1>
  <blockquote>
  <p>markdown <em>input</em></p>
  </blockquote>

Batch:

  $ markdown-it README.md README.footer.md > index.html

Tables are disabled by default, as in CommonMark. Use --enable-tables with any input mode to enable them:

markdown-it --enable-tables README.md > index.html
markdown-it --enable-tables --stdin < README.md > index.html
markdown-it --enable-tables

References / Thanks

Big thanks to the authors of markdown-it:

Also John MacFarlane for his work on the CommonMark spec and reference implementations.