mirror of
https://github.com/markedjs/marked.git
synced 2026-11-30 16:48:05 +01:00
fix: keep a line starting with # but no space in the list item (#4127)
This commit is contained in:
+3
-1
@@ -382,7 +382,9 @@ export class _Tokenizer<ParserOutput = string, RendererOutput = string> {
|
||||
const nextBulletRegex = this.rules.other.nextBulletRegex(indent);
|
||||
const hrRegex = this.rules.other.hrRegex(indent);
|
||||
const fencesBeginRegex = this.rules.other.fencesBeginRegex(indent);
|
||||
const headingBeginRegex = this.rules.other.headingBeginRegex(indent);
|
||||
const headingBeginRegex = this.options.pedantic
|
||||
? this.rules.other.pedanticHeadingBeginRegex(indent)
|
||||
: this.rules.other.headingBeginRegex(indent);
|
||||
const htmlBeginRegex = this.rules.other.htmlBeginRegex(indent);
|
||||
const blockquoteBeginRegex = this.rules.other.blockquoteBeginRegex(indent);
|
||||
|
||||
|
||||
+4
-1
@@ -98,7 +98,10 @@ export const other = {
|
||||
nextBulletRegex: cachedIndentRegex((indent: number) => new RegExp(`^ {0,${indent}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`)),
|
||||
hrRegex: cachedIndentRegex((indent: number) => new RegExp(`^ {0,${indent}}((?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\\*[ \t]*){3,})(?:\\n+|$)`)),
|
||||
fencesBeginRegex: cachedIndentRegex((indent: number) => new RegExp(`^ {0,${indent}}(?:\`\`\`|~~~)`)),
|
||||
headingBeginRegex: cachedIndentRegex((indent: number) => new RegExp(`^ {0,${indent}}#`)),
|
||||
// an ATX heading needs a space (or the end of the line) after the hashes, so a line
|
||||
// like `#tag` does not end a list item; pedantic mode accepts it as a heading
|
||||
headingBeginRegex: cachedIndentRegex((indent: number) => new RegExp(`^ {0,${indent}}#{1,6}(?:\\s|$)`)),
|
||||
pedanticHeadingBeginRegex: cachedIndentRegex((indent: number) => new RegExp(`^ {0,${indent}}#`)),
|
||||
// a list item ends where a paragraph would be interrupted, so this mirrors the
|
||||
// html start conditions in the paragraph rule below; type 7 is excluded there
|
||||
htmlBeginRegex: cachedIndentRegex((indent: number) => new RegExp(`^ {0,${indent}}(?:</?(?:${_tag})(?: +|$|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`, 'i')),
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<ul>
|
||||
<li>item
|
||||
#tag</li>
|
||||
</ul>
|
||||
<ol>
|
||||
<li>one
|
||||
#######</li>
|
||||
</ol>
|
||||
<ul>
|
||||
<li>last</li>
|
||||
</ul>
|
||||
<h1>heading</h1>
|
||||
@@ -0,0 +1,8 @@
|
||||
- item
|
||||
#tag
|
||||
|
||||
1. one
|
||||
#######
|
||||
|
||||
- last
|
||||
# heading
|
||||
@@ -0,0 +1,4 @@
|
||||
<ul>
|
||||
<li>item</li>
|
||||
</ul>
|
||||
<h1>tag</h1>
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
pedantic: true
|
||||
---
|
||||
|
||||
- item
|
||||
#tag
|
||||
Reference in New Issue
Block a user