Mistletoe

Latest version: v1.3.0

Safety actively analyzes 626513 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 3 of 5

0.7

**Warning**: this is a release that breaks backwards compatibility in non-trivial ways (hopefully for the last time!) Read the full release notes if you are updating from a previous version.

**Features**:

* all tests passing in CommonMark test suite (finally! :tada:)
* allow specifying span token precedence levels;
* new and shiny `span_tokenizer.tokenize`.

**Fixed**:

* well, all the CommonMark test cases..
* `ASTRenderer` crashes on tables with headers (48, thanks timfox456!)

**Where I break backwards compatibility**:

Previously span-level tokens need to have their `children` attribute manually specified. This is no longer the case, as the `children` attribute will automatically be set based on the class variable `parse_group`, which correspond to the regex match group in which child tokens might occur.

As an example, previously `GithubWiki` is implemented as this:

python
from mistletoe.span_token import SpanToken, tokenize_inner
import re

class GithubWiki(SpanToken):
pattern = re.compile(r'...')
def __init__(self, match_obj):
super().__init__(match_obj)
alternatively, self.children = tokenize_inner(match_obj.group(1))
self.target = match_obj.group(2)


Now we can write:

python
from mistletoe.span_token import SpanToken
import re

class GithubWiki(SpanToken):
pattern = re.compile(r'...')
parse_inner = True default value, can be omitted
parse_group = 1 default value, can be omitted
precedence = 5 default value, can be omitted
def __init__(self, match_obj):
self.target = match_obj.group(2)


If we have a span token that does not need further parsing, we can write:

python
class Foo(SpanToken):
pattern = re.compile(r'(foo)')
parse_inner = False
def __init__(self, match_obj):
self.content = match_obj.group(1)


See the readme for more details.

0.6.2

**Features**:

* CommonMark compliant `CodeFence`;
* CommonMark compliant `BlockCode`;
* CommonMark compliant `HTMLBlock`;
* CommonMark compliant `HTMLSpan`;
* CommonMark compliant `AutoLink`;
* CommonMark compliant `InlineCode`;
* CommonMark compliant `Heading`;
* CommonMark compliant `SetextHeading`;
* added span-level token `LineBreak`;
* better handling of lazy-continuation in `Quote`;
* `Footnote`s can be defined in any block-level containers.

**Fixes**:

* loose lists conform to CommonMark spec (44, thanks huettenhain);
* not parsing sub-lists deeper than two levels (46, thanks daerhu);
* `FileWrapper._index` should not go below -1.

**Development**:

* refactored handling of `SetextHeading`;
* removed `block_tokenizer.MismatchException`;
* removed `_children` attribute, using `children` directly; (potentially breaking change?)
* renamed `Separator` to `ThematicBreak`;
* renamed `FootnoteBlock` to `Footnote`;
* `tokenize` and `tokenize_inner` returns lists of tokens;
* refactored CommonMark testing script.

0.6.1

**Features**:

* CommonMark compliant `CodeFence` (41);
* allow multiple backticks for `InlineCode`;
* strips whitespace around `InlineCode`;

**Fixed**:

* `Separator` needs at least three characters;
* indented code blocks should not interrupt paragraphs (40, thanks joncass);
* crashes when sublists have different marker type (42, thanks JBartlett86);
* typo in `Paragraph.read` (43, thanks NatTupper);
* preliminary fixes for handling loose lists (44, thanks huettenhain);
* removed corrupted `block_token.until` function;
* html code language tags starts with "`language-`".

0.6

**Features:**

* added Pygments renderer to `contrib` (35, thanks to Bridouz);
* `HTMLSpan` now supports comments (37);
* (more or less) Commonmark compliant List implementation (40).

**Fixes:**

* changed logo to an actual mistletoe (21, thanks to liuq);
* allow lists after block tokens without newlines (34, thanks to huettenhain);
* recognize headings within paragraphs (36);
* disallow opening space in html tag (37).

**Performance**:

* removed `FileWrapper.normalize`;
* utilized universal newline mode.

**Breaking changes**:

* `BlockToken.start` does not advance file iterator.

Special shout-out to joncass for raising the unattributed issues above, and giving me the motivation to finally fix the list implementation!

Note that this is a release with major changes. If you notice any rough edges (as there will certainly be), please do not hesitate to open an issue.

0.5.5

**Features:**

* added default render methods for all tokens;
* added `reset_tokens` function to `block_token` and `span_token`;
* allowed `BlockToken.read` to return any iterable;
* BaseRenderer is now available at mistletoe.BaseRenderer;
* added Scheme.

**Fixes:**

* throw better `AttributeError` when accessing `RawText.children` (31, thanks jabdoa2);
* disallow whitespace in `span_token.Link` (32, thanks DMRobertson);
* allowed empty alt text in `Image` and `FootnoteImage` (33, thanks joncass).

0.5.4

**Features**:

* md2jira: read from stdin if no input file is given (27, thanks alexkolson!);
* better command line options and help messages;
* auto-splitlines when `mistletoe.markdown` is given a string;
* inline tokens can span multiple lines (30, thanks duckwork!).

**Fixes**:

* TableRow now supports table shorthand (29, thanks huettenhain!);
* normalize line breaks.

... plus various refactors and documentation improvements.

Page 3 of 5

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.