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

New feature: hyphenation support using Hyphenopoly.js #34

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

RLesur
Copy link
Collaborator

@RLesur RLesur commented Dec 12, 2018

Here's a proposal for #33 .
It uses the Hyphenopoly.js library.

Hyphenopoly.js integration was not straightforward for many reasons:

  • Hyphenopoly.js must run first. In our context, this means before MathJax. Since MathJax is configured in the Pandoc template, we also have to configure Hyphenopoly.js in this template. Moreover, elements with a math class must not be hyphenated (otherwise, MathJax does not work properly). See /inst/resources/html/paged.html.
  • In the PR, I've deactivated hyphenation for titles (because I don't like hyphenated titles). Following the documentation, we have to declare a huge Hyphenopoly.setup.dontHyphenate object.
  • Hyphenopoly.js uses asm.js and WebAssembly. I did not find any implementation that would be compatible with self_contained = TRUE (but I am not familiar with these technologies). However, it seems that it is not yet possible. In this PR, the user cannot use self_contained = TRUE with hyphenation. Be careful, I've inverted the default value for self_contained (it could be confusing for users, tell me what do you prefer).
  • Hyphenopoly.js needs to know where its resource files are located. By default, Hyphenopoly.js search in these paths. Obviously, it does not work with rmarkdown. So, I had to write a script to dynamically find these paths. See inst/resources/js/Hyphenopoly/configHyphenopoly.js.
  • Language support. We have to declare which languages are used in the html file and provide a long word for each of these languages. I am not satisfied by what I've done with the Hyphenopoly.require object: I've forced the use of 6 languages. I think it would be better if the user could declare the languages with something like html_paged(lang = c('en-us', 'pt'), ...). But I did not find the way to implement such a solution. You can find the languages supported by Hyphenopoly.js in inst/resources/js/Hyphenopoly/patterns/.

@RLesur RLesur requested a review from yihui December 12, 2018 01:25
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

Successfully merging this pull request may close these issues.

None yet

1 participant