Giter Club home page Giter Club logo

jekyll-relative-links's Introduction

Jekyll Relative Links

CI

A Jekyll plugin to convert relative links to Markdown files to their rendered equivalents.

What it does

Let's say you have a link like this in a Markdown file:

[foo](bar.md)

While that would render as a valid link on GitHub.com, it would not be a valid link on Pages. Instead, this plugin converts that link to:

[foo](bar.html)

It even work with pages with custom permalinks. If you have bar.md with the following:

---
permalink: /bar/
---

# bar

Then [foo](bar.md) will render as [foo](/bar/).

The default Jekyll's configuration permalink: pretty in the _config.yaml file removes the .html extensions from the generated links.

Why

Because Markdown files rendered by GitHub Pages should behave similar to Markdown files rendered on GitHub.com

Usage

  1. Add the following to your site's Gemfile:
gem 'jekyll-relative-links'
  1. Add the following to your site's config file:
plugins:
  - jekyll-relative-links

Note: If you are using a Jekyll version less than 3.5.0, use the gems key instead of plugins.

Configuration

You can configure this plugin in _config.yml under the relative_links key. This is optional and defaults to:

relative_links:
  enabled:     true
  collections: false

Excluding files

To exclude specific directories and/or files:

relative_links:
  exclude:
    - directory
    - file.md

Processing Collections

Setting the collections option to true enables relative links from collection items (including posts).

Assuming this structure

├── _my_collection
│   ├── some_doc.md
│   └── some_subdir
│       └── another_doc.md
├── _config.yml
└── index.md

the following will work:

File Link
index.md [Some Doc](_my_collection/some_doc.md)
index.md [Another Doc](_my_collection/some_subdir/another_doc.md)
_my_collection/some_doc.md [Index](../index.md)
_my_collection/some_doc.md [Another Doc](some_subdir/another_doc.md)
_my_collection/some_subdir/another_doc.md [Index](../../index.md)
_my_collection/some_subdir/another_doc.md [Some Doc](../some_doc.md)

Disabling

Even if the plugin is enabled (e.g., via the :jekyll_plugins group in your Gemfile) you can disable it by setting the enabled key to false.

jekyll-relative-links's People

Contributors

aloisklink avatar andymond avatar benbalter avatar bwdmonkey avatar dato avatar dependabot-preview[bot] avatar janpio avatar jeff-matthews avatar kenman345 avatar krichardsson avatar nono avatar parkr avatar petk avatar philip-linaro avatar qwtel avatar rmccue avatar windol avatar zeke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

jekyll-relative-links's Issues

Release a new version

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

It seems that this has not been released since 2019.

Describe the solution you'd like

Could you release a new version.

Describe alternatives you've considered

I did not see any new versions on https://rubygems.org/gems/jekyll-relative-links/versions/0.6.1

Additional context

I am very interested in this change specifically #71

url_for_path failing

I'm using jekyll 3.5.1 and trying to use jekyll-relative-links to fix the problem of GitHub MD files not being linked properly when the pages are built.

When I try to build the site, I get:

NoMethodError: undefined method `sub` for nil:NilClass

The stacktrace is:

