Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

❗️ REFACTOR markdown links #613

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f63f988
✨ NEW: suppress warnings in docutils
chrisjsewell Aug 27, 2022
4586448
❗️ REFACTOR markdown links
chrisjsewell Aug 31, 2022
5e08e30
Improve intersphinx support
chrisjsewell Sep 2, 2022
ef0b9ac
Update test_basic.sphinx4.html
chrisjsewell Sep 2, 2022
129a1c1
Update myst_refs.py
chrisjsewell Sep 2, 2022
b79f7ff
refactor `myst:inv`
chrisjsewell Sep 3, 2022
eaeeba2
change how project works
chrisjsewell Sep 4, 2022
945f1c8
more tests
chrisjsewell Sep 4, 2022
5a2806f
Update test_myst_refs.py
chrisjsewell Sep 4, 2022
5057006
Add `objects` builder
chrisjsewell Sep 4, 2022
ed700b9
fix tests
chrisjsewell Sep 4, 2022
eebc76a
Replace explicit sphinx references with
chrisjsewell Sep 4, 2022
6643c4f
Add auto-documenting of warnings
chrisjsewell Sep 4, 2022
356dea7
change warning name
chrisjsewell Sep 4, 2022
986f093
add render_math_block_label to docutils
chrisjsewell Sep 4, 2022
6fa0947
add tests for building other formats
chrisjsewell Sep 5, 2022
4e8ae8e
Change to unix pattern matching
chrisjsewell Sep 5, 2022
f51d20b
Update documentation
chrisjsewell Sep 6, 2022
4f5e463
Refactor the refactor
chrisjsewell Sep 8, 2022
eebd3f0
more documentation
chrisjsewell Sep 8, 2022
6536f59
Allow for referencing math
chrisjsewell Sep 9, 2022
83e22bd
Update test_myst_refs.py
chrisjsewell Sep 9, 2022
7d40454
Collect reference numbering
chrisjsewell Sep 9, 2022
c7f32a7
change `_#` to `.#` for local only links
chrisjsewell Sep 9, 2022
6524c8d
Add link text `{name}` `{number}` placeholders
chrisjsewell Sep 11, 2022
aca0a01
Update syntax.md
chrisjsewell Sep 11, 2022
f55a99f
Update syntax.md
chrisjsewell Sep 11, 2022
43c4dc8
Move project inventory load to single event
chrisjsewell Sep 11, 2022
b62132f
Big update, mainly about exposing numbering
chrisjsewell Sep 12, 2022
ba92cdd
Prioritise local anchor links, and remove warning
chrisjsewell Sep 13, 2022
c96505d
fix test
chrisjsewell Sep 13, 2022
f468ad0
Warn if anchor superseding other matches
chrisjsewell Sep 13, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
67 changes: 65 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
python-version: ["3.7", "3.9", "3.10"]
sphinx: [">=5,<6"]
os: [ubuntu-latest]
include:
Expand Down Expand Up @@ -103,10 +103,73 @@ jobs:
- name: Run docutils CLI
run: echo "test" | myst-docutils-html

doc-builds:

name: Documentation builds
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
format: ["man", "text"]

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[linkify,rtd]
- name: Build docs
run: |
sphinx-build -nW --keep-going -b ${{ matrix.format }} docs/ docs/_build/${{ matrix.format }}

doc-build-pdf:

name: Documentation PDF build
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[linkify,rtd]
- name: Build docs
run: |
sphinx-build -nW --keep-going -b latex docs/ docs/_build/latex

