Skip to content
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

Emphasis takes precedence over inline code span #75

Closed
eush77 opened this issue Sep 26, 2015 · 4 comments
Closed

Emphasis takes precedence over inline code span #75

eush77 opened this issue Sep 26, 2015 · 4 comments
Labels
remark 🧑 semver/major This is a change 🦋 type/enhancement This is great to have

Comments

@eush77
Copy link
Contributor

eush77 commented Sep 26, 2015

Input:

_`_`_

Actual AST:

{
  "type": "paragraph",
  "children": [
    {
      "type": "emphasis",
      "children": [
        {
          "type": "text",
          "value": "`"
        }
      ]
    },
    {
      "type": "text",
      "value": "`_"
    }
  ]
}

Expected AST:

{
  "type": "paragraph",
  "children": [
    {
      "type": "emphasis",
      "children": [
        {
          "type": "inlineCode",
          "value": "_"
        }
      ]
    }
  ]
}

Commonmark:

Code span backticks have higher precedence than any other inline constructs except HTML tags and autolinks. Thus, for example, this is not parsed as emphasized text, since the second * is part of a code span: *foo*``.

@wooorm
Copy link
Member

wooorm commented Sep 27, 2015

This kinda sucks; due to the legacy of marked this isn’t really do-able currently.

I’d love to make this happen but it will need a rewrite of the parsing algorithm; stepping away from regexes and to a real algorithmic tokeniser, e.g., like markdown-it 😦

@eush77
Copy link
Contributor Author

eush77 commented Oct 5, 2015

I came across the test that freezes the wrong precedence of inlineCode against linkReference.

In Commonmark,

[the `]` character](/url)

should parse as

<a href="/url">the <code>]</code> character</a>

@wooorm
Copy link
Member

wooorm commented Oct 6, 2015

Nice catch @eush77! In fact, I think all of the “pending” tests in mdast-html have to do with this (I wrote a bit about it here).

I think the only way to fix this is by rewriting the engine to use code tokenisers in favour of regexes; it’ll take a while to rewrite everything though!

@wooorm
Copy link
Member

wooorm commented Oct 21, 2018

Let’s track this in GH-306.

@wooorm wooorm closed this as completed Oct 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
remark 🧑 semver/major This is a change 🦋 type/enhancement This is great to have
Development

No branches or pull requests

2 participants