Skip to content

Commit

Permalink
CommonMark backend: replace recommonmark with MyST
Browse files Browse the repository at this point in the history
recommonmark was deprectated in in May 2021
  • Loading branch information
brechtm committed Oct 19, 2022
1 parent 557e3db commit b2d080b
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 39 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ New Features:

Changed:

* `MyST <https://github.com/executablebooks/MyST-Parser>`_ replaces
`recommonmark <https://github.com/readthedocs/recommonmark>`_ for Markdown
support (issues #265 and #370)
* The Article template has been overhauled. The title page and front matter
parts have been removed and their contents are moved to the first content
page. This makes the Article template more useful, since it was too similar
Expand Down
169 changes: 136 additions & 33 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ python = "^3.7.0"
appdirs = "^1.4.3"
docutils = ">=0.15"
importlib-metadata = {version = ">=0.21", python = "<3.8"}
myst-parser = "^0.18.1"
packaging = ">=14.0"
recommonmark = ">=0.6.0"
rinoh-typeface-dejavuserif = "^0.1.3"
rinoh-typeface-texgyrecursor = "^0.1.1"
rinoh-typeface-texgyreheros = "^0.1.1"
Expand Down
4 changes: 2 additions & 2 deletions src/rinoh/frontend/commonmark/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Use of this source code is subject to the terms of the GNU Affero General
# Public License v3. See the LICENSE file or http://www.gnu.org/licenses/.

from recommonmark.parser import CommonMarkParser
from myst_parser.docutils_ import Parser

from ..rst import DocutilsReader

Expand All @@ -15,4 +15,4 @@

class CommonMarkReader(DocutilsReader):
extensions = ('md', )
parser_class = CommonMarkParser
parser_class = Parser
6 changes: 3 additions & 3 deletions src/rinoh/frontend/rst/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,9 @@ class Literal_Block(DocutilsBodyNode):
@property
def language(self):
classes = self.get('classes')
if classes and classes[0] == 'code': # .. code::
return classes[1]
return None # literal block (double colon)
if len(classes) > 1 and classes[0] == 'code': # .. code::
return classes[1] # (MyST doesn't add the
return None # literal block (double colon) language as class)

def build_flowable(self):
return rt.CodeBlock(self.text, language=self.language,
Expand Down

0 comments on commit b2d080b

Please sign in to comment.