Skip to content

Commit

Permalink
move to markdown-it-py
Browse files Browse the repository at this point in the history
this removes the dependency to myst-parser in exchange for just markdown-it-py
plus, a change in styling that was breaking the rendering of math equations
(was probably there before the change)

on remaining glitch with this version is that plain html gets quoted
  • Loading branch information
parmentelat committed Sep 5, 2020
1 parent a8f9635 commit f7e419a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
2 changes: 1 addition & 1 deletion binder/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ ipython
ipywidgets
numpy
PyYAML
myst_parser
markdown-it-py
# for the demo notebooks
jupytext
14 changes: 4 additions & 10 deletions nbautoeval/content.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# an earlier version was relying on markdown2
#from myst_parser.main import to_html, default_parser

from myst_parser.main import default_parser, MdParserConfig
from markdown_it import MarkdownIt

from ipywidgets import HTML, HTMLMath, Layout

Expand Down Expand Up @@ -75,9 +75,9 @@ class TextContent(Content):
several settings are available, which by default
are all turned off
is_code: will cause the whhole content to be taken as code
is_code: will cause the whole content to be taken as code
needs_math: will create a HTMLMath widget instead of plain HTML
has_markdown: text first goes through myst_parser
has_markdown: text first goes through a markdown stage
'''
def __init__(self, text,
is_code=False, needs_math=False, has_markdown=False,
Expand Down Expand Up @@ -117,13 +117,7 @@ def _widget_(self):

text = self.text
if self.has_markdown:
config = MdParserConfig(renderer="html")
parser = default_parser(config)

# math + markdown requires to turn off myst_parser's math
# capabilities, the math thingy gets managed by HTMLMath already
if self.needs_math:
parser.disable("math_single").disable("math_inline")
parser = MarkdownIt("commonmark")
text = parser.render(text)
if self.is_code:
text = f"<pre>{text}</pre>"
Expand Down
6 changes: 2 additions & 4 deletions nbautoeval/quiz.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,12 @@
padding-right: 6px;
}
.nbae-question.unanswered span/*.unanswered*/,
.nbae-question.partial span/*.partial*/,
.nbae-question.right span/*.right*/,
.nbae-question.wrong span/*.wrong*/ {
.nbae-question div.score span {
font-weight: bold;
font-size: larger;
padding: 4px;
}
.nbae-question.unanswered span.unanswered {
background-color: var(--question-bg-odd);
}
Expand Down

0 comments on commit f7e419a

Please sign in to comment.