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

Handle Line-Wrapped Links #61

Open
hasheddan opened this issue Mar 27, 2020 · 15 comments
Open

Handle Line-Wrapped Links #61

hasheddan opened this issue Mar 27, 2020 · 15 comments

Comments

@hasheddan
Copy link

Is your feature request related to a problem? Please describe the problem you're trying to solve.

Currently, if a link is wrapped in valid markdown style (i.e. line break in either text or url section), it is not handled by the relative links plugin.

Describe the solution you'd like

Line wrapped links handled in the same manner as normal links.

Describe alternatives you've considered

Other options include not line-wrapping links (can be painful if the rest of the doc is line-wrapped), or using permalinks to force all to .md (can break if directory structure is generated by outside source).

Additional context

Example:

[my cool link](cool-doc.md)

gets correctly converted to:

[my cool link](cool-doc.html)

But,

[my cool 
link](cool-doc.md)

does not get handled and still points to cool-doc.md.

I am happy to do the work to implement this feature, but will likely need some direction :)

@hasheddan
Copy link
Author

@benbalter is this as simple as adding /m option to INLINE_LINK_REGEX (and REFERENCE_LINK_REGEX if we want that also) to enable multi-line mode?

INLINE_LINK_REGEX = %r!\[#{LINK_TEXT_REGEX}\]\(([^\)]+?)#{FRAG_AND_TITLE_REGEX}\)!.freeze

@benbalter
Copy link
Owner

benbalter commented Mar 27, 2020

Based on https://spec.commonmark.org/, I don't believe links can have new lines in them. Do you read the spec otherwise?

@hasheddan
Copy link
Author

hasheddan commented Mar 27, 2020

@benbalter thank you for the quick response :) You can have breaks in an in-line markdown link as long as it does not break the actual link text. Examples: https://gist.github.com/hasheddan/0fcebadaa82f29fd51ab0bcd36d193dd

Gist
GitHub Gist: instantly share code, notes, and snippets.

@hasheddan
Copy link
Author

hasheddan commented Mar 27, 2020

Some examples with the commonmark tool: https://spec.commonmark.org/dingus/?text=%5Ba%20cool%0Alink%5D(%2Furl)%0A%0A%5Banother%20cool%0Alink%5D(%0A%2Furl)%0A%0A%5B%0Aand%20another%20one%0A%5D(%2Furl)%0A

@thaJeztah
Copy link

👍 just ran into this issue when debugging why some links were not handled correctly, but others did, and came to the same conclusion that it was due to those links being wrapped. I would prefer wrapped links to work, as it's quite commonly used.

@hasheddan
Copy link
Author

@benbalter I am happy to make this update 👍 I don't work with Ruby too frequently, any tips on building / testing this project?

@hasheddan
Copy link
Author

@benbalter just following up here :) anything I can do to help?

@stale
Copy link

stale bot commented Jun 6, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jun 6, 2020
@hasheddan
Copy link
Author

@benbalter i would love to help get this fixed, any chance we could reopen this?

@stale
Copy link

stale bot commented Aug 8, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Aug 8, 2020
@thaJeztah
Copy link

still relevant

@stale stale bot removed the wontfix label Aug 8, 2020
@stale
Copy link

stale bot commented Oct 11, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Oct 11, 2020
@thesofakillers
Copy link

still relevant

@stale stale bot removed the wontfix label Oct 12, 2020
@stale
Copy link

stale bot commented Dec 25, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Dec 25, 2020
reiddraper added a commit to reiddraper/jekyll-relative-links that referenced this issue Feb 4, 2021
Uses https://github.com/gjtorikian/commonmarker to create an AST,
manipulates the AST to rewrite links, and then converts back into
markdown.

Fixes benbalter#61

Fixing benbalter#61 was
the main motivation for doing this fundamental change, as it wasn't
obvious how to manipulate the regex to accomplish allowing newlines the
markdown link text (not the URL).

Unforununately the test suite did not respond well to this change, as
much of the suite is expecting that the *only* thing modified is the
link text, whereas since we roundtrip now from source -> ast ->
markdown, there are several bits of the original source that are not
respected. For example, in certain situations ' quotes are replaced with
". There are also some minor newline changes, in fact links with
newlines in the text are rewritten to be on a single line.

Lastly, the handing of footnotes is different, as the AST/parser does
not represent a footnote 'source' as it's own entity, the footnotes are
simply 'followed' and reference links are rewritten to be replaced with
the reference's link.

These changes required quite a bit of surgery on the test suite.
@settings settings bot removed the wontfix label Sep 16, 2021
bnf added a commit to bnf/systemd that referenced this issue May 17, 2022
Allows for links to work equally on systemd.io and
on https://github.com/systemd/systemd/tree/main/docs

