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

Incorrect attribute assignment for bracketed text within code within items #94

Closed
rivy opened this issue Aug 8, 2019 · 3 comments · Fixed by #95
Closed

Incorrect attribute assignment for bracketed text within code within items #94

rivy opened this issue Aug 8, 2019 · 3 comments · Fixed by #95

Comments

@rivy
Copy link
Contributor

rivy commented Aug 8, 2019

I came across this bug while writing a README for a javascript package.

This test fails (see rivy@795a537 in rivy/js.markdown-it-attrs/fix.item+code)...

    it(replaceDelimiters('should not apply inside item lists with `code{.red}`', options), () => {
      src = '- item with `code = {.red}`';
      expected = '<ul>\n<li>item with <code>code = {.red}</code></li>\n</ul>\n';
      assert.equal(md.render(replaceDelimiters(src, options)), replaceDelimiters(expected, options));
    });

The bracketed text is being removed from the code section and applied as an attribute to the item. It should, I believe, stay within the code section, untouched.

Example input:

- item with `code = {.red}`

Current output:

<ul>
<li class="red">item with <code>code =</code></li>
</ul>

Expected output:

<ul>
<li>item with <code>code = {.red}</code></li>
</ul>
@arve0
Copy link
Owner

arve0 commented Aug 9, 2019

Thanks for the report🙂 I’m on vacation and will be away from computer until next week.

Feel free to look at the token tree(markdow-it.github.io, choose debug) and the rules (patterns.js) to figure out what fails.

@rivy
Copy link
Contributor Author

rivy commented Aug 9, 2019

With your hints, I was able to narrow down the exact issue, added some tests, and a PR with a fix (#95).

Note that the first two commits of the PR fix this specific issue. I added two more tests that I thought were related in c18bdaa (which pass without any code changes), and b8434bd is a judgement call. I believe the content: utils.hasDelimiters('only', options) requirement makes the addition of type: text unnecessary, but it fit thematically with the same code fix previously.

I'm happy to edit out one or both of c18bdaa and/or b8434bd if you think that would be best.

Let me know if you'd like any changes after you get back from your vacation.
🏖🌴🍻 😃

@arve0 arve0 closed this as completed in #95 Aug 18, 2019
@arve0
Copy link
Owner

arve0 commented Aug 18, 2019

Good judgement call on the tests, I've merged as is. Released in v3.0.1. Thanks again 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants