[go: nahoru, domu]

Skip to content

Commit

Permalink
Python-Markdown's Markdown-in-HTML extension is now enabled (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
gpoore committed Jun 16, 2020
1 parent 136e930 commit fc362f7
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
for newlines in HTML comments. The preprocessor now skips backslash
escapes, inline code containing newlines, and fenced code blocks (as long as
they do not start on the same line as a list marker).
* Python-Markdown's Markdown-in-HTML extension is now enabled (#13).



Expand Down
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,34 @@ text, which typically appears as italics. Text can be styled using Markdown
notation, or with HTML. Remember to preview quizzes after conversion to QTI,
especially when using any significant amount of HTML.

Python-Markdown provides several
[extensions to basic Markdown](https://python-markdown.github.io/extensions/).
Currently, the following extensions are enabled:
* `smarty`: Automatic curly quotation marks and dashes.
* `sane_lists`: List behavior is closer to what might be expected.
* `def_list`: Definition lists of this form:
```
term
: definition
* `fenced_code`: Fenced code blocks (` ``` ` or `~~~`).
* `footnotes`: Footnotes using this form:
```
Normal text [^1].

[^1]: Footnote text.
* `tables`: Tables of this form:
```
Header | Header
------ | ------
Cell | Cell
Cell | Cell
```
* `md_in_html`: Text inside HTML tags is treated as Markdown. This requires
setting the attribute `markdown="1"` in the opening tag for block-level
elements. See the
[documentation](https://python-markdown.github.io/extensions/md_in_html/)
for more details about proper usage and potential issues.

While indented Markdown code blocks are supported, fenced code blocks should
be preferred. Indented code can interfere with the preprocessor that strips
HTML comments and handles LaTeX math and siunitx notation.
Expand Down
10 changes: 9 additions & 1 deletion text2qti/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,15 @@ class Markdown(object):
def __init__(self, config: Config):
self.config = config

md_extensions = ['smarty', 'sane_lists', 'def_list', 'fenced_code', 'footnotes', 'tables']
md_extensions = [
'smarty',
'sane_lists',
'def_list',
'fenced_code',
'footnotes',
'tables',
'md_in_html',
]
markdown_processor = markdown.Markdown(extensions=md_extensions)
markdown_image_processor = Text2qtiImagePattern(IMAGE_LINK_RE, markdown_processor, self)
markdown_processor.inlinePatterns.register(markdown_image_processor, 'image_link', 150)
Expand Down
2 changes: 1 addition & 1 deletion text2qti/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-

from .fmtversion import get_version_plus_info
__version__, __version_info__ = get_version_plus_info(0, 4, 0, 'dev', 2)
__version__, __version_info__ = get_version_plus_info(0, 4, 0, 'dev', 3)

0 comments on commit fc362f7

Please sign in to comment.