The markdown links are converted by jekyll-relative-links[1]
enabled by default on github pages[2][3].

Due to a bug in jekyll-relative-links – see
benbalter/jekyll-relative-links#61 –
we need to avoid line-wrapped links when using relative markdown links.

[1] https://github.com/benbalter/jekyll-relative-links
[2] https://github.blog/2016-12-05-relative-links-for-github-pages/
[3] https://docs.github.com/en/pages/setting-up-a-github-pages-site-with-jekyll/about-github-pages-and-jekyll#plugins
bnf added a commit to bnf/systemd that referenced this issue May 17, 2022
Allows for links to work equally on systemd.io and
on https://github.com/systemd/systemd/tree/main/docs

The markdown links are converted by jekyll-relative-links[1]
enabled by default on github pages[2][3].

Due to a bug in jekyll-relative-links – see
benbalter/jekyll-relative-links#61 –
we need to avoid line-wrapped links when using relative markdown links.

[1] https://github.com/benbalter/jekyll-relative-links
[2] https://github.blog/2016-12-05-relative-links-for-github-pages/
[3] https://docs.github.com/en/pages/setting-up-a-github-pages-site-with-jekyll/about-github-pages-and-jekyll#plugins
bnf added a commit to bnf/systemd that referenced this issue May 18, 2022
Allows for links to work both on systemd.io (or forks) and
when viewed on https://github.com/systemd/systemd/tree/main/docs

Note that the markdown links are converted by jekyll-relative-links[1]
to html. This plugin is enabled by default on github pages[2][3].

Due to a bug in jekyll-relative-links – see
benbalter/jekyll-relative-links#61 –
we need to avoid line-wrapped links when using relative markdown links.

[1] https://github.com/benbalter/jekyll-relative-links
[2] https://github.blog/2016-12-05-relative-links-for-github-pages/
[3] https://docs.github.com/en/pages/setting-up-a-github-pages-site-with-jekyll/about-github-pages-and-jekyll#plugins
behrmann pushed a commit to uapi-group/specifications that referenced this issue Oct 18, 2022
Allows for links to work both on systemd.io (or forks) and
when viewed on https://github.com/systemd/systemd/tree/main/docs

Note that the markdown links are converted by jekyll-relative-links[1]
to html. This plugin is enabled by default on github pages[2][3].

Due to a bug in jekyll-relative-links – see
benbalter/jekyll-relative-links#61 –
we need to avoid line-wrapped links when using relative markdown links.

[1] https://github.com/benbalter/jekyll-relative-links
[2] https://github.blog/2016-12-05-relative-links-for-github-pages/
[3] https://docs.github.com/en/pages/setting-up-a-github-pages-site-with-jekyll/about-github-pages-and-jekyll#plugins
keszybz pushed a commit to uapi-group/specifications that referenced this issue Oct 19, 2022
Allows for links to work both on systemd.io (or forks) and
when viewed on https://github.com/systemd/systemd/tree/main/docs

Note that the markdown links are converted by jekyll-relative-links[1]
to html. This plugin is enabled by default on github pages[2][3].

Due to a bug in jekyll-relative-links – see
benbalter/jekyll-relative-links#61 –
we need to avoid line-wrapped links when using relative markdown links.

[1] https://github.com/benbalter/jekyll-relative-links
[2] https://github.blog/2016-12-05-relative-links-for-github-pages/
[3] https://docs.github.com/en/pages/setting-up-a-github-pages-site-with-jekyll/about-github-pages-and-jekyll#plugins
Yamakuzure pushed a commit to elogind/elogind that referenced this issue Dec 21, 2022
Allows for links to work both on systemd.io (or forks) and
when viewed on https://github.com/systemd/systemd/tree/main/docs

Note that the markdown links are converted by jekyll-relative-links[1]
to html. This plugin is enabled by default on github pages[2][3].

Due to a bug in jekyll-relative-links – see
benbalter/jekyll-relative-links#61 –
we need to avoid line-wrapped links when using relative markdown links.

[1] https://github.com/benbalter/jekyll-relative-links
[2] https://github.blog/2016-12-05-relative-links-for-github-pages/
[3] https://docs.github.com/en/pages/setting-up-a-github-pages-site-with-jekyll/about-github-pages-and-jekyll#plugins
@aaronmw
Copy link

aaronmw commented Jan 30, 2023

Still relevant. Just lost a bunch of hours trying to pin down our issues.

aspiers added a commit to rolod0x/rolod0x that referenced this issue Apr 22, 2024
Line-wrapping breaks link translation by jekyll-relative-links:

benbalter/jekyll-relative-links#61
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants