arve0 / markdown-it-attrs

Add classes, identifiers and attributes to your markdown with {} curly brackets, similar to pandoc's header attributes
MIT License
300 stars 58 forks source link

Readme 'custom blocks' section outdated? #134

Closed tlylt closed 2 years ago

tlylt commented 2 years ago

Hi,

While looking through the code to understand how it does the parsing, I realized that the description in the Custom-blocks seems to be outdated. Quoting it below for reference:

markdown-it-attrs will add attributes to any token.block == true with {}-curlies in end of token.info. For example, see markdown-it/rules_block/fence.js which stores text after the three backticks in fenced code blocks to token.info.

Remember to render attributes if you use a custom renderer.

In particular, I think it is no longer the case that markdown-it-attrs will add attributes to any token.block == true with {}-curlies in end of token.info.. Now it seems to be more complex than what's described here because of the rewrite with patterns and transforms.

Pointing it out in case there's a need to update it. Thanks!

arve0 commented 2 years ago

Hi 🙂 I think this still holds, does it not?

any token.block == true

This part of test: https://github.com/arve0/markdown-it-attrs/blob/master/patterns.js#L26

with {}-curlies in end of token.info

Test part: https://github.com/arve0/markdown-it-attrs/blob/master/patterns.js#L27

The pattern name is fenced code blocks, but it will apply to any token matching the test.

tlylt commented 2 years ago

Hi 🙂 I think this still holds, does it not?

any token.block == true

This part of test: master/patterns.js#L26

with {}-curlies in end of token.info

Test part: master/patterns.js#L27

The pattern name is fenced code blocks, but it will apply to any token matching the test.

Ah ok, sorry I think I misunderstood it to mean only for token.block == true with {}-curlies in end of token.info, which is not the case anymore (as long as they match one of the patterns described). I think I was confused because the link below was referencing the file markdown-it-attrs/index.js in an old commit. So, I scrolled up and saw the version of the index.js without patterns and transforms. image

Anyways thanks for the clarification!