76 Commits

Author SHA1 Message Date
Tony Brix
a37fe8e82b
fix: fix quadratic execution in em mask (#2818)
* fix: fix redos in em mask

* also remove (
2023-05-26 11:50:39 -05:00
Tony Brix
9b452bc7f1
feat: add preprocess and postprocess hooks (#2730) 2023-03-22 00:48:56 -05:00
Tony Brix
3acbb7f9ab
fix: fenced code doesn't need a trailing newline (#2756)
* fix: fenced code doesn't need a trailing newline

* build marked for demo

* clean up
2023-03-21 19:50:28 -05:00
Tony Brix
697ac2a42e
fix: remove quotes at the end of gfm autolink (#2673)
Fixes undefined
2022-12-07 01:44:55 -06:00
Tony Brix
4aee878ac9
fix: fix multiline setext headings (#2655) 2022-11-20 10:06:04 -06:00
Tony Brix
b7eea9504b
fix: fix link reference definitions specs (#2654) 2022-11-20 10:05:52 -06:00
Richard Gibson
377823a6f5
fix: Support escapes within emphasis (#2627)
* fix: Support escapes within emphasis

...particularly right at the end.

Fixes #2280

* chore: realign comments with regexp alternatives

* test: Add HTML test for escapes within emphasis

* fix: Correct recognition and masking of escaped emphasis punctuation

* fix: Correct backslash fake-lookbehind
2022-11-01 21:03:58 -05:00
rossipedia
7d19665167
fix: only convert leading tabs to spaces (#1559) (#2434)
* fix: non leading-tabs in markdown content (#1559)

Only replaces tabs at the beginning of a block construct. Tabs in the
middle of the item are unaffected.

All tests passing. Tabs in both GFM and CommonMark at 100%

fixes #1559

* update new/html_comments.html to preserve tab

* combine redundant if condition

* add test for tab immediately after blockquote character
2022-04-10 19:37:04 -05:00
Trevor Buckner
35583c3dec
fix: allow emStrong regex to consume more characters at once (#2433)
Just a small tweak so `emStrong` regex doesn't have to check character-by-character. Try to consume everything up to the delimiter we are checking for.
2022-04-07 20:52:55 -05:00
Tony Brix
c4a3ccd344
Merge pull request from GHSA-rrrm-qjm4-v8hf
* fix: fix reflink redos

Co-authored-by: MakeNowJust <make.just.on@gmail.com>

* fix: fix def redos

Co-authored-by: MakeNowJust <make.just.on@gmail.com>

* fix block label for multiple slashes

Co-authored-by: MakeNowJust <make.just.on@gmail.com>
2022-01-12 19:53:48 -06:00
Emmet Jang
5714212afd
fix: table after paragraph without blank line (#2298)
* fix: gfm table requires leading empty line

* test(gfm/table): add some test cases

* revert changes to `gfm.0.29.json`

* test(gfm/table): add `table_following_text` testcase
2021-11-24 18:10:22 -06:00
Ben McCann
4afb228d95
fix: Convert to ESM (#2227)
BREAKING CHANGE:

- Default export removed. Use `import { marked } from 'marked'` or `const { marked } = require('marked')` instead.
- `/lib/marked.js` removed. Use `/marked.min.js` in script tag instead.
- When using marked in a script tag use `marked.parse(...)` instead of `marked(...)`
2021-11-02 09:32:17 -05:00
Tony Brix
8c00ed31c5
fix: fix detection of orphaned emStrong delimiters (#2206) 2021-09-14 12:48:41 -05:00
Trevor Buckner
7792adcfe6
Fix detection of orphaned emStrong delimiters (#2203) 2021-09-14 12:42:01 -05:00
Tony Brix
910f0f0356
fix: fix space at end of table line (#2201) 2021-09-08 15:20:45 -05:00
Tony Brix
21268abfba
fix: stop table at lines with only whitespace (#2188) 2021-08-24 21:23:53 -05:00
Trevor Buckner
eb33d3b3a9
fix: Full Commonmark compliance for Lists (#2112) 2021-08-09 22:41:45 -05:00
Trevor Buckner
288f1cbe2f
Tokenizers lex their own child tokens (#2124)
BREAKING CHANGES:

- Tokenizers will create their own tokens with `this.lexer.inline(text, tokens)`. The `inline` function will queue the token creation until after all block tokens are rendered.
- `nptable` tokenizer is removed and merged with `table` tokenizer.
- Extensions tokenizer `this` object will include the `lexer` as a property. `this.inlineTokens` becomes `this.lexer.inline`.
- Extensions parser `this` object will include the `parser` as a property. `this.parseInline` becomes `this.parser.parseInline`.
- `tag` and `inlineText` tokenizer function signatures have changed.
2021-08-02 14:12:43 -05:00
Tony Brix
62d6a0e325
fix: update commonmark spec to v0.30 (#2113) 2021-06-25 15:14:09 -05:00
Trevor Buckner
825a9f82af
fix: em strong (#2075) 2021-06-01 15:26:35 -04:00
Tony Brix
6c9a8999dd
fix: fix autolink email after single space (#2073) 2021-05-27 11:15:32 -05:00
Michał Krassowski
6435ac9889
fix: Fix indented markdown in html (#2052)
Co-authored-by: Tony Brix <tony@brix.ninja>
2021-05-20 08:42:45 -05:00
Tony Brix
46cdfc1ece
fix: fix items between lists (#1936) 2021-02-26 23:51:21 -06:00
Trevor Buckner
7293251c43
fix: Total rework of Emphasis/Strong (#1864)
BREAKING CHANGE: `em` and `strong` tokenizers have been merged into one `emStrong` tokenizer
2021-02-07 16:25:01 -06:00
Tony Brix
53c79ee919
fix: leave whitespace only lines alone (#1889)
* fix: leave whitespace only lines alone

* test: add whitepace_lines test

* fix: render code with trailing new line
2021-01-26 08:20:13 -06:00
Tony Brix
70ee29c02b
fix: fix atx heading and make regex safe (#1853) 2020-12-10 10:28:58 -06:00
Tony Brix
656c3e4aba
fix: fix link with angle brackets around href (#1851) 2020-12-10 10:27:58 -06:00
Tony Brix
d79f210aba
fix: no strikethrough on different number of tildes (#1821)
Possible Breaking Change: When using the inline.del rule the text is provided in capture group 2 instead of 1.
2020-11-14 20:03:39 -06:00
Tony Brix
5f9cafd49c
fix: list alignment (#1810)
* fix: fix list alignment

* test: add test

* test: update passing tests

* move regex to rules

* clean up code

* move item back to top
2020-11-04 15:23:04 -06:00
Tony Brix
a317912f7a fix strong overlapSkip 2020-09-07 23:45:28 -05:00
Tony Brix
9576a982ff fix underscore adjacent to asterisk 2020-09-07 21:43:28 -05:00
Steven
1d6afc1774
Merge pull request #1748 from UziTech/indented-tables
fix indented tables to follow gfm spec
2020-08-13 10:33:43 -04:00
Tony Brix
2e99532bbd fix indented tables to act like gfm 2020-08-12 16:21:46 -05:00
Plan C
69908c21f7
fix bug : Cannot break line well
Co-authored-by: Tony Brix <tony@brix.ninja>
2020-08-12 10:49:25 +08:00
Plan C
480b9f0c07
fix bug : Cannot break line well
Co-authored-by: Tony Brix <tony@brix.ninja>
2020-08-12 10:48:49 +08:00
hubenchang0515
52872d2121 fix bug : Cannot break line well [#1537](https://github.com/markedjs/marked/issues/1537)
Cannot use **(WhiteSpace)(WhiteSpace)(Return)** to break line while only one characher before it.

And if use special character, it will reset the character count

brought by [#1460](https://github.com/markedjs/marked/pull/1460)
2020-08-12 10:32:44 +08:00
Tony Brix
e39f1ef07e fix inline comment and other html blocks 2020-08-07 11:19:26 -05:00
Dmitriy Derepko
8d07cffadc
Update src/rules.js
Co-authored-by: Tony Brix <tony@brix.ninja>
2020-08-07 09:03:47 +03:00
Dmitriy Derepko
464045ab55 Added testcase and fixed #1738 2020-08-06 19:56:06 +03:00
Tony Brix
dddf9ae72c
Merge pull request #1686 from calculuschild/EmphasisFixes 2020-07-13 08:34:55 -05:00
Trevor Buckner
e27e6f960f Sorted strong and em into sub-objects 2020-07-09 19:35:22 -04:00
Trevor Buckner
226bbe70b7 Lint 2020-07-08 17:01:42 -04:00
Trevor Buckner
cc778ade42 Removed redundancy in "startEM" check 2020-07-08 16:58:58 -04:00
Trevor Buckner
211b9f9a20 Removed Lookbehinds
Beginning and End delimiters for EM and Strong must be searched in a separate regex to work without lookbehinds. This invalidates the regex that skips over blocks (code, html, etc.) that take precedence over EM or Strong blocks.

Getting around this means we must now mask not only reflinks, but all enclosed blocks which were previously just skipped over in the Regex.

Add one check for overlapping Strong block when testing EM, now passes Commonmark 390 and 471
2020-07-08 16:00:12 -04:00
Trevor Buckner
bd4f8c464b Fix unrestricted "any character" for REDOS
And remove redundant unused capture group.
2020-07-02 11:59:31 -04:00
Tony Brix
d233fd5806 mask reflinks 2020-06-20 10:25:48 -05:00
Trevor Buckner
2a45677bf0 Remove redundant regex symbols
Found a few more cases of redundant symbols in addition to fixes suggested during review.
2020-06-18 10:00:27 -04:00
Randolf C
463f49d90c
Update src/rules.js
Co-authored-by: Tony Brix <tony@brix.ninja>
2020-06-17 17:27:35 +02:00
Trevor Buckner
335a6601d4 Added fixes to Strong
Fixes examples 391, 397, 399, 400, 401, 431, 443, 475, 476, 479, and 480
2020-06-17 11:06:25 -04:00
jun-sheaf
5920cf9cf8 Updated rules and created tests. 2020-06-17 11:50:00 +02:00