Skip to content

Commit b2d080b

Browse files
committed
CommonMark backend: replace recommonmark with MyST
recommonmark was deprectated in in May 2021
1 parent 557e3db commit b2d080b

File tree

5 files changed

+145
-39
lines changed

5 files changed

+145
-39
lines changed

CHANGES.rst

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ New Features:
3232

3333
Changed:
3434

35+
* `MyST <https://github.com/executablebooks/MyST-Parser>`_ replaces
36+
`recommonmark <https://github.com/readthedocs/recommonmark>`_ for Markdown
37+
support (issues #265 and #370)
3538
* The Article template has been overhauled. The title page and front matter
3639
parts have been removed and their contents are moved to the first content
3740
page. This makes the Article template more useful, since it was too similar

poetry.lock

+136-33
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ python = "^3.7.0"
8888
appdirs = "^1.4.3"
8989
docutils = ">=0.15"
9090
importlib-metadata = {version = ">=0.21", python = "<3.8"}
91+
myst-parser = "^0.18.1"
9192
packaging = ">=14.0"
92-
recommonmark = ">=0.6.0"
9393
rinoh-typeface-dejavuserif = "^0.1.3"
9494
rinoh-typeface-texgyrecursor = "^0.1.1"
9595
rinoh-typeface-texgyreheros = "^0.1.1"

src/rinoh/frontend/commonmark/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Use of this source code is subject to the terms of the GNU Affero General
66
# Public License v3. See the LICENSE file or http://www.gnu.org/licenses/.
77

8-
from recommonmark.parser import CommonMarkParser
8+
from myst_parser.docutils_ import Parser
99

1010
from ..rst import DocutilsReader
1111

@@ -15,4 +15,4 @@
1515

1616
class CommonMarkReader(DocutilsReader):
1717
extensions = ('md', )
18-
parser_class = CommonMarkParser
18+
parser_class = Parser

src/rinoh/frontend/rst/nodes.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,9 @@ class Literal_Block(DocutilsBodyNode):
349349
@property
350350
def language(self):
351351
classes = self.get('classes')
352-
if classes and classes[0] == 'code': # .. code::
353-
return classes[1]
354-
return None # literal block (double colon)
352+
if len(classes) > 1 and classes[0] == 'code': # .. code::
353+
return classes[1] # (MyST doesn't add the
354+
return None # literal block (double colon) language as class)
355355

356356
def build_flowable(self):
357357
return rt.CodeBlock(self.text, language=self.language,

0 commit comments

Comments
 (0)