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

Include Statement Breaks when Given Path with Certain Special Characters #1098

Open
june128 opened this issue Nov 14, 2019 · 4 comments
Open
Labels
A-link-preprocessor Area: Link preprocessor, #{{include}}, etc.

Comments

@june128
Copy link

june128 commented Nov 14, 2019

The #include statement breaks when it is given a path with certain special characters.

Here an example. The following source:

Screenshot_2019-11-14_19-40-20_+0100_Include_Statement_Breaks_when_Given_Path_with_Certain_Special_Characters_example_source_code

Results in:

Screenshot_2019-11-14_19-41-04_+0100_Include_Statement_Breaks_when_Given_Path_with_Certain_Special_Characters_example_source_code_output

@uint
Copy link
Contributor

uint commented Nov 27, 2019

I think I see what's going on with the colons. The logic for parsing includes takes the first colon and interprets it as a separator between the actual path and a range/anchor thingy.

I'll dig into what's up with pluses eventually.

It feels like without changing range/anchor syntax and breaking backwards compatibility, a way to fix this is to introduce an escape character for colons that are part of the path.

Or maybe the path can be optionally wrapped in double quotes? I like that more.

@uint
Copy link
Contributor

uint commented Jan 4, 2020

I finally (sorry) took a look. It looks like the plus is a different beast - the find_links() function uses regexp to find things and simply doesn't expect strings with pluses in them. Here it is.

Fixing this one is trivial. It seems to work fine after adding \+ to the regexp.

I'd be happy to make a pull request once we know how we want to handle colons!

@ehuss
Copy link
Contributor

ehuss commented Apr 21, 2020

I would kinda prefer not to support colons in the path (and not deal with absolute Windows paths, or deal with an escaping system), but fixing other characters like + sounds good.

@ehuss ehuss added the A-link-preprocessor Area: Link preprocessor, #{{include}}, etc. label Apr 21, 2020
ehuss added a commit that referenced this issue May 7, 2020
@june128
Copy link
Author

june128 commented Aug 28, 2020

Thanks for the work on this issue! I can confirm that the fix for the plus works.
If not supporting colons in paths is a product decision, this issue can be closed.

Ruin0x11 pushed a commit to Ruin0x11/mdBook that referenced this issue Aug 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-link-preprocessor Area: Link preprocessor, #{{include}}, etc.
Projects
None yet
Development

No branches or pull requests

3 participants