Skip to content

Commit 424a122

Browse files
committed
upgrade mistune to 2.x
1 parent 3e9a646 commit 424a122

File tree

3 files changed

+26
-27
lines changed

3 files changed

+26
-27
lines changed

index.mako

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ _new in 2.8.0_: `pre-commit` now exits with more specific codes:
844844
- `3`: an unexpected error
845845
- `130`: the process was interrupted by `^C`
846846
847-
## pre-commit autoupdate [options] [](#pre-commit-autoupdate)
847+
## pre-commit autoupdate [options] #pre-commit-autoupdate
848848
849849
Auto-update pre-commit config to the latest repos' versions.
850850
@@ -901,13 +901,13 @@ $ grep rev: .pre-commit-config.yaml
901901
rev: 34a269fd7650d264e4de7603157c10d0a9bb8211 # frozen: v1.25.2
902902
```
903903
904-
## pre-commit clean [options] [](#pre-commit-clean)
904+
## pre-commit clean [options] #pre-commit-clean
905905
906906
Clean out cached pre-commit files.
907907
908908
Options: (no additional options)
909909
910-
## pre-commit gc [options] [](#pre-commit-gc)
910+
## pre-commit gc [options] #pre-commit-gc
911911
912912
_new in 1.14.0_
913913
@@ -919,7 +919,7 @@ the cache directory.
919919
920920
Options: (no additional options)
921921
922-
## pre-commit init-templatedir DIRECTORY [options] [](#pre-commit-init-templatedir)
922+
## pre-commit init-templatedir DIRECTORY [options] #pre-commit-init-templatedir
923923
924924
_new in 1.18.0_
925925
@@ -942,7 +942,7 @@ pre-commit init-templatedir ~/.git-template
942942
Now whenever a repository is cloned or created, it will have the hooks set up
943943
already!
944944
945-
## pre-commit install [options] [](#pre-commit-install)
945+
## pre-commit install [options] #pre-commit-install
946946
947947
Install the pre-commit script.
948948
@@ -967,7 +967,7 @@ Some example useful invocations:
967967
existing git hook scripts with pre-commit, and also installs hook
968968
environments.
969969
970-
## pre-commit install-hooks [options] [](#pre-commit-install-hooks)
970+
## pre-commit install-hooks [options] #pre-commit-install-hooks
971971
972972
Install all missing environments for the available hooks. Unless this command or
973973
`install --install-hooks` is executed, each hook's environment is created the
@@ -981,15 +981,15 @@ the hook environments in one command, use `pre-commit install --install-hooks`.
981981
982982
Options: (no additional options)
983983
984-
## pre-commit migrate-config [options] [](#pre-commit-migrate-config)
984+
## pre-commit migrate-config [options] #pre-commit-migrate-config
985985
986986
_new in 1.0.0_
987987
988988
Migrate list configuration to the new map configuration format.
989989
990990
Options: (no additional options)
991991
992-
## pre-commit run [hook-id] [options] [](#pre-commit-run)
992+
## pre-commit run [hook-id] [options] #pre-commit-run
993993
994994
Run hooks.
995995
@@ -1019,13 +1019,13 @@ Some example useful invocations:
10191019
have changed between `HEAD^^^` and `HEAD`. This form is useful when
10201020
leveraged in a pre-receive hook.
10211021
1022-
## pre-commit sample-config [options] [](#pre-commit-sample-config)
1022+
## pre-commit sample-config [options] #pre-commit-sample-config
10231023
10241024
Produce a sample `.pre-commit-config.yaml`.
10251025
10261026
Options: (no additional options)
10271027
1028-
## pre-commit try-repo REPO [options] [](#pre-commit-try-repo)
1028+
## pre-commit try-repo REPO [options] #pre-commit-try-repo
10291029
10301030
_new in 1.3.0_
10311031
@@ -1053,7 +1053,7 @@ Some example useful invocations:
10531053
- See [`pre-commit run`](#pre-commit-run) for more useful `run` invocations
10541054
which are also supported by `pre-commit try-repo`.
10551055
1056-
## pre-commit uninstall [options] [](#pre-commit-uninstall)
1056+
## pre-commit uninstall [options] #pre-commit-uninstall
10571057
10581058
Uninstall the pre-commit script.
10591059

requirements-dev.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
mako
22
libsass
3-
markdown-code-blocks
3+
markdown-code-blocks>=3.0.0
44
markdown-to-presentation>=0.0.12
5-
# remove once merged and release
6-
git+https://github.com/lepture/mistune@449c2b5
75
pre-commit>=1.21.0
86
pygments-pre-commit>=1.4.0

template_lib.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import markupsafe
1010

1111

12-
ID_RE = re.compile(r'\[\]\(#([a-z0-9-]+)\)')
12+
ID_RE = re.compile(r' #([a-z0-9-]+)$')
1313
SPECIAL_CHARS_RE = re.compile('[^a-z0-9 _-]')
1414

1515

@@ -94,16 +94,17 @@ def link(
9494
) -> str:
9595
if link.startswith(SELF_LINK_PREFIX):
9696
a_id = link[len(SELF_LINK_PREFIX):]
97-
return f'<a id="{a_id}" href="#{a_id}">{title}</a>'
97+
return f'<a id="{a_id}" href="#{a_id}">{text}</a>'
9898
else:
9999
return super().link(link, text, title)
100100

101-
def header(self, text: str, level: int, raw: str) -> str:
102-
match = ID_RE.search(raw)
101+
def heading(self, text: str, level: int) -> str:
102+
match = ID_RE.search(text)
103+
text = ID_RE.sub('', text)
103104
if match:
104-
h_id = match.group(1)
105+
h_id = match[1]
105106
else:
106-
h_id = SPECIAL_CHARS_RE.sub('', raw.lower()).replace(' ', '-')
107+
h_id = SPECIAL_CHARS_RE.sub('', text.lower()).replace(' ', '-')
107108
return (
108109
f'<h{level} id="{h_id}">'
109110
f' {text} <small><a href="#{h_id}">¶</a></small>'
@@ -117,18 +118,18 @@ def codespan(self, text: str) -> str:
117118
else:
118119
return super().codespan(text)
119120

120-
def block_code(self, code: str, lang: Optional[str]) -> str:
121+
def block_code(self, code: str, info: Optional[str] = None) -> str:
121122
copyable = False
122-
if lang is not None:
123+
if info is not None:
123124
copyable_s = '#copyable'
124-
copyable = lang.endswith(copyable_s)
125-
lang, _, _ = lang.partition(copyable_s)
126-
if lang == 'table':
125+
copyable = info.endswith(copyable_s)
126+
info, _, _ = info.partition(copyable_s)
127+
if info == 'table':
127128
ret = _render_table(code)
128-
elif lang == 'cmd':
129+
elif info == 'cmd':
129130
ret = _render_cmd(code)
130131
else:
131-
ret = super().block_code(code, lang)
132+
ret = super().block_code(code, info)
132133
if copyable:
133134
return f'<div class="copyable">{ret}</div>'
134135
else:

0 commit comments

Comments
 (0)