mdformat icon indicating copy to clipboard operation
mdformat copied to clipboard

convert inline links to references?

Open anarcat opened this issue 2 years ago • 7 comments

Context

I'm an apologetic reference link fan. For me, they make the source document easier to read, and I often send markdown documents by email (for various reasons) where it is particularly important to get those pesky links out of the way.

Proposal

It would be nice if mdformat could (optionally? in a plugin?) completely convert all inline links to references in a document. It's not a simple task, as references might clash with each other, so there needs to be some tracking for that...

I understand if that can't be part of mdformat per se, but I figured i would use this space to open up discussion about this, perhaps someone else has already found and fixed that problem themselves?

Thanks!

Tasks and updates

No response

anarcat avatar Dec 21 '23 03:12 anarcat

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:

welcome[bot] avatar Dec 21 '23 03:12 welcome[bot]

Super interested by this as well. Would be happy to try and send a PR if a maintainer can provide some initial guidance :smile:

pawamoy avatar Apr 14 '24 16:04 pawamoy

Would love to see this - but it does mean this tooling needs to make very opinionated decisions about how to make the translation from inline -> reference links work

  • what is the ID system enforced? ( [text used][ID])
  • what is the location of reference links in a page? (always at the end?)
    • how are references sorted? (ID alphanumeric decending?)
  • is the inverse possible? (replace ID with URL)

nuke-web3 avatar Jun 19 '24 16:06 nuke-web3

Good questions.

  • ID system: I'd say, use the text as-is, i.e. [some text] or [some text][], and [some text]: url. The user can then change the ID and mdformat would respect it next times it formats.
  • location: I think it currently always puts all references at the end of the page
  • sorting: I'd say sort on IDs yes, lower case, 0 -> 9 then a -> z
  • seems doable. Might be done in later PRs?

We just need updates from maintainers :slightly_smiling_face:

pawamoy avatar Jun 20 '24 10:06 pawamoy