/home/philip/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/jekyll-relative-links-0.4.1/lib/jekyll-relative-links/generator.rb:77:in `block in url_for_path'
/home/philip/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/jekyll-relative-links-0.4.1/lib/jekyll-relative-links/generator.rb:77:in `each'
/home/philip/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/jekyll-relative-links-0.4.1/lib/jekyll-relative-links/generator.rb:77:in `find'
/home/philip/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/jekyll-relative-links-0.4.1/lib/jekyll-relative-links/generator.rb:77:in `url_for_path'
/home/philip/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/jekyll-relative-links-0.4.1/lib/jekyll-relative-links/generator.rb:41:in `block in replace_relative_links!'
/home/philip/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/jekyll-relative-links-0.4.1/lib/jekyll-relative-links/generator.rb:36:in `gsub!'
/home/philip/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/jekyll-relative-links-0.4.1/lib/jekyll-relative-links/generator.rb:36:in `replace_relative_links!'
/home/philip/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/jekyll-relative-links-0.4.1/lib/jekyll-relative-links/generator.rb:29:in `block in generate'
/home/philip/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/jekyll-relative-links-0.4.1/lib/jekyll-relative-links/generator.rb:27:in `each'
/home/philip/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/jekyll-relative-links-0.4.1/lib/jekyll-relative-links/generator.rb:27:in `generate'
/home/philip/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/jekyll-3.5.1/lib/jekyll/site.rb:178:in `block in generate'
/home/philip/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/jekyll-3.5.1/lib/jekyll/site.rb:176:in `each'
/home/philip/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/jekyll-3.5.1/lib/jekyll/site.rb:176:in `generate'
/home/philip/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/jekyll-3.5.1/lib/jekyll/site.rb:72:in `process'
/home/philip/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/jekyll-3.5.1/lib/jekyll/command.rb:26:in `process_site'
/home/philip/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/jekyll-3.5.1/lib/jekyll/commands/build.rb:63:in `build'
/home/philip/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/jekyll-3.5.1/lib/jekyll/commands/build.rb:34:in `process'
/home/philip/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/jekyll-3.5.1/lib/jekyll/commands/build.rb:16:in `block (2 levels) in init_with_program'
/home/philip/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'
/home/philip/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'
/home/philip/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'
/home/philip/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'
/home/philip/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
/home/philip/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/jekyll-3.5.1/exe/jekyll:13:in `<top (required)>'
/home/philip/.rbenv/versions/2.4.1/bin/jekyll:22:in `load'
/home/philip/.rbenv/versions/2.4.1/bin/jekyll:22:in `<top (required)>'

If I add a print statement to url_for_path so that I can see what path is set to, it is:

go/go/hackathon-mexico

and that link is coming from this file:

---
title: 96boards Go Events
permalink: /go/
layout: empty-container-page-no-nav
redirect_from:
- /go/aosp/
---
# 96boards Go Pages
[Go Hackathon Mexico](/go/hackathon-mexico/)
[Go Hackathon India Summer 2017](/go/hackathon-indiasummer2017/)
[Go DragonBoard-410c Partnership Brazil](/go/db410c-partnership-brazil/)

Now, in the main jekyll directory, the tree structure includes:

go
    hackathon-mexico
        README.md

I'm presuming from the nil error that p.relative_path is resolving to nil rather than a string, but I'm not a Ruby programmer so I'm struggling to figure out what is going wrong. I thought that the links might be broken (which is why the code is resolving to a nil) but these pages are actually building properly at the moment because the links don't end with a .md filename.

What can I do to debug this further? Is it a problem with the plugin or with the site I'm trying to build?

Can't modify frozen String

We're getting the above error when we try to build our site. The error is occurring at:

document.content.gsub!(LINK_REGEX) do |original|
(in replace_relative_links, line 47)

Having done some more research, it would seem that this isn't allowed with Ruby 2.3 and later. The oft-recommended solution is to call 'dup' on the content first then modify that duplicate copy but I don't know Ruby enough to unpick that from the do-loop.

Thanks.

References to `subfolder/foo.md` don't point to html files.

Describe the bug

References to subfolder/foo.md don't point to html files.

Steps to reproduce the behavior

The following call - referencing a document alongside my top-level index.html - works as expected:

[User documentatioen](./README.md)
use after processing poits to
local http://127.0.0.1:4000/README.html
remote https://nfttix.github.io/README.html

Subfolders, on the other hand, don't get the same treatment. Each of the following:

[fail](./my-account/README.md)		# ./foo/bar.md
[also fail](/my-account/README.md)	# /foo/bar.md
[more fail](my-account/README.md) 	# foor/bar.md
use after processing poits to
local http://127.0.0.1:4000/my-account/README.md
remote https://nfttix.github.io/my-account/README.md

Expected behavior

Each of these variants will point to the README.html instead of README.md.

Screenshots

N/A

Additional context

Versions are pegged to Github Pages' dependency versions.

$ ruby -v
ruby 2.7.8p225 (2023-03-30 revision 1f4d455848) [x86_64-darwin22]
$ bundle exec jekyll -v
jekyll 3.9.3
$ sw_vers
ProductName:		macOS
ProductVersion:		13.3.1
ProductVersionExtra:	(a)
BuildVersion:		22E772610a
$

Gemfile excerpt

gem 'github-pages', '228', group: :jekyll_plugins
group :jekyll_plugins do
  gem 'jekyll-relative-links', '0.6.1'
end

_config.yml excerpt

plugins:
  - jekyll-relative-links
relative_links:
  enabled:     true
  collections: true

Relative links not working in includes

Description

Create a brand new Jekyll site with the following content:

  • index.md
Hello, world!
[Target](target.md)
or {% include include.md %}
  • target.md
(anything)
  • _includes/include.md
Also try go to the [Target](target.md)

Enable jekyll-relative-links, and build the site.

Expected behavior

Both links to target.md are rendered as <a href="target.html">.

Actual behaviour

Only the link to target.md in the root markdown is rendered as <a href="target.html">.

The link included through the include is rendered as <a href="target.md">, breaking navigation.

Workarounds

None known. Changing the include to relative e.g. [Target](../target.md) doesn't work either.

Links with title not working

Describe the bug

If a relative link contains a title, the resulting link is not redirecting to the generated html file, but maintaining the reference to the markdown.

Steps to reproduce the behavior

This markdown:

[CHANGELOG](./CHANGELOG.md "Changelog")

Generate:

<a href="./CHANGELOG.md" title="Changelog">CHANGELOG</a>

But, this markdown:

[CHANGELOG](./CHANGELOG.md)

Generate:

<a href="/CHANGELOG.html">CHANGELOG</a>

Regression in 0.5.0 using reference links to files that exist

The following file works fine (renders the link) with 0.5.0

---
layout: page
title: Examples
---

[link][link]

[link]: does_not_exist

However, if you create does_not_exist as an empty file, it renders as [link][link] [link]: /does_not_exist.

However on 0.4.1 it would render a link regardless of whether the file existed or not.

Support relative links pointing outside of the Jekyll site?

Problem

We have Markdown documentation for a software project. Let's call the repo directory "repo". The /docs directory in this project is served via GitHub Pages, so repo/docs/index.md is served as $user.github.io/repo/index.html

For local use and viewed on GitHub, index.md could link to source code, or other content outside of docs/: index.md could link to "../src/main.cc" for example. Currently this rewrites to $user.github.io/src/index.html

I'd love to be able to configure a Jekyll plugin to rewrite relative links that point at the parent of docs/, to rather point at https://github.com/$user/repo/tree/master or https://github.com/$user/repo/tree/$selected_release_tag

Preferred solution

I'd love to configure Jeyll Relative Links to indicate what URL I wish it to consider to be the parent of docs/ - perhaps if I tell it the parent of docs/ should be considered to be http://example.com/foo/bar/baz/, it could even handle grandparent (.../foo/bar/) or great-grandparent (.../foo/) of docs.

Alternative solution

  • If this feels too out of scope for Jekyll Relative Links, it might need to be a different plugin?
  • I've considered creating a new repo for $user, called $src, so that I can serve a simple html redirect page on $user.github.io/src/ - but I think I'd need a page for every page I want to redirect, I don't think I can set up a redirect for the whole tree.

Issue with Umlauts in file path on windows

Describe the bug

When a umlaut is present in the file path a error message occurs

jekyll 3.9.0 | Error:  incompatible encoding regexp match (Windows-1252 regexp with UTF-8 string)
Traceback (most recent call last):
        26: from C:/Ruby27-x64/bin/jekyll:23:in `<main>'
        25: from C:/Ruby27-x64/bin/jekyll:23:in `load'
        24: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-3.9.0/exe/jekyll:15:in `<top (required)>'
        23: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
        22: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'
        21: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'
        20: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'
        19: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'
        18: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-3.9.0/lib/jekyll/commands/serve.rb:75:in `block (2 levels) in init_with_program'
        17: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-3.9.0/lib/jekyll/commands/serve.rb:93:in `start'
        16: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-3.9.0/lib/jekyll/commands/serve.rb:93:in `each'
        15: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-3.9.0/lib/jekyll/commands/serve.rb:93:in `block in start'        14: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-3.9.0/lib/jekyll/commands/build.rb:36:in `process'
        13: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-3.9.0/lib/jekyll/commands/build.rb:65:in `build'
        12: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-3.9.0/lib/jekyll/command.rb:28:in `process_site'
        11: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-3.9.0/lib/jekyll/site.rb:70:in `process'
        10: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-3.9.0/lib/jekyll/site.rb:173:in `generate'
         9: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-3.9.0/lib/jekyll/site.rb:173:in `each'
         8: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-3.9.0/lib/jekyll/site.rb:175:in `block in generate'
         7: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-relative-links-0.6.1/lib/jekyll-relative-links/generator.rb:38:in `generate'
         6: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-relative-links-0.6.1/lib/jekyll-relative-links/generator.rb:38:in `each'
         5: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-relative-links-0.6.1/lib/jekyll-relative-links/generator.rb:43:in `block in generate'
         4: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-relative-links-0.6.1/lib/jekyll-relative-links/generator.rb:51:in `replace_relative_links!'
         3: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-relative-links-0.6.1/lib/jekyll-relative-links/generator.rb:51:in `gsub'
         2: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-relative-links-0.6.1/lib/jekyll-relative-links/generator.rb:55:in `block in replace_relative_links!'
         1: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-relative-links-0.6.1/lib/jekyll-relative-links/generator.rb:99:in `path_from_root'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/jekyll-relative-links-0.6.1/lib/jekyll-relative-links/generator.rb:99:in `sub': incompatible encoding regexp match (Windows-1252 regexp with UTF-8 string) (Encoding::CompatibilityError)

