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

Prevent HTML escaping when rendering a pdf #71

Open
kalsan opened this issue Jun 12, 2023 · 1 comment
Open

Prevent HTML escaping when rendering a pdf #71

kalsan opened this issue Jun 12, 2023 · 1 comment

Comments

@kalsan
Copy link

kalsan commented Jun 12, 2023

When rendering a .pdf.erb file to latex and the file contains non-html-safe parts, they get escaped in a way that would be suitable for HTML. However, we are generating LaTeX and not HTML, which means html_safe makes no sense in the first place (already the name says that).

This is a problem in the following example:

<%= people.map{|person| "'#{person.label}'"}.join(', ') %> 

Since the string produced by join is not html_safe, the generated String is &quot;Anna&quot;, &quot;Berta&quot;, which then causes LaTeX to crash because the & sign is not permitted.

The alterantive would be to use safe_join and raw instead:

<%= safe_join people.map{|person| raw "'#{person.label}'"}, ', ' %> 

...or to tag the string as html_safe. However, it would be much more convenient, and also appropriate for the reasons described above, to skip HTML safety entirely when rendering LaTeX to PDF. Can this be achieved?

@kalsan
Copy link
Author

kalsan commented Jun 12, 2023

Note: the problem with " and ' might actually be related to ERB escaping and not with html_safe: https://api.rubyonrails.org/classes/ERB/Util.html

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

No branches or pull requests

1 participant