Repository navigation
fix: require a space after ATX hashes; parse --- after headings and indented code #120
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,7 +24,7 @@ function encodeAttr(str) { | |
|
|
||
| /** Parse Markdown into an HTML String. */ | ||
| export default function parse(md, prevLinks) { | ||
| let tokenizer = /((?:^|\n+)(?:\n---+|\* \*(?: \*)+)\n)|(?:^``` *(\w*)\n([\s\S]*?)\n```$)|((?:(?:^|\n+)(?:\t| {2,}).+)+\n*)|((?:(?:^|\n)([>*+-]|\d+\.)\s+.*)+)|(?:!\[([^\]]*?)\]\(([^)]+?)\))|(\[)|(\](?:\(([^)]+?)\))?)|(?:(?:^|\n+)([^\s].*)\n(-{3,}|={3,})(?:\n+|$))|(?:(?:^|\n+)(#{1,6})\s*(.+)(?:\n+|$))|(?:`([^`].*?)`)|( \n\n*|\n{2,}|__|\*\*|[_*]|~~)/gm, | ||
| let tokenizer = /((?:^|\n+)(?:\n---+|\* \*(?: \*)+)\n|^---+(?:\n|$))|(?:^``` *(\w*)\n([\s\S]*?)\n```$)|((?:(?:^|\n+)(?:\t| {2,}).+)+\n*)|((?:(?:^|\n)([>*+-]|\d+\.)\s+.*)+)|(?:!\[([^\]]*?)\]\(([^)]+?)\))|(\[)|(\](?:\(([^)]+?)\))?)|(?:(?:^|\n+)([^\s].*)\n(-{3,}|={3,})(?:\n+|$))|(?:(?:^|\n+)(#{1,6})[ \t]+(.+)(?:\n+|$))|(?:`([^`].*?)`)|( \n\n*|\n{2,}|__|\*\*|[_*]|~~)/gm, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For an empty heading at the end of a document, such as Useful? React with 👍 / 👎. |
||
| context = [], | ||
| out = '', | ||
| links = prevLinks || {}, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a heading whose text consists of dashes, such as
# ---, the new HR alternative also matches during the recursiveparse()call that renders the heading's contents. Consequently, this input now produces<h1><hr /></h1>instead of the previous<h1>---</h1>, removing the title text and inserting a block element inside the heading. Restrict the new HR recognition to block contexts so that heading contents remain inline text.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked this and the empty-heading finding against the base and PR commits.
# ---renders as<h1>---</h1>on the base and<h1><hr /></h1>on this PR. Empty ATX headings followed by a space or tab also render as literal text on the PR.Would you be open to a small follow-up on this PR covering both cases, with focused regression tests? I'd appreciate your guidance on the scope.