Steps to reproduce the behavior

  1. Clone https://github.com/tobi6112/jekyll-issue inside a directory with umlauts. For example C:\tmp\Köln\jekyll-issue
  2. Run bundle exec jekyll serve

Additional context

Running bundle exec jekyll serve from WSL is no problem.

StaticFiles with .md extensions cause NoMethod error

I have a project where I wanted to try the collections feature of this plugin. Unfortunately switching collections to true breaks jekyll s:

First run was this configuration:

relative_links:
  enabled: true
  collections: false

Result:

sujan@LenovoX1:/mnt/c/Users/Jan/Documents/ionic.zone$ bundle exec jekyll s
Configuration file: /mnt/c/Users/Jan/Documents/ionic.zone/_config.yml
       Deprecation: You appear to have pagination turned on, but you haven't included the `jekyll-paginate` gem. Ensure
you have `plugins: [jekyll-paginate]` in your configuration file.
            Source: /mnt/c/Users/Jan/Documents/ionic.zone
       Destination: /mnt/c/Users/Jan/Documents/ionic.zone/_site
 Incremental build: disabled. Enable with --incremental
      Generating...
                    done in 4.694 seconds.
                    Auto-regeneration may not work on some Windows versions.
                    Please see: https://github.com/Microsoft/BashOnWindows/issues/216
                    If it does not work, please upgrade Bash on Windows or run Jekyll with --no-watch.
 Auto-regeneration: enabled for '/mnt/c/Users/Jan/Documents/ionic.zone'
    Server address: http://127.0.0.1:4000/
  Server running... press ctrl-c to stop.
