85 Commits

Author SHA1 Message Date
Tony Brix
1ce59ea827
feat: Send token objects to renderers (#3291)
BREAKING CHANGE: extensions that change marked renderers will need to be updated and use new option `useNewRenderer`
2024-06-12 00:00:22 -06:00
Tony Brix
7ab818502e
fix: blockquote code continuation (#3264)
BREAKING CHANGE: add space token after blockquote and hr if there are multiple newlines
2024-06-11 23:53:43 -06:00
Tony Brix
daa511d79d
chore: fix tests in node v21 (#3209)
* chore: fix tests in node v21

* chore: use latest for node version
2024-03-04 08:05:38 -07:00
Tony Brix
4826841bd6
feat: flatten childToken arrays (#3172) 2024-01-26 17:26:33 -07:00
Rahul Zhade
bf44ae85ed
fix: Fix ENOENT error message in CLI (#3165)
* Update utility to only output err path

* Fix failing tests

* Update code to explicitly check for presence of input

* Add input file not found test

* Make error messaging consistent

* fix bin test mocks

* add --input test

* Remove race condition causing exist check

* Update bin/main.js

Co-authored-by: Steven <steven@ceriously.com>

* Update tests

---------

Co-authored-by: Tony Brix <tony@brix.ninja>
Co-authored-by: Steven <steven@ceriously.com>
2024-01-26 17:26:11 -07:00
Tony Brix
faae24356a
feat: add processAllTokens hook (#3114) 2023-12-11 23:02:22 -07:00
Tony Brix
a28743391a
fix: allow Renderer class in marked.use (#3118) 2023-12-08 00:17:36 -07:00
Tony Brix
175fc0c321
fix: clean up rules so they can be typed (#3087)
BREAKING CHANGE: Lexer.rules object has been changed so it can be properly types. Some intermediate rules have been removed.
2023-11-28 20:56:27 -07:00
Tony Brix
014d4e61f6
fix: run spec tests with testutils (#3017)
BREAKING CHANGE: drop support for node v16
2023-11-10 22:49:27 -07:00
Tony Brix
f9d08cc1ef
fix: fix instance options sent to lexer and parser (#3073) 2023-11-10 00:41:04 -07:00
Susheel Thapa
7403ec0779
Chore: Typo fixed in multiple files (#3045)
Co-authored-by: Tony Brix <tony@brix.ninja>
2023-10-16 23:28:19 -06:00
Tony Brix
92033e57c8
fix: trim newline from blockquote token.text (#3037) 2023-10-13 13:52:19 -06:00
Tony Brix
ccd02296b0
docs: remove slugger (#2984) 2023-09-14 13:20:54 -06:00
Tony Brix
9a2a4ad61a
fix: fix space removed after checkbox (#2971)
* fix: fix space removed after checkbox

* add loose test
2023-09-06 12:57:09 -06:00
Tony Brix
22ebdb2507
fix: remove deprecated options (#2936)
BREAKING CHANGE: deprecated options removed. See https://marked.js.org/using_advanced#options to see how to enable the removed options with extensions.
2023-09-02 22:02:24 -06:00
Tony Brix
65b6f146b6
add config option to bin/marked (#2937)
* add config option to bin/marked

* add tests

* add docs

* remove focused tests
2023-09-02 21:39:45 -06:00
Tony Brix
b6ee877d58
fix: ignore async: false when async: true is set by an extension (#2920) 2023-08-19 16:58:32 -06:00
Tony Brix
63a839b8cb
fix: change defaults for mangle and headerIds to false (#2890)
BREAKING CHANGE: change defaults for mangle and headerIds to false
2023-08-06 17:48:30 -06:00
Florian Dreier
cb549065f1
fix: Migrate to Typescript (#2805)
BREAKING CHANGE: Migrate to Typescript
2023-07-29 00:31:34 -06:00
Tony Brix
353e13b479
feat: add Marked instance (#2831)
Co-authored-by: Steven <steven@ceriously.com>
2023-06-09 22:10:12 -05:00
Tony Brix
fa21b9f60a
feat: add block param to html renderer (#2768) 2023-05-01 23:31:40 -05:00
Tony Brix
62d3312b7a
fix: deprecate options (#2766)
BREAKING CHANGE: deprecate options
2023-05-01 23:30:06 -05:00
Tony Brix
9b452bc7f1
feat: add preprocess and postprocess hooks (#2730) 2023-03-22 00:48:56 -05:00
Tony Brix
042dcc5431
fix: always return promise if async (#2728)
* fix: always return promise if async

* docs: await walktokens when async

* docs: walktokens async

Co-authored-by: Steven <steven@ceriously.com>

* return rejected promise on error

---------

Co-authored-by: Steven <steven@ceriously.com>
2023-03-21 19:51:45 -05:00
Tony Brix
edc857c628
fix: use paragraph token in blockquote in list (#2671)
Fixes undefined
2022-12-07 01:45:09 -06:00
Tony Brix
df4eb0e090
fix: loose list items are loose (#2672) 2022-12-07 01:44:35 -06:00
Tony Brix
73a7bf5cd9
fix: fix marked.use with multiple args (#2651)
Fixes undefined
2022-11-20 10:06:28 -06:00
Tony Brix
4aee878ac9
fix: fix multiline setext headings (#2655) 2022-11-20 10:06:04 -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
Tony Brix
994b2e6127
feat: add async option (#2474)
* fix: return values from walkTokens

* docs: add async docs

* test: add async test

* docs: add nav to async

* Update docs/USING_PRO.md

Co-authored-by: Steven <steven@ceriously.com>

* test: expect promise

* Update docs/USING_ADVANCED.md

Co-authored-by: Steven <steven@ceriously.com>

Co-authored-by: Steven <steven@ceriously.com>
2022-08-30 09:36:16 -05:00
Tony Brix
f1a9608201
fix: make second parameter optional on lexer.inline (#2552)
* fix: make second parameter optional on lexer.inline

* return tokens

* add test
2022-08-21 11:21:11 -05:00
Phillip Burch
a9696e2898
fix: retain line breaks in tokens properly (#2341)
* Fix lexer and tokenizer to retain line breaks properly

* Add test for bug

* Check for line breaks not just spaces

* Fix lint

* Fix spacing in test

* clean up code

Co-authored-by: Tony Brix <tony@brix.ninja>
2022-01-06 09:31:58 -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
2da5885989
fix: walkTokens uses marked as this (#2251) 2021-10-24 00:03:59 -05:00
Trevor Buckner
bc400ac789
fix: Refactor table tokens (#2166)
BREAKING CHANGE:

- `table` tokens `header` property changed to contain an array of objects for each header cell with `text` and `tokens` properties.
- `table` tokens `cells` property changed to `rows` and is an array of rows where each row contains an array of objects for each cell with `text` and `tokens` properties.

v2:

```json
{
  "type": "table",
  "align": [null, null],
  "raw": "| a | b |\n|---|---|\n| 1 | 2 |\n",
  "header": ["a", "b"],
  "cells": [["1", "2"]],
  "tokens": {
    "header": [
      [{ "type": "text", "raw": "a", "text": "a" }],
      [{ "type": "text", "raw": "b", "text": "b" }]
    ],
    "cells": [[
      [{ "type": "text", "raw": "1", "text": "1" }],
      [{ "type": "text", "raw": "2", "text": "2" }]
    ]]
  }
}
```

v3:

```json
{
  "type": "table",
  "align": [null, null],
  "raw": "| a | b |\n|---|---|\n| 1 | 2 |\n",
  "header": [
    {
      "text": "a",
      "tokens": [{ "type": "text", "raw": "a", "text": "a" }]
    },
    {
      "text": "b",
      "tokens": [{ "type": "text", "raw": "b", "text": "b" }]
    }
  ],
  "rows": [
    {
      "text": "1",
      "tokens": [{ "type": "text", "raw": "1", "text": "1" }]
    },
    {
      "text": "2",
      "tokens": [{ "type": "text", "raw": "2", "text": "2" }]
    }
  ]
}
```
2021-08-15 22:02:39 -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
af14068b99
fix: fix node v12 (#2109) 2021-06-16 08:48:39 -05:00
Trevor Buckner
5be9d6d70e
feat: Custom Tokenizer/Renderer extensions (#2043)
Co-authored-by: Tony Brix <tony@brix.ninja>
2021-06-15 18:22:00 -05:00
Tony Brix
1d973084ab
fix: call walkTokens when calling marked with a callback(#2060) 2021-05-21 15:53:01 -05:00
Tony Brix
46cdfc1ece
fix: fix items between lists (#1936) 2021-02-26 23:51:21 -06:00
Trevor Buckner
f848e77039
fix: Join adjacent inlineText tokens (#1926) 2021-02-07 16:22:47 -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
c8a2b59d83 remove focused tests 2020-09-21 00:21:56 -05:00
Tony Brix
baece60557 test marked.parseInline 2020-09-20 23:01:11 -05:00
flouc001
75b2646687 add sequence test 2020-07-15 08:16:03 +01:00
Callum
014fbcf43f
add assertion to existing test
Co-authored-by: Tony Brix <tony@brix.ninja>
2020-07-15 08:03:31 +01:00
flouc001
710658cb61 use options param, update docs, update tests 2020-07-12 19:38:37 +01:00
flouc001
7c35a842a6 add dry run capabilities to default slugger 2020-07-11 09:24:46 +01:00