Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New markdown parser #2439

Merged
merged 52 commits into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
f0ef11d
Map Markdown tokens to same format as old parser
darrenburns Jul 20, 2022
85380a1
Handling inline styling elements and basic text
darrenburns Jul 20, 2022
0ef4cc2
Slight refactor of Markdown parse code structure to make flow clearer
darrenburns Jul 21, 2022
745bd99
Checking in progress
darrenburns Jul 25, 2022
a20c3d5
Support for headings
darrenburns Jul 26, 2022
795b285
Add support for hardbreak
darrenburns Jul 26, 2022
57ea4c3
Handle softbreaks
darrenburns Jul 26, 2022
60cb12d
Add support for horizontal rule
darrenburns Jul 26, 2022
7b92aed
Add support for links
darrenburns Jul 26, 2022
9c70126
Add incomplete support for lists
darrenburns Jul 27, 2022
a295348
Add support for bullet lists
darrenburns Jul 27, 2022
829cd5f
Support soft breaks
darrenburns Jul 27, 2022
d6a819f
Fix typo block_quote -> blockquote to support... blockquotes
darrenburns Jul 27, 2022
fb3113a
Work in progress image support
darrenburns Jul 27, 2022
b3d70df
Ensure we pop self-closing tags from the stack
darrenburns Jul 27, 2022
73552a8
Add support for code blocks
darrenburns Jul 27, 2022
4e09d67
Use more minimalistic styling for Markdown code blocks
darrenburns Jul 27, 2022
219bf22
Switch off GFM markdown, manually enable tables (faster parsing)
darrenburns Jul 27, 2022
32a7465
Merge branch 'master' of github.com:Textualize/rich into new-markdown…
darrenburns Jul 27, 2022
7ce3d2a
Remove a bunch of commented out code
darrenburns Jul 27, 2022
87807de
Remove linkify
darrenburns Jul 27, 2022
90069d7
Remove test files from repo
darrenburns Jul 27, 2022
9383774
Switching off links
darrenburns Aug 2, 2022
f21aed1
Remove redundant code
darrenburns Aug 2, 2022
c8fbd61
Support toggling links on and off
darrenburns Aug 2, 2022
2e814de
Map inline code to correct style
darrenburns Aug 2, 2022
ecea70e
Support ordered list "start number"
darrenburns Aug 2, 2022
b472de3
Support highlighting inline code
darrenburns Aug 2, 2022
cf28a12
Fix a test, remove debugging stuff
darrenburns Aug 2, 2022
4fecdd5
Remove unused code
darrenburns Aug 2, 2022
2860e72
Fix mypy complaints
darrenburns Aug 2, 2022
4787873
Fix some broken tests, remove redundant code
darrenburns Aug 2, 2022
df1ea6b
Remove dataclasses and types-dataclasses dependencies
darrenburns Aug 2, 2022
ea5faba
Re-add types dataclasses
darrenburns Aug 2, 2022
ca0aa4c
Lockfile
darrenburns Aug 2, 2022
c71a152
Remove a bunch of 3.6 stuff
darrenburns Aug 2, 2022
d029a81
Remove redundant line
darrenburns Aug 2, 2022
22e70f0
Remove old comment
darrenburns Aug 2, 2022
640c890
Some renaming, removing unused code
darrenburns Aug 2, 2022
0999b40
Inline a closure that was no longer required
darrenburns Aug 2, 2022
15c41e7
Un-fstring a string that shouldnt be an fstring
darrenburns Aug 3, 2022
4760190
Remove mapping of tag to style names, just add new `markdown.*` style…
darrenburns Aug 3, 2022
5516ed4
Update typing in Markdown to be stricter
darrenburns Aug 3, 2022
0fdf3cf
Assert that the element popped on link_close is a Link
darrenburns Aug 3, 2022
1c66120
Merge branch 'new-markdown-parser' of github.com:Textualize/rich into…
darrenburns Jan 17, 2023
6dada68
Merge branch 'master' of github.com:Textualize/rich into new-markdown…
darrenburns Jan 17, 2023
8e87818
Fix failing tests
darrenburns Jan 17, 2023
73a9ec0
Fix Markdown link styling
darrenburns Jan 18, 2023
644e0c0
Validate and fix some failed snapshot tests
darrenburns Jan 18, 2023
421bd52
Remove some test Markdown files from repository
darrenburns Jan 18, 2023
d1813d2
Add CHANGELOG entry for commonmark -> markdown-it migration
darrenburns Jan 18, 2023
3f316c5
Add support for strikethrough text
darrenburns Jan 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
python-version: ["3.7", "3.8", "3.9", "3.10"]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were missing 3.11.

python-version: ["3.7", "3.8", "3.9", "3.10", "3.11.0"]
defaults:
run:
shell: bash
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

### Changed

- Switch Markdown parsing from commonmark to markdown-it-py https://github.com/Textualize/rich/pull/2439

## [13.1.0] - 2023-01-14

### Fixed
Expand Down
1,744 changes: 881 additions & 863 deletions poetry.lock

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ include = ["rich/py.typed"]
python = ">=3.7.0"
typing-extensions = { version = ">=4.0.0, <5.0", python = "<3.9" }
pygments = "^2.6.0"
commonmark = "^0.9.0"
ipywidgets = { version = "^7.5.1", optional = true }

markdown-it-py = "^2.1.0"

[tool.poetry.extras]
jupyter = ["ipywidgets"]
Expand All @@ -57,7 +56,7 @@ strict = true
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]

[[tool.mypy.overrides]]
module = ["pygments.*", "IPython.*", "commonmark.*", "ipywidgets.*"]
module = ["pygments.*", "IPython.*", "ipywidgets.*"]
ignore_missing_imports = true

[tool.pytest.ini_options]
Expand Down
10 changes: 6 additions & 4 deletions rich/default_styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,11 @@
"tree.line": Style(),
"markdown.paragraph": Style(),
"markdown.text": Style(),
"markdown.emph": Style(italic=True),
"markdown.em": Style(italic=True),
"markdown.emph": Style(italic=True), # For commonmark backwards compatibility
"markdown.strong": Style(bold=True),
"markdown.code": Style(bgcolor="black", color="bright_white"),
"markdown.code_block": Style(dim=True, color="cyan", bgcolor="black"),
"markdown.code": Style(bold=True, color="cyan", bgcolor="black"),
"markdown.code_block": Style(color="cyan", bgcolor="black"),
"markdown.block_quote": Style(color="magenta"),
"markdown.list": Style(color="cyan"),
"markdown.item": Style(),
Expand All @@ -157,7 +158,8 @@
"markdown.h6": Style(italic=True),
"markdown.h7": Style(italic=True, dim=True),
"markdown.link": Style(color="bright_blue"),
"markdown.link_url": Style(color="blue"),
"markdown.link_url": Style(color="blue", underline=True),
"markdown.s": Style(strike=True),
"iso8601.date": Style(color="blue"),
"iso8601.time": Style(color="magenta"),
"iso8601.timezone": Style(color="yellow"),
Expand Down
Loading