^C

Second, failing, run was done with this config:

relative_links:
  enabled: true
  collections: false

Result:

sujan@LenovoX1:/mnt/c/Users/Jan/Documents/ionic.zone$ bundle exec jekyll s
Configuration file: /mnt/c/Users/Jan/Documents/ionic.zone/_config.yml
       Deprecation: You appear to have pagination turned on, but you haven't included the `jekyll-paginate` gem. Ensure
you have `plugins: [jekyll-paginate]` in your configuration file.
            Source: /mnt/c/Users/Jan/Documents/ionic.zone
       Destination: /mnt/c/Users/Jan/Documents/ionic.zone/_site
 Incremental build: disabled. Enable with --incremental
      Generating...
jekyll 3.5.2 | Error:  undefined method `content' for #<Jekyll::StaticFile:0x0000000001ea5320>

From the error message I assume that somehow this line is failing:

document.content.gsub!(LINK_REGEX) do |original|
Probably because of some malformed .md file or link I have in this project.

How can I debug this further?
What should I do to find out which file is causing this?

Also process collections

Currently the plugin only processes pages. I'd like it to process collections as well. This should probably only apply to collections that use the output:true property since otherwise you wouldn't know how to resolve the relative link (although we could just replace .md with .html and /index.md with /).

Support Jekyll 4

Hi @benbalter,

Would you mind bumping the Jekyll requirement to allow v4 to be used? I can submit a PR if you'd like?

Best regards,

Kyle

Relative links not working in excerpts

Describe the bug

I'm using relative links between items in a collection (posts in this case), for example: ie [here's an old post](2010-03-03-somepost.md).

This works fine when individually viewing a post but for excerpts (i.e. when viewing a list of posts) the filename isn't replaced with the correct URL, it stays as 2019-03-03-somepost.md which doesn't work.

URLs with a fragment

Hi,

thanks for this plugin. It's a nice addition to Github pages.

I have a question: it seems that the plugin doesn't transform links to a markdown file when there is a fragment, is it expected? For example, if I have in the markdown [TOC](README.md#table-of-contents), it will still be a link to the markdown file on github pages, not to the HTML file.

YAML frontmatter field named `excerpt:` breaks jekyll-relative-links

Describe the bug

When a file has a field with the key excerpt: in its YAML frontmatter, jekyll-relative-links v0.7.0 will cause an exception that prevents the website from rendering:

Expand error log
Configuration file: ~/Documents/jekyll-test/_config.yml
            Source: ~/Documents/jekyll-test
       Destination: ~/Documents/jekyll-test/_site
 Incremental build: disabled. Enable with --incremental
      Generating...
       Jekyll Feed: Generating feed for posts
~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/excerpt.rb:93: warning: Jekyll::Excerpt#yaml_file? at /usr/local/Cellar/ruby/3.2.1/lib/ruby/3.2.0/forwardable.rb:159 forwarding to private method Jekyll::Page#yaml_file?
  Liquid Exception: undefined method `yaml_file?' for #<Jekyll::Page @relative_path="index.markdown"> in ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/minima-2.5.1/_layouts/default.html
                    ------------------------------------------------
      Jekyll 4.3.2   Please append `--trace` to the `build` command
                     for any additional information or backtrace.
                    ------------------------------------------------