- name: Run PDF build
uses: xu-cheng/latex-action@v2
with:
working_directory: docs/_build/latex
root_file: "mystparser.tex"
# https://github.com/marketplace/actions/github-action-for-latex#it-fails-due-to-xindy-cannot-be-found
pre_compile: |
ln -sf /opt/texlive/texdir/texmf-dist/scripts/xindy/xindy.pl /opt/texlive/texdir/bin/x86_64-linuxmusl/xindy
ln -sf /opt/texlive/texdir/texmf-dist/scripts/xindy/texindy.pl /opt/texlive/texdir/bin/x86_64-linuxmusl/texindy
wget https://sourceforge.net/projects/xindy/files/xindy-source-components/2.4/xindy-kernel-3.0.tar.gz
tar xf xindy-kernel-3.0.tar.gz
cd xindy-kernel-3.0/src
apk add make
apk add clisp --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community
make
cp -f xindy.mem /opt/texlive/texdir/bin/x86_64-linuxmusl/
cd ../../
env:
XINDYOPTS: -L english -C utf8 -M sphinx.xdy

publish:

name: Publish myst-parser to PyPi
needs: [pre-commit, tests, check-myst-docutils]
needs: [pre-commit, tests, check-myst-docutils, doc-builds]
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
runs-on: ubuntu-latest
steps:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,4 @@ _archive/

.vscode/
.DS_Store
TODO.md
8 changes: 4 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ In addition, configuration to more finely tune this behaviour has been added.
- `myst_url_schemes=("http", "https")`, sets what URL schemes are treated as (1)
- `myst_ref_domains=("std", "py")`, sets what Sphinx reference domains are checked, when handling (3)

