Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: markedjs/marked
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.0.0
Choose a base ref
...
head repository: markedjs/marked
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.0.1
Choose a head ref
  • 9 commits
  • 11 files changed
  • 5 contributors

Commits on Aug 16, 2021

  1. 2

    Verified

    This commit was signed with the committer’s verified signature.
    bagder Daniel Stenberg
    Copy the full SHA
    6fa4842 View commit details
  2. chore(deps-dev): Bump semantic-release from 17.4.4 to 17.4.5 (#2175)

    Bumps [semantic-release](https://github.com/semantic-release/semantic-release) from 17.4.4 to 17.4.5.
    - [Release notes](https://github.com/semantic-release/semantic-release/releases)
    - [Commits](semantic-release/semantic-release@v17.4.4...v17.4.5)
    
    ---
    updated-dependencies:
    - dependency-name: semantic-release
      dependency-type: direct:development
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Aug 16, 2021
    1
    Copy the full SHA
    e2ee4ea View commit details

Commits on Aug 22, 2021

  1. 1
    Copy the full SHA
    9c312b2 View commit details

Commits on Aug 23, 2021

  1. chore(deps-dev): Bump rollup from 2.56.2 to 2.56.3 (#2183)

    Bumps [rollup](https://github.com/rollup/rollup) from 2.56.2 to 2.56.3.
    - [Release notes](https://github.com/rollup/rollup/releases)
    - [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
    - [Commits](rollup/rollup@v2.56.2...v2.56.3)
    
    ---
    updated-dependencies:
    - dependency-name: rollup
      dependency-type: direct:development
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Aug 23, 2021
    1
    Copy the full SHA
    a9076f8 View commit details
  2. chore(deps-dev): Bump jasmine from 3.8.0 to 3.9.0 (#2184)

    Bumps [jasmine](https://github.com/jasmine/jasmine-npm) from 3.8.0 to 3.9.0.
    - [Release notes](https://github.com/jasmine/jasmine-npm/releases)
    - [Commits](jasmine/jasmine-npm@v3.8.0...v3.9.0)
    
    ---
    updated-dependencies:
    - dependency-name: jasmine
      dependency-type: direct:development
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Aug 23, 2021
    1
    Copy the full SHA
    42e82a9 View commit details
  3. chore(deps-dev): Bump eslint-plugin-import from 2.24.0 to 2.24.1 (#2185)

    Bumps [eslint-plugin-import](https://github.com/import-js/eslint-plugin-import) from 2.24.0 to 2.24.1.
    - [Release notes](https://github.com/import-js/eslint-plugin-import/releases)
    - [Changelog](https://github.com/import-js/eslint-plugin-import/blob/main/CHANGELOG.md)
    - [Commits](import-js/eslint-plugin-import@v2.24.0...v2.24.1)
    
    ---
    updated-dependencies:
    - dependency-name: eslint-plugin-import
      dependency-type: direct:development
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Aug 23, 2021
    1
    Copy the full SHA
    73c39ca View commit details
  4. 1
    Copy the full SHA
    e03b5c1 View commit details
  5. 🗜️ build [skip ci]

    MarkedJS bot committed Aug 23, 2021
    Copy the full SHA
    ddef60f View commit details
  6. chore(release): 3.0.1 [skip ci]

    ## [3.0.1](v3.0.0...v3.0.1) (2021-08-23)
    
    ### Bug Fixes
    
    * fix gfm urls after link ([#2186](#2186)) ([e03b5c1](e03b5c1))
    semantic-release-bot committed Aug 23, 2021
    1
    Copy the full SHA
    ce30ed4 View commit details
Showing with 130 additions and 150 deletions.
  1. +6 −0 README.md
  2. +1 −1 docs/PUBLISHING.md
  3. +24 −28 docs/USING_PRO.md
  4. +3 −1 lib/marked.esm.js
  5. +3 −1 lib/marked.js
  6. +1 −1 marked.min.js
  7. +75 −112 package-lock.json
  8. +5 −5 package.json
  9. +3 −1 src/Tokenizer.js
  10. +3 −0 test/specs/new/autolink_after_link.html
  11. +6 −0 test/specs/new/autolink_after_link.md
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -29,6 +29,12 @@ Also read about:
* [Options](https://marked.js.org/#/USING_ADVANCED.md)
* [Extensibility](https://marked.js.org/#/USING_PRO.md)

## Compatibility

**Node.js:** Only [current and LTS](https://nodejs.org/en/about/releases/) Node.js versions are supported. End of life Node.js versions may become incompatible with Marked at any point in time.

**Browser:** Not IE11 :)

## Installation

**CLI:** `npm install -g marked`
2 changes: 1 addition & 1 deletion docs/PUBLISHING.md
Original file line number Diff line number Diff line change
@@ -10,6 +10,6 @@ Marked uses [semantic-release](https://github.com/semantic-release/semantic-rele

We follow [semantic versioning](https://semver.org) where the following sequence is true `[major].[minor].[patch]`:

1. **Major:** There is at least one change to the public API or a break from the [CommonMark](https://spec.commonmark.org/current/) or [GFM](https://github.github.com/gfm/) spec.
1. **Major:** There is at least one change to the public API or a break from the [CommonMark](https://spec.commonmark.org/current/) or [GFM](https://github.github.com/gfm/) spec. Only [current and LTS](https://nodejs.org/en/about/releases/) Node.js versions are supported at any point in time. A drop in support for a Node.js version may not result in a semver major bump to Marked.
2. **Minor:** There is at least one new feature added to the public API.
3. **Patch:** Changes that move Marked closer to spec compliance or change a public API that does not break backwards compatibility.
52 changes: 24 additions & 28 deletions docs/USING_PRO.md
Original file line number Diff line number Diff line change
@@ -315,53 +315,49 @@ The index can be the result of a <code>src.match().index</code>, or even a simpl

The return value should be an object with the following parameters:

<dl>
<dt><code><strong>type</strong></code></dt>
<dd>A string that matches the <code>name</code> parameter of the extension.</dd>
<dl>
<dt><code><strong>type</strong></code></dt>
<dd>A string that matches the <code>name</code> parameter of the extension.</dd>

<dt><code><strong>raw</strong></code></dt>
<dd>A string containing all of the text that this token consumes from the source.</dd>
<dt><code><strong>raw</strong></code></dt>
<dd>A string containing all of the text that this token consumes from the source.</dd>

<dt><code><strong>tokens</strong> [optional]</code></dt>
<dd>An array of child tokens that will be traversed by the <code>walkTokens</code> function by default.</dd>
</dl>
<dt><code><strong>tokens</strong> [optional]</code></dt>
<dd>An array of child tokens that will be traversed by the <code>walkTokens</code> function by default.</dd>
</dl>

The returned token can also contain any other custom parameters of your choice that your custom `renderer` might need to access.

The tokenizer function has access to the lexer in the `this` object, which can be used if any internal section of the string needs to be parsed further, such as in handling any inline syntax on the text within a block token. The key functions that may be useful include:

<dl>
<dt><code><strong>this.lexer.blockTokens</strong>(<i>string</i> text, <i>array</i> tokens)</code></dt>
<dd>This runs the block tokenizer functions (including any block-level extensions) on the provided text, and appends any resulting tokens onto the <code>tokens</code> array. The <code>tokens</code> array is also returned by the function. You might use this, for example, if your extension creates a "container"-type token (such as a blockquote) that can potentially include other block-level tokens inside.</dd>
<dl>
<dt><code><strong>this.lexer.blockTokens</strong>(<i>string</i> text, <i>array</i> tokens)</code></dt>
<dd>This runs the block tokenizer functions (including any block-level extensions) on the provided text, and appends any resulting tokens onto the <code>tokens</code> array. The <code>tokens</code> array is also returned by the function. You might use this, for example, if your extension creates a "container"-type token (such as a blockquote) that can potentially include other block-level tokens inside.</dd>

<dl>
<dt><code><strong>this.lexer.inline</strong>(<i>string</i> text, <i>array</i> tokens)</code></dt>
<dd>Parsing of inline-level tokens only occurs after all block-level tokens have been generated. This function adds <code>text</code> and <code>tokens</code> to a queue to be processed using inline-level tokenizers (including any inline-level extensions) at that later step. Tokens will be generated using the provided <code>text</code>, and any resulting tokens will be appended to the <code>tokens</code> array. Note that this function does **NOT** return anything since the inline processing cannot happen until the block-level processing is complete.</dd>
<dt><code><strong>this.lexer.inline</strong>(<i>string</i> text, <i>array</i> tokens)</code></dt>
<dd>Parsing of inline-level tokens only occurs after all block-level tokens have been generated. This function adds <code>text</code> and <code>tokens</code> to a queue to be processed using inline-level tokenizers (including any inline-level extensions) at that later step. Tokens will be generated using the provided <code>text</code>, and any resulting tokens will be appended to the <code>tokens</code> array. Note that this function does **NOT** return anything since the inline processing cannot happen until the block-level processing is complete.</dd>

<dt><code><strong>this.lexer.inlineTokens</strong>(<i>string</i> text, <i>array</i> tokens)</code></dt>
<dd>Sometimes an inline-level token contains further nested inline tokens (such as a <pre><code>**strong**</code></pre> token inside of a <pre><code>### Heading</code></pre>). This runs the inline tokenizer functions (including any inline-level extensions) on the provided text, and appends any resulting tokens onto the <code>tokens</code> array. The <code>tokens</code> array is also returned by the function.</dd>
</dl>
<dt><code><strong>this.lexer.inlineTokens</strong>(<i>string</i> text, <i>array</i> tokens)</code></dt>
<dd>Sometimes an inline-level token contains further nested inline tokens (such as a <pre><code>**strong**</code></pre> token inside of a <pre><code>### Heading</code></pre>). This runs the inline tokenizer functions (including any inline-level extensions) on the provided text, and appends any resulting tokens onto the <code>tokens</code> array. The <code>tokens</code> array is also returned by the function.</dd>
</dl>
</dd>

<dt><code><strong>renderer</strong>(<i>object</i> token)</code></dt>
<dd>A function that reads a token and returns the generated HTML output string.

The renderer function has access to the parser in the `this` object, which can be used if any part of the token needs needs to be parsed further, such as any child tokens. The key functions that may be useful include:

<dl>
<dt><code><strong>this.parser.parse</strong>(<i>array</i> tokens)</code></dt>
<dd>Runs the block renderer functions (including any extensions) on the provided array of tokens, and returns the resulting HTML string output. This is used to generate the HTML from any child block-level tokens, for example if your extension is a "container"-type token (such as a blockquote) that can potentially include other block-level tokens inside.</dd>

<dt><code><strong>this.parser.parseInline</strong>(<i>array</i> tokens)</code></dt>
<dd>Runs the inline renderer functions (including any extensions) on the provided array of tokens, and returns the resulting HTML string output. This is used to generate the HTML from any child inline-level tokens.</dd>
</dl>
<dl>
<dt><code><strong>this.parser.parse</strong>(<i>array</i> tokens)</code></dt>
<dd>Runs the block renderer functions (including any extensions) on the provided array of tokens, and returns the resulting HTML string output. This is used to generate the HTML from any child block-level tokens, for example if your extension is a "container"-type token (such as a blockquote) that can potentially include other block-level tokens inside.</dd>

<dt><code><strong>this.parser.parseInline</strong>(<i>array</i> tokens)</code></dt>
<dd>Runs the inline renderer functions (including any extensions) on the provided array of tokens, and returns the resulting HTML string output. This is used to generate the HTML from any child inline-level tokens.</dd>
</dl>
</dd>

<dt><code><strong>childTokens</strong> [optional]</code></dt>
<dd>An array of strings that match the names of any token parameters that should be traversed by the <code>walkTokens</code> functions. For instance, if you want to use a second custom parameter to contain child tokens in addition to <code>tokens</code>, it could be listed here. If <code>childTokens</code> is provided, the <code>tokens</code> array will not be walked by default unless it is also included in the <code>childTokens</code> array.
</dl>

</dd>
<dd>An array of strings that match the names of any token parameters that should be traversed by the <code>walkTokens</code> functions. For instance, if you want to use a second custom parameter to contain child tokens in addition to <code>tokens</code>, it could be listed here. If <code>childTokens</code> is provided, the <code>tokens</code> array will not be walked by default unless it is also included in the <code>childTokens</code> array.</dd>
</dl>

**Example:** Add a custom syntax to generate `<dl>` description lists.
4 changes: 3 additions & 1 deletion lib/marked.esm.js
Original file line number Diff line number Diff line change
@@ -326,14 +326,16 @@ function outputLink(cap, link, raw, lexer) {

if (cap[0].charAt(0) !== '!') {
lexer.state.inLink = true;
return {
const token = {
type: 'link',
raw,
href,
title,
text,
tokens: lexer.inlineTokens(text, [])
};
lexer.state.inLink = false;
return token;
} else {
return {
type: 'image',
4 changes: 3 additions & 1 deletion lib/marked.js
Original file line number Diff line number Diff line change
@@ -418,14 +418,16 @@

if (cap[0].charAt(0) !== '!') {
lexer.state.inLink = true;
return {
var token = {
type: 'link',
raw: raw,
href: href,
title: title,
text: text,
tokens: lexer.inlineTokens(text, [])
};
lexer.state.inLink = false;
return token;
} else {
return {
type: 'image',
Loading