/usr/local/Cellar/ruby/3.2.1/lib/ruby/3.2.0/forwardable.rb:238:in `yaml_file?': undefined method `yaml_file?' for #<Jekyll::Page @relative_path="index.markdown"> (NoMethodError)
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/excerpt.rb:93:in `render_with_liquid?'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/renderer.rb:78:in `render_document'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/renderer.rb:63:in `run'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/excerpt.rb:83:in `output'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/excerpt.rb:70:in `to_s'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/page.rb:193:in `excerpt'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/convertible.rb:117:in `block in to_liquid'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/convertible.rb:116:in `each'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/convertible.rb:116:in `each_with_object'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/convertible.rb:116:in `to_liquid'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/standardfilters.rb:499:in `block in each'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/standardfilters.rb:498:in `each'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/standardfilters.rb:498:in `each'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/standardfilters.rb:220:in `map'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/standardfilters.rb:220:in `map'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/strainer.rb:56:in `invoke'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/context.rb:86:in `invoke'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/variable.rb:84:in `block in render'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/variable.rb:82:in `each'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/variable.rb:82:in `inject'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/variable.rb:82:in `render'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/tags/assign.rb:26:in `render'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/block_body.rb:103:in `render_node_to_output'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/block_body.rb:91:in `render'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/template.rb:206:in `block in render'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/template.rb:240:in `with_profiling'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/template.rb:205:in `render'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/template.rb:218:in `render!'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:39:in `block (3 levels) in render!'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:59:in `measure_counts'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:38:in `block (2 levels) in render!'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:63:in `measure_bytes'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:37:in `block in render!'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:70:in `measure_time'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:36:in `render!'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/inclusion.rb:16:in `render'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/tags/include.rb:208:in `block in render'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/context.rb:123:in `stack'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/tags/include.rb:206:in `render'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/block_body.rb:103:in `render_node_to_output'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/block_body.rb:91:in `render'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/template.rb:206:in `block in render'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/template.rb:240:in `with_profiling'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/template.rb:205:in `render'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/liquid-4.0.4/lib/liquid/template.rb:218:in `render!'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:39:in `block (3 levels) in render!'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:59:in `measure_counts'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:38:in `block (2 levels) in render!'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:63:in `measure_bytes'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:37:in `block in render!'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:70:in `measure_time'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:36:in `render!'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/renderer.rb:129:in `render_liquid'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/renderer.rb:192:in `render_layout'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/renderer.rb:161:in `place_in_layouts'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/renderer.rb:93:in `render_document'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/renderer.rb:63:in `run'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/site.rb:572:in `render_regenerated'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/site.rb:557:in `block (2 levels) in render_docs'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/site.rb:556:in `each'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/site.rb:556:in `block in render_docs'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/site.rb:555:in `each_value'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/site.rb:555:in `render_docs'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/site.rb:210:in `render'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/site.rb:80:in `process'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/command.rb:28:in `process_site'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/commands/build.rb:65:in `build'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/commands/build.rb:36:in `process'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/command.rb:91:in `block in process_with_graceful_fail'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/command.rb:91:in `each'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/command.rb:91:in `process_with_graceful_fail'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/lib/jekyll/commands/build.rb:18:in `block (2 levels) in init_with_program'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `block in execute'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `each'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `execute'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/lib/mercenary/program.rb:44:in `go'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/mercenary-0.4.0/lib/mercenary.rb:21:in `program'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/gems/jekyll-4.3.2/exe/jekyll:15:in `<top (required)>'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/bin/jekyll:25:in `load'
	from ~/Documents/jekyll-test/.vendor/bundle/ruby/3.2.0/bin/jekyll:25:in `<top (required)>'
	from /usr/local/Cellar/ruby/3.2.1/lib/ruby/3.2.0/bundler/cli/exec.rb:58:in `load'
	from /usr/local/Cellar/ruby/3.2.1/lib/ruby/3.2.0/bundler/cli/exec.rb:58:in `kernel_load'
	from /usr/local/Cellar/ruby/3.2.1/lib/ruby/3.2.0/bundler/cli/exec.rb:23:in `run'
	from /usr/local/Cellar/ruby/3.2.1/lib/ruby/3.2.0/bundler/cli.rb:491:in `exec'
	from /usr/local/Cellar/ruby/3.2.1/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	from /usr/local/Cellar/ruby/3.2.1/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from /usr/local/Cellar/ruby/3.2.1/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	from /usr/local/Cellar/ruby/3.2.1/lib/ruby/3.2.0/bundler/cli.rb:34:in `dispatch'
	from /usr/local/Cellar/ruby/3.2.1/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	from /usr/local/Cellar/ruby/3.2.1/lib/ruby/3.2.0/bundler/cli.rb:28:in `start'
	from /usr/local/Cellar/ruby/3.2.1/lib/ruby/gems/3.2.0/gems/bundler-2.4.6/exe/bundle:45:in `block in <top (required)>'
	from /usr/local/Cellar/ruby/3.2.1/lib/ruby/3.2.0/bundler/friendly_errors.rb:117:in `with_friendly_errors'
	from /usr/local/Cellar/ruby/3.2.1/lib/ruby/gems/3.2.0/gems/bundler-2.4.6/exe/bundle:33:in `<top (required)>'
	from /usr/local/opt/ruby/bin/bundle:25:in `load'
	from /usr/local/opt/ruby/bin/bundle:25:in `<main>'

Steps to reproduce the behavior

  1. Setup the default Jekyll website and add gem "jekyll-relative-links", "0.7.0" to the Gemfile
  2. Add a field named excerpt: with any value to the YAML frontmatter of a Markdown file in the repo.
  3. jekyll build
  4. See error log above

Expected behavior

Jekyll-relative-links should not interfere with well-formed YAML frontmatter.

Attached test repo

jekyll-test.zip

Additional context

  • Reproduced the exception with both Jekyll v4.2.0 and v4.3.2
  • Exception only affects jekyll-relative-links v0.7.0, not 0.6.1
  • The excerpt: field needs to have a value (any value, string, number or date) for the exception to occur.

Relative links to images (and other non markdown content) under a collection folder don't work

Describe the bug

Relative links to images (and other non markdown content) under a collection folder don't work. For example, suppose we have a file _posts > media > example.svg. Then we try to reference that image from _post > example_post.md. The relative file link would be ./media/example.svg. Building this just outputs the relative file path (in this case ./media/examples.svg) and does not link to the image at runtime.

I eventually realized that this is probably because jekyll doesn't automatically publish files in collection folders.

Expected behavior

It would be nice if the image content could be copied over, but there are certainly issues deciding how that should work.

I think a sufficient fix would be making this behavior clear in the processing collections section of the documentation.

I can contribute the documentation if you'd like.

Additional context

Using jekyll-relative-links 0.6.1 and jekyll 3.8.7 on windows.

Links with hex-encoded spaces in the path aren't processed correctly

Describe the bug

Links with hex-encoded spaces (%20) don't get processed correctly

Steps to reproduce the behavior

In a situation where you have files / directories with spaces in their names, e.g.

├── index.md
└── sub folder
        └── file with spaces.md

A link such as this...

[Link Name](sub%20folder/file%20with%20spaces.md)

... doesn't get processed correctly - I'm guessing because the parsing of the link URL doesn't match the .md file name with the hex-encoded spaces (%20)

(Note: I came across this as I'm trying to get a collection of MD files from Obsidian into GitHub pages. Yes, I can go through my entire vault and rename every file and link to have no spaces, but I'd rather not!)

Expected behaviour

A link such as this...

[Link Name](sub%20folder/file%20with%20spaces.md)

... should get processed to this...

[Link Name](sub%20folder/file%20with%20spaces.html)

[welcome bot] CONTRIBUTING.md is missing

Welcome bot links to non-existent file:

newPRWelcomeComment: Welcome! Congrats on your first pull request to benbalter/jekyll-relative-links. If you haven't already, please be sure to check out [the contributing guidelines](https://github.com/benbalter/jekyll-relative-linksblob/master/docs/CONTRIBUTING.md).

Can't PR fixed link as file doesn't exist at all.

Detect broken links

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

Suppose I create a link like this:

See [the help page](support/help.md) for more troubleshooting info.

Describe the solution you'd like

If ./support/help.md would be a broken link at runtime, then Jekyll should fail with an error at build time.

Additional context

Currently jekyll-relative-links seems to silently emit a broken hyperlink.

Some relative links are not converted

Describe the bug

In this code

Posiblemente necesites [configurar tu
infraestructura](infraestructura/1.ConcienciaSituacional.md) antes de pasar al
nivel siguiente; cuando lo hagas, comienza con [él](2.Modelo.md).

that's translated to this web page (last paragraph, scroll down). The second URL is converted to its suffix-less equivalent... The first one is not.

Steps to reproduce the behavior

I guess that paragraph by itself should fail. This paragraph:

 Se puede consultar [el
  documento de infraestructura](infraestructura/0.PRs.md), que muestra el punto

Fails to convert too. Maybe it's the fact that the reference to the URL is split in two lines?

Expected behavior

It's a relative URL alright. It should be converted.

Additional context

Here's the repo https://github.com/JJ/MPDA-IS It's using the GitHub pages, so that might translate to specific versions or processors.

Detect dead links (perhaps using Jekyll’s own {% link %}?)

Jekyll normally aborts the build if it finds a dead link such as {% link nonexistant.md %}.

This is very useful behavior (prevents publishing dead links), but it is lost when using jekyll-relative-links (which is a very useful plugin as well).

Perhaps… jekyll-relative-links could rewrite relative links to use {% link ...md %} instead of replacing in the URL directly?

I toyed with an initial patch, it seems to me it can be done, but there are one or two ugly corner cases (e.g. fragments, which are not supported by {% link %}).

I’d love to hear, in the first place, what the maintainers think of the “fail the build if there’s a dead relative link”.

Many thanks in advance.

Links from normal pages to collections are broken

I was just playing around with the new collections functionality, and seem to have broken something.

Project Source: https://github.com/janpio/jekyll-relative-links_test
Hosted on GH: https://janpio.github.io/jekyll-relative-links_test/ (Same result with jekyll s locally)

File structure looks like this:

.
├── _articles
│   ├── folder
│   │   └── test2.md
│   └── test.md
├── foo.md
├── index.md

articles is registered as a collection, the collections feature of jekyll-relative-links is enabled.

https://janpio.github.io/jekyll-relative-links_test/
https://janpio.github.io/jekyll-relative-links_test/foo.html
Note the 2 broken links to the "articles".

(via https://janpio.github.io/jekyll-relative-links_test/dump.html you get a list of all articles)

https://janpio.github.io/jekyll-relative-links_test/test
https://janpio.github.io/jekyll-relative-links_test/folder/test2
Note that here both the links to the pages and to the articles work.

Am I missing something or is this case not covered (yet)?

Several link formats with brackets and spaces are not rewritten

Greetings 😃
I've just started using Github Pages and put my generated documentation on it - my files work flawlessly when viewed from repository, but some links are not rewritten when viewing the generated site.

Here is a minimal example:

# Hello, world!

Working links:
* [Simple one](plain-one.md)
* [With square brackets and no spaces](square-[brackets].md)

Not working links (extension doesn't change):
* [Words with spaces](words with spaces.md)
* [Round brackets](round-(brackets).md)
* [Square brackets with spaces](square [brackets] with spaces.md)
* [Square brackets with text after it](square-[brackets]-heyo.md) - this one gets cut off

Maybe there is other patterns that don't work too, that's only the ones I've found so far.
For a live example, you can view the website I'm talking about.

I was able to reproduce the issue on newly installed local Github Pages installation (gem 'github-pages', group: :jekyll_plugins).

I guess that the link extracting regexes don't cover these patterns, but I'm not sure.
I've also considered an HTML escaping of links in my generator, but that would hurt readability of filenames when viewed from the repo, so I hope that this could be fixed.
If any additional info is needed, I'll be happy to add it.

unable to disable?

i was getting an error, so i tried to just disable it with:

relative_links:
  enabled: false 

but it doesn't seem to change anything: the build process still runs the generator

the error:

Generating: JekyllRelativeLinks::Generator finished in 7.7e-06 seconds.
[91](https://github.com/rahil627/marks-of-rathewolf/runs/5605531619?check_suite_focus=true#step:4:91)
github-pages 225 | Error:  Invalid scheme format: 'Engels, Friedrich - Socialism'

i tried searching for the text (in github and with grep) and couldn't find it, but surely it's in there somewhere... 😓

.html extension ommited

I use this permalink configuration:

permalink: :year/:month/:title.html

But when I create a link with [link text](markdown.md), the generated HTML link points to markdown instead of markdown.html.

Any way to change that? Maybe a setting I didn't notice?

Thanks.

Reference-style links are not processed when tag definition is indented

Given the following file:

[This is a link][]


  [This is a link]: self.md

This HTML is generated:

<p><a href="self.md">This is a link</a></p>

Notice that the resulting link goes to self.md instead of self.html.

If you remove the indentation in the final line of the markdown file (where the link destination is declared) the generated HTML correctly points to self.html

Links with encoded spaces (%20) are not transformed

Describe the bug

A markdown file containing links to other files which have spaces in their names (example - Line 27).

This was previously reported under #48, but was closed as stale.

Steps to reproduce the behavior

  1. Create a link to a markdown file with a space in it
  2. Build
  3. See that the link retains the .md extension

Expected behavior

The .md link should be .html instead.

Additional context

Live GitHub pages site with this issue: https://davwheat-bhasvic.github.io/btec-notetaking/

Encoded Spaces Don't Work

Describe the bug

MD files with links like this /docs/space%20test.md aren't converted.

Steps to reproduce the behavior

Create a link like this /docs/space%20test.md. It is a valid relative link in MD on GH. However, it won't be converted, e.g., for GH pages.

Expected behavior

I would expect that links with encoded spaces are also converted.

Validating links?

Hi,
It seems links are not validated, in the way they are when you use {% link my_page.md %}

Would it be possible to add an option for this?

Links starting with `~` or `/~` results in Ruby exception

For example, the following content in the middle of a document causes an exception:

[text](/~nonexistent/example.pdf)

We encountered this when migrating a large (dirty) site where we had a lot of references in the format /~username/path (the site used to be a "home" site for a group of users).

I have traced down the offending code:

absolute_path = File.expand_path(relative_path, base)

The problem is File.expand_path treats leading tildes like shells and attempts to expand home directories, which results in an exception if the username doesn't exist on the local system.

As we were not interested in keeping those links (they've been broken for years already), I ended up monkey patching the code and overridden the method, inserting this line at the beginning of the method.

return relative_path if relative_path.start_with? '/~'

But I do think there should be a better, more general solution, or code fix.

Relative links not working in footnotes

Describe the bug

Hi,

I'm using Github Pages service to generate a static website from a collection of markdown files.
Relative links in footnotes are not working as expected. They are rendered as links to markdown files, instead of links to html files.

test1.md

TEST[^1].

[test2](test2.md).

[^1]: [test2](test2.md).

test2.md

TEST

_config.yml:

...
kramdown:
  gfm_quirks: [paragraph_end, no_auto_typographic]
...

Expected behavior

Link in footnote should be rendered as <a href="/test2.html">test2</a>.

Actual behavior

But it is rendered as <a href="test2.md">test2</a>.

Handle Line-Wrapped Links

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 :)

Image inside Link doesn't match properly

Describe the bug

[Title ![badge](https://example.com/badge.png)](./article.md)

link = link_parts(Regexp.last_match)

link_type, link_text, relative_path, fragment = link_parts(Regexp.last_match)
# link_type: "inline"
# link_text: "Title ![badge"
# relative_path: "https://example.com/badge.png"

Steps to reproduce the behavior

Expected behavior

link_type, link_text, relative_path, fragment = link_parts(Regexp.last_match)
# link_type: "inline"
# link_text: "Title ![badge](https://example.com/badge.png)"
# relative_path: "./article.md"

and

link_type, link_text, relative_path, fragment = link_parts(Regexp.last_match)
# link_type: "inline"
# link_text: "badge"
# relative_path: "https://example.com/badge.png"

Screenshots

Additional context

Multiple links in same line are not rewritten

I have a markdown document with the following line:

The current parent of a widget is returned by the [`parent`](api/Widget.md#parent) method, and the children by the [`children`](api/Widget.md#children) method.

The first link is correctly rewritten to api/Widget.html#parent, but the second link is not.

When I add a linebreak between the two links, the second one is also rewritten. Looks like some regex is missing the global flag?

jekyll-relative-links and Liquid's include_relative interact poorly

Describe the bug

If I have one page, a.md that has some relative links in it:

[X](./some/path/to/x.md)

And I use include_relative to include the content of b.md in another page:

{% include_relative a.md %}

In the generated a.html, the links will correctly point to x.html. But on b.html, the links will point to b.md.

Configuration options for specific directories

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

First of all, thank you for building this plugin! It's been a huge help.

I only need to run this plugin on a specific directory in my project. Running it on all directories increases the build time by ~100%. I only need to run this on select directories.

Describe the solution you'd like

I'd like to be able to specify which directories to run this on in the _config.yml file.

I expect the plugin to ignore all other directories not explicitly specified in the config file so that my build time doesn't increase so profoundly.

Describe alternatives you've considered

Using absolute links in the directory in question.

Additional context

I have an abnormally large set of files to process due to an ineffective versioning strategy, so I have to build multiple versions at once instead of by branch. See magento/devdocs.

Any help or guidance on how I can customize this plugin to acheive this goal would be highly appreciated! Thanks!

Support absolute links

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

I think this gem does not work when I got absolute links that finish with a .md

Describe the solution you'd like

I would like this gem to work with both absolute and relative link. At the current stage, it does not work with a link like foo

Describe alternatives you've considered

I've tried to use permalink but those are very cumbersome to manage.

Plugin not working on Pages

Is there any reason why this would not be working? I've set up jekyll and added the necessary lines to my gemfile and config. My links still go to ".md" instead of ".html". Might I be missing something?

Support image

Auto convert image relative links will help local editor display.

FRAGMENT_REGEX is too greedy, breaks multiple links

I have the following in my Markdown source:

This is [a first link](doc.md#ref) and then [a second link](anotherdoc.md).

a second link ends up pointing to anotherdoc.md directly.

I believe the following diff would help, but not sure if it would break anything else:

-    FRAGMENT_REGEX = %r!(#.+)?!
+    FRAGMENT_REGEX = %r!(#[^)]+)?!

but it would break fragments that include a literal ) for reference syntax.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.