Skip to content

Commit

Permalink
‼️ BREAKING: Set URL scheme defaults (#329)
Browse files Browse the repository at this point in the history
Set `myst_url_schemes` default to `("http", "https", "mailto", "ftp")`,
so that only these URL will be considered as external,
and references like `prefix:main` will be considered as internal references.
  • Loading branch information
choldgraf authored Jun 12, 2021
1 parent 2ebb51a commit 1b2bfd8
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
"substitution",
"tasklist",
]
myst_url_schemes = ("http", "https", "mailto")
myst_heading_anchors = 2
myst_footnote_transition = True
myst_dmath_double_inline = True
Expand Down
2 changes: 1 addition & 1 deletion docs/using/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ To do so, use the keywords beginning `myst_`.
- `["dollarmath"]`
- Enable Markdown extensions, [see here](syntax-optional) for details.
* - `myst_url_schemes`
- `None`
- `("http", "https", "mailto", "ftp")`
- [URI schemes](https://en.wikipedia.org/wiki/List_of_URI_schemes) that will be recognised as external URLs in `[](scheme:loc)` syntax, or set `None` to recognise all.
Other links will be resolved as internal cross-references.
* - `myst_heading_anchors`
Expand Down
4 changes: 2 additions & 2 deletions myst_parser/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Callable, Dict, Iterable, Optional, Tuple, Union
from typing import Callable, Dict, Iterable, Optional, Tuple, Union, cast

import attr
from attr.validators import (
Expand Down Expand Up @@ -81,7 +81,7 @@ def check_extensions(self, attribute, value):

# see https://en.wikipedia.org/wiki/List_of_URI_schemes
url_schemes: Optional[Iterable[str]] = attr.ib(
default=None,
default=cast(Optional[Iterable[str]], ("http", "https", "mailto", "ftp")),
validator=optional(deep_iterable(instance_of(str), instance_of((list, tuple)))),
)

Expand Down
1 change: 1 addition & 0 deletions tests/test_renderers/test_myst_refs.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
("ref", "(ref)=\n# Title\n[](ref)", False),
("ref_nested", "(ref)=\n# Title\n[*text*](ref)", False),
("duplicate", "(index)=\n# Title\n[](index)", True),
("ref_colon", "(ref:colon)=\n# Title\n[](ref:colon)", False),
],
)
def test_parse(test_name, text, should_warn, file_regression):
Expand Down
8 changes: 8 additions & 0 deletions tests/test_renderers/test_myst_refs/ref_colon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<document classes="tex2jax_ignore mathjax_ignore" ids="title ref-colon" names="title ref:colon" source="root/index.md" title="Title">
<title>
Title
<target refid="ref-colon">
<paragraph>
<reference internal="True" refid="ref-colon">
<inline classes="std std-ref">
Title

0 comments on commit 1b2bfd8

Please sign in to comment.