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

Definitions at end of section should be excluded #7

Closed
niftylettuce opened this issue Aug 20, 2017 · 11 comments
Closed

Definitions at end of section should be excluded #7

niftylettuce opened this issue Aug 20, 2017 · 11 comments
Labels
👀 no/external This makes more sense somewhere else

Comments

@niftylettuce
Copy link

If you have the following:

## License

[npm]: http://npmjs.org

Upon running remark with remark-license plugin it will strip the link [npm] etc

@wooorm
Copy link
Member

wooorm commented Aug 20, 2017

Correct! It's not very pretty.

This plugin uses https://github.com/syntax-tree/mdast-util-heading-range, so the definitions are passed in 'nodes', and to make them persist you can add them to the returned nodes.

I think it makes the most sense to actually, optionally, let heading-range do this.

What do you think?

@niftylettuce
Copy link
Author

This package conflicts though with your own preset.

I get tons of these warnings now:

  93:1-93:30  warning  Move definitions to the end of the file (after the node at line `171`)  final-definition            remark-lint
    95:1-95:34  warning  Move definitions to the end of the file (after the node at line `171`)  final-definition            remark-lint
    97:1-97:37  warning  Move definitions to the end of the file (after the node at line `171`)  final-definition            remark-lint
    99:1-99:27  warning  Move definitions to the end of the file (after the node at line `171`)  final-definition            remark-lint
  101:1-101:41  warning  Move definitions to the end of the file (after the node at line `171`)  final-definition            remark-lint
  103:1-103:49  warning  Move definitions to the end of the file (after the node at line `171`)  final-definition            remark-lint
  105:1-105:36  warning  Move definitions to the end of the file (after the node at line `171`)  final-definition            remark-lint
  107:1-107:40  warning  Move definitions to the end of the file (after the node at line `171`)  final-definition            remark-lint
  109:1-109:43  warning  Move definitions to the end of the file (after the node at line `171`)  final-definition            remark-lint
  111:1-111:41  warning  Move definitions to the end of the file (after the node at line `171`)  final-definition            remark-lint
  113:1-113:71  warning  Move definitions to the end of the file (after the node at line `171`)  final-definition            remark-lint
  115:1-115:52  warning  Move definitions to the end of the file (after the node at line `171`)  final-definition            remark-lint
  117:1-117:41  warning  Move definitions to the end of the file (after the node at line `171`)  final-definition            remark-lint
  119:1-119:30  warning  Move definitions to the end of the file (after the node at line `171`)  final-definition            remark-lint
  121:1-121:40  warning  Move definitions to the end of the file (after the node at line `171`)  final-definition            remark-lint
  123:1-123:36  warning  Move definitions to the end of the file (after the node at line `171`)  final-definition            remark-lint

@wooorm
Copy link
Member

wooorm commented Aug 20, 2017

I know, I don't use it personally.
Plus that's not a reply to my above comment 😛

@niftylettuce
Copy link
Author

niftylettuce commented Aug 20, 2017

I was confused by the comment* so much hahahaha

@wooorm wooorm changed the title If you have links at bottom of file below License section it strips them Definitions at end of section should be excluded Aug 20, 2017
@niftylettuce
Copy link
Author

@wooorm Since this plugin formats it to just a single line / node, shouldn't we only check for the next two immediate lines?

@niftylettuce
Copy link
Author

@wooorm How can we implement this? I'm trying to read through the docs now and understand Compiler - looking at headings gap plugin and experimenting.

@wooorm
Copy link
Member

wooorm commented Aug 20, 2017

No, I don‘t think we can just check one node. This feature would benefit other plugins too.

First, have you read up on what mdast-util-heading-range does?

In essence: it searches for a section, and gives you its first node (a heading), the content in the section, and the end node (another heading, or nothing if it it’s not there).

I think we should change that, optionally, by looking at end and then walking back, and moving all those definitions “outside” the section.

E.g., say you have the following:

# License

Paragraph

[definition-a]: example.com

[definition-b]: example.com

Proposed: Paragraph would be in nodes, definition-a would be end.
Currently: Paragraph, definition-a, definition-b are in nodes, there’s no end.

@niftylettuce
Copy link
Author

I don't think I'd be able to do this efficiently, I just did write a major plugin enhancement though over at remarkjs/remark-contributors#4, so that taught me a lot about remark and retext so far.

wooorm added a commit to syntax-tree/mdast-util-heading-range that referenced this issue Aug 21, 2017
wooorm added a commit to syntax-tree/mdast-util-heading-range that referenced this issue Aug 21, 2017
@wooorm
Copy link
Member

wooorm commented Aug 21, 2017

@niftylettuce
Copy link
Author

Can you add to this package and version bump? @wooorm

@wooorm
Copy link
Member

wooorm commented Aug 21, 2017

Could you create the loose PRs first? That way my changes won’t conflict yours. I’ll update it here after that.

@wooorm wooorm closed this as completed in 719bcbd Aug 10, 2018
@wooorm wooorm added the 👀 no/external This makes more sense somewhere else label Aug 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👀 no/external This makes more sense somewhere else
Development

No branches or pull requests

2 participants