See [Markdown Links and Referencing](docs/syntax/syntax.md#markdown-links-and-referencing) for more information.
See [Markdown Links and Referencing](docs/syntax/syntax.md#links-and-referencing) for more information.

### ‼️ Dollarmath is now disabled by default

Expand Down Expand Up @@ -363,7 +363,7 @@ In particular for users, this update alters the parsing of tables to be consiste

### New Features ✨

- **Task lists** utilise the [markdown-it-py tasklists plugin](markdown_it:md/plugins), and are applied to Markdown list items starting with `[ ]` or `[x]`.
- **Task lists** utilise the [markdown-it-py tasklists plugin](myst:markdown_it#md/plugins), and are applied to Markdown list items starting with `[ ]` or `[x]`.

```markdown
- [ ] An item that needs doing
Expand Down Expand Up @@ -437,7 +437,7 @@ A warning (of type `myst.nested_header`) is now emitted when this occurs.
- ✨ NEW: Add warning types `myst.subtype`:
All parsing warnings are assigned a type/subtype, and also the messages are appended with them.
These warning types can be suppressed with the sphinx `suppress_warnings` config option.
See [How-to suppress warnings](howto/warnings) for more information.
See [How-to suppress warnings](#myst-warnings) for more information.

## 0.13.3 - 2021-01-20

Expand Down Expand Up @@ -596,7 +596,7 @@ I’m an inline image: <img src="img/fun-fish.png" height="20px">
## 0.12.7 - 2020-08-31

✨ NEW: Want to include your README.md in the documentation?
: See [including a file from outside the docs folder](howto/include-readme).
: See [including a file from outside the docs folder](#howto/include-readme).

(👌 added `relative-docs` option in 0.12.8)

Expand Down
12 changes: 0 additions & 12 deletions docs/_static/custom.css
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
/** Add a counter before subsections **/
h1 {
counter-reset: subsection;
text-decoration: underline;
}
h2 {
counter-reset: subsubsection;
}
h2::before {
counter-increment: subsection;
content: counter(subsection) ". ";
}
h3::before {
counter-increment: subsubsection;
content: counter(subsection) "." counter(subsubsection) ". ";
}

/** No icon for admonitions with no-icon class */
.admonition > .admonition-title, div.admonition.no-icon > .admonition-title::before {
Expand Down
1 change: 0 additions & 1 deletion docs/api/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ Sphinx

.. autoclass:: myst_parser.mdit_to_docutils.sphinx_.SphinxRenderer
:special-members: __output__
:members: render_internal_link, render_math_block_label
:undoc-members:
:member-order: alphabetical
:show-inheritance:
Expand Down
80 changes: 44 additions & 36 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,40 @@
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

intersphinx_mapping = {
"python": ("https://docs.python.org/3.7", None),
"sphinx": ("https://www.sphinx-doc.org/en/master", None),
"markdown_it": ("https://markdown-it-py.readthedocs.io/en/latest", None),
}

autodoc_member_order = "bysource"

# -- Parsing Configuration ---------------------------------------------------

myst_enable_extensions = [
"dollarmath",
"amsmath",
"deflist",
"fieldlist",
"html_admonition",
"html_image",
"colon_fence",
"smartquotes",
"replacements",
"linkify",
"strikethrough",
"substitution",
"tasklist",
"attrs_image",
]
myst_number_code_blocks = ["typescript"]
myst_heading_anchors = 2
myst_link_placeholders = True
myst_footnote_transition = True
myst_dmath_double_inline = True
numfig = True
numfig_secnum_depth = 2


# -- Options for HTML output -------------------------------------------------

Expand Down Expand Up @@ -76,27 +110,6 @@
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]

myst_enable_extensions = [
"dollarmath",
"amsmath",
"deflist",
"fieldlist",
"html_admonition",
"html_image",
"colon_fence",
"smartquotes",
"replacements",
"linkify",
"strikethrough",
"substitution",
"tasklist",
"attrs_image",
]
myst_number_code_blocks = ["typescript"]
myst_heading_anchors = 2
myst_footnote_transition = True
myst_dmath_double_inline = True

rediraffe_redirects = {
"using/intro.md": "sphinx/intro.md",
"sphinx/intro.md": "intro.md",
Expand All @@ -112,24 +125,13 @@
"explain/index.md": "develop/background.md",
}

suppress_warnings = ["myst.strikethrough"]
# -- Options for LaTeX output -------------------------------------------------

latex_engine = "xelatex"

intersphinx_mapping = {
"python": ("https://docs.python.org/3.7", None),
"sphinx": ("https://www.sphinx-doc.org/en/master", None),
"markdown_it": ("https://markdown-it-py.readthedocs.io/en/latest", None),
}
# -- Options for Warnings -------------------------------------------------

# autodoc_default_options = {
# "show-inheritance": True,
# "special-members": "__init__, __enter__, __exit__",
# "members": True,
# # 'exclude-members': '',
# "undoc-members": True,
# # 'inherited-members': True
# }
autodoc_member_order = "bysource"
suppress_warnings = ["myst.strikethrough", "myst.strip", "myst.xref_not_explicit"]
nitpicky = True
nitpick_ignore = [
("py:class", "docutils.nodes.document"),
Expand Down Expand Up @@ -161,9 +163,15 @@ def setup(app: Sphinx):
DirectiveDoc,
DocutilsCliHelpDirective,
MystConfigDirective,
MystWarningsDirective,
StripMermaid,
StripSVGImages,
)

app.add_css_file("custom.css")
app.add_directive("myst-config", MystConfigDirective)
app.add_directive("myst-warnings", MystWarningsDirective)
app.add_directive("docutils-cli-help", DocutilsCliHelpDirective)
app.add_directive("doc-directive", DirectiveDoc)
app.add_post_transform(StripMermaid)
app.add_post_transform(StripSVGImages)
40 changes: 30 additions & 10 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Configuration specific to syntax extensions:
```

The following configuration variables are available at the document level.
These can be set in the document [front matter](syntax/frontmatter), under the `myst` key, e.g.
These can be set in the document [front matter](#syntax/frontmatter), under the `myst` key, e.g.

```yaml
---
Expand All @@ -64,28 +64,28 @@ Configuration specific to syntax extensions:

## List of syntax extensions

Full details in the [](syntax/extensions) section.
Full details in the <project:#syntax/extensions> section.

amsmath
: enable direct parsing of [amsmath](https://ctan.org/pkg/amsmath) LaTeX equations

colon_fence
: Enable code fences using `:::` delimiters, [see here](syntax/colon_fence) for details
: Enable code fences using `:::` delimiters, [see here](#syntax/colon_fence) for details

deflist
: Enable definition lists, [see here](syntax/definition-lists) for details
: Enable definition lists, [see here](#syntax/definition-lists) for details

dollarmath
: Enable parsing of dollar `$` and `$$` encapsulated math

fieldlist
: Enable field lists, [see here](syntax/fieldlists) for details
: Enable field lists, [see here](#syntax/fieldlists) for details

html_admonition
: Convert `<div class="admonition">` elements to sphinx admonition nodes, see the [HTML admonition syntax](syntax/html-admonition) for details
: Convert `<div class="admonition">` elements to sphinx admonition nodes, see the [HTML admonition syntax](#syntax/html-admonition) for details

html_image
: Convert HTML `<img>` elements to sphinx image nodes, [see here](syntax/images) for details
: Convert HTML `<img>` elements to sphinx image nodes, [see here](#syntax/images) for details

linkify
: Automatically identify "bare" web URLs and add hyperlinks
Expand All @@ -97,10 +97,30 @@ smartquotes
: Automatically convert standard quotations to their opening/closing variants

strikethrough
: Enable strikethrough syntax, [see here](syntax/strikethrough) for details
: Enable strikethrough syntax, [see here](#syntax/strikethrough) for details

substitution
: Substitute keys, [see here](syntax/substitutions) for details
: Substitute keys, [see here](#syntax/substitutions) for details

tasklist
: Add check-boxes to the start of list items, [see here](syntax/tasklists) for details
: Add check-boxes to the start of list items, [see here](#syntax/tasklists) for details

(myst-warnings)=
## Build Warnings

Below lists the MyST specific warnings that may be emitted during the build process. These will be prepended to the end of the warning message, e.g.

```
WARNING: Non-consecutive header level increase; H1 to H3 [myst.header]
```

**In general, if your build logs any warnings, you should either fix them or [raise an Issue](https://github.com/executablebooks/MyST-Parser/issues/new/choose) if you think the warning is erroneous.**

However, in some circumstances if you wish to suppress the warning you can use the [`suppress_warnings`](myst:sphinx#suppress_warnings) configuration option, e.g.

```python
suppress_warnings = ["myst.header"]
```

```{myst-warnings}
```
2 changes: 1 addition & 1 deletion docs/develop/background.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ but there is no community standard around various syntactic choices for these fe
Sphinx is a documentation generation framework written in Python. It heavily-utilizes
reStructuredText syntax, which is another markup language for writing documents. In
particular, Sphinx defines two extension points that are extremely useful:
**{ref}`in-line roles<sphinx:rst-roles-alt>`** and **{ref}`block-level directives <sphinx:rst-directives>`**.
[**in-line roles**](myst:sphinx#rst-roles-alt) and [**block-level directives**](myst:sphinx#rst-directives).

**This project is an attempt at combining the simplicity and readability of Markdown
with the power and flexibility of reStructuredText and the Sphinx platform.** It
Expand Down
6 changes: 5 additions & 1 deletion docs/docutils.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ $ echo "Hello World" | myst-docutils-html
$ myst-docutils-html hello-world.md
```

The commands are based on the [Docutils Front-End Tools](https://docutils.sourceforge.io/docs/user/tools.html), and so follow the same argument and options structure, included many of the MyST specific options detailed in [](sphinx/config-options).
The commands are based on the [Docutils Front-End Tools](https://docutils.sourceforge.io/docs/user/tools.html), and so follow the same argument and options structure, included many of the MyST specific options detailed in <project:#sphinx/config-options>.

:::{dropdown} Shared Docutils CLI Options
```{docutils-cli-help}
```
:::

:::{versionadded} 0.19.0
`myst-suppress-warnings` replicates the functionality of [sphinx's `suppress_warnings`](myst:sphinx#suppress_warnings) for `myst.` warnings in the `docutils` CLI.
:::

The CLI commands can also utilise the [`docutils.conf` configuration file](https://docutils.sourceforge.io/docs/user/config.html) to configure the behaviour of the CLI commands. For example:

```
Expand Down