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

URLs in a['href'] should be escaped for LaTeX #67

Closed
wants to merge 1 commit into from

Conversation

@hperl
Copy link
Contributor

@hperl hperl commented Jul 16, 2013

An URL such as in a a['href'] can contain URL escape codes, which all start with a %. The LaTeX-converter should escape all % to \% using escape(), or otherwise the unescaped % will be treated like a comment in LaTeX, corrupting the file.

This pull request fixes this by calling escape() on the URL.

@ghost ghost assigned gettalong Jul 29, 2013
@gettalong
Copy link
Owner

@gettalong gettalong commented Aug 21, 2013

Thanks!

@gettalong gettalong closed this Aug 21, 2013
@mkamensky
Copy link

@mkamensky mkamensky commented Sep 28, 2016

I think this is actually wrong, escaping breaks for instance urls with a tilde in them. The hyperref manual says that " The special characters # and ̃ do not need to be escaped in any way.". Unfortunately, it does not say anything about other characters...

@gettalong
Copy link
Owner

@gettalong gettalong commented Sep 28, 2016

@mkamensky Thanks for your comment - do you have any test cases for this?

@mkamensky
Copy link

@mkamensky mkamensky commented Oct 2, 2016

Yes, this comes from my real life example:

echo '<https://www.math.bgu.ac.il/~amyekut/teaching/2016-17/der-cats-III/course_page.html>' | ruby -rkramdown -e 'puts Kramdown::Document.new(ARGF.read).to_latex'

It produces

\href{https://www.math.bgu.ac.il/\ensuremath{\sim}amyekut/teaching/2016-17/der-cats-III/course\_page.html}{https://www.math.bgu.ac.il/\ensuremath{\sim}amyekut/teaching/2016-17/der-cats-III/course\_page.html}

which does not compile. Thanks!

@gettalong
Copy link
Owner

@gettalong gettalong commented Sep 8, 2017

@mkamensky Sorry for the long delay...

I have tested this now with #, % and ~: Seems to work fine without escaping. As you mentioned, the hyperref package doesn't say much about escaping but I found this answer on StackExchange.

Therefore I have changed the code to just escape the percent sign and nothing else. Seems to do what it should so far.

Will be in the next release!

gettalong added a commit that referenced this pull request Sep 8, 2017
Pull request #67 changed the code to use the escape() method. However,
this does more than it should, breaking the URLs.

By just escaping the percent sign this code should work in all
cases and environments now (fingers crossed).
@mkamensky
Copy link

@mkamensky mkamensky commented Sep 18, 2017

@gettalong Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants