-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-work markdown fenced codeblock lexing
This primarily makes lexing of nested fenced codeblocks work but also added support for tilde-delimited blocks and corrected the end offset for blocks.
- Loading branch information
Showing
9 changed files
with
407 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
backticks: | ||
|
||
``` | ||
< | ||
> | ||
``` | ||
|
||
tildes: | ||
~~~ | ||
< | ||
> | ||
~~~ | ||
|
||
Fewer than three backticks is not enough: | ||
`` | ||
foo | ||
`` | ||
|
||
|
||
The closing code fence must use the same character as the opening fence: | ||
|
||
|
||
``` | ||
aaa | ||
~~~ | ||
``` | ||
|
||
|
||
The closing code fence must be at least as long as the opening fence: | ||
|
||
```` | ||
aaa | ||
``` | ||
`````` | ||
|
||
Nested: | ||
|
||
~~~~ | ||
~~~ | ||
aaa | ||
~~~ | ||
~~~~ | ||
|
||
|
||
Can't mix chars: | ||
|
||
~`~ | ||
foo | ||
~`~ | ||
|
||
|
||
This one gets closed by the end of document: | ||
``` | ||
some stuff here | ||
~~~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# {py:mod}`bytewax.connectors.demo` | ||
|
||
```{py:module} bytewax.connectors.demo | ||
``` | ||
|
||
```{autodoc2-docstring} bytewax.connectors.demo | ||
:parser: myst | ||
:allowtitles: | ||
``` | ||
|
||
## Data | ||
|
||
````{py:data} X | ||
:canonical: bytewax.connectors.demo.X | ||
:type: typing.TypeVar | ||
```{autodoc2-docstring} bytewax.connectors.demo.X | ||
:parser: myst | ||
``` | ||
```` | ||
|
||
|
||
## Classes | ||
|
||
`````{py:class} RandomMetricSource(metric_name: str, interval: datetime.timedelta = timedelta(seconds=0.7), count: int = sys.maxsize, next_random: typing.Callable[[], float] = lambda: random.randrange(0, 10)) | ||
:canonical: bytewax.connectors.demo.RandomMetricSource | ||
:Bases: | ||
- {py:obj}`~bytewax.inputs.FixedPartitionedSource``[`{py:obj}`~typing.Tuple``[`{py:obj}`~str``, `{py:obj}`~float``], `{py:obj}`~bytewax.connectors.demo._RandomMetricState``]` | ||
```{autodoc2-docstring} bytewax.connectors.demo.RandomMetricSource | ||
:parser: myst | ||
``` | ||
```{rubric} Initialization | ||
``` | ||
```{autodoc2-docstring} bytewax.connectors.demo.RandomMetricSource.__init__ | ||
:parser: myst | ||
``` | ||
````{py:method} list_parts() -> typing.List[str] | ||
:canonical: bytewax.connectors.demo.RandomMetricSource.list_parts | ||
```` | ||
````{py:method} build_part(now: datetime.datetime, for_part: str, resume_state: typing.Optional[bytewax.connectors.demo._RandomMetricState]) | ||
:canonical: bytewax.connectors.demo.RandomMetricSource.build_part | ||
```` | ||
````` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
````{note} | ||
The warning block will be properly-parsed | ||
```{warning} | ||
Here's my warning | ||
``` | ||
But the next block will be parsed as raw text | ||
```{warning} | ||
Here's my raw text warning that isn't parsed... | ||
``` | ||
```` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from testfixtures import compare | ||
|
||
from sybil.parsers.markdown.lexers import RawFencedCodeBlockLexer | ||
from sybil.region import Region | ||
from .helpers import region_details, check_lexed_regions | ||
|
||
|
||
def test_fenced_code_block(): | ||
lexer = RawFencedCodeBlockLexer() | ||
check_lexed_regions('markdown-fenced-code-block.md', lexer, expected = [ | ||
Region(12, 24, lexemes={'source': '<\n >\n'}), | ||
Region(34, 46, lexemes={'source': '<\n >\n'}), | ||
Region(177, 192, lexemes={'source': 'aaa\n~~~\n'}), | ||
Region(266, 285, lexemes={'source': 'aaa\n```\n'}), | ||
Region(301, 312, lexemes={'source': 'aaa\n'}), | ||
Region(296, 317, lexemes={'source': '~~~\naaa\n~~~\n'}), | ||
Region(397, 421, lexemes={'source': 'some stuff here\n~~~\n'}), | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.