-
Notifications
You must be signed in to change notification settings - Fork 330
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
Convert between inline link and reference link #260
Comments
Here is a node.js program I found if it can help: |
I agree that it might be useful. But I probably have little time for this in the near future. Let's see whether there is somebody can help. |
I don't have that much time the two next weeks neither but I could definitely help creating it after. 😃 |
Is there any progress on this? Could you make it work just like in StackExchange editor? |
Thanks for asking. Technically, it is not hard (I guess). But there are many corner cases to take into account. It would be great if anyone can help as now I only have limited time for this extension (for crucial bugs or small fixes). |
There is a reference But if you copy it to |
Well, if you look at the "Cases" section in the origin post of this issue, you will see a lot of implementation details, which are not considered in the link you mentioned. For example, <!-- From: -->
[My [simple] link](<uri uri> 'title \'n )(title')
<!-- To: -->
[My [simple] link][2_ref-def]
[2_ref-def]: <uri%20uri> "title 'n )(title" note
and more. As I said, it is not technically hard, but requires a certain amount of time. It cannot be a one-pass regex replacement but needs a reasonable workflow (e.g. A rough thinking tells me it should have 3 (maybe 2) steps: parse existing reference link definitions, identify inline/reference links, and then transform). If anyone can make a PR, I'm happy to review it. |
The original post has been merged into the formal proposal.
Proposal
Overview
Markdown provides multiple ways to create links. It would be useful to have refactorings that convert between inline and reference links. Doing it manually all the time makes me quite sad.
There are totally 12 kinds of conversions.
The following seem always feasible:
Out of reliability and compatibility concern, the other 5 conversions are possible only under certain circumstances.
In practice, the 5 kinds below should be enough:
The
Inline -> Collapsed
conversion is available only if no brackets ([
or]
) are next to the link, and the link text matches JavaScript regular expression/^[\w-]+$/
(only contains ASCII letters, digits, underscore, and hyphen).Cases
One inline link to full or collapsed reference link.
<
and>
."
) first, then'
.All inline links with the same destination and title to full reference links.
One reference link to inline link.
All reference links with the same link reference definition to inline links.
Code spans and code blocks should remain untouched.
Consecutive links should remain untouched. Too dangerous to process them.
References
The text was updated successfully, but these errors were encountered: