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

Generate different text for inline glossary reference depending on output format #16

Closed
gvwilson opened this issue Sep 5, 2020 · 3 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@gvwilson
Copy link

gvwilson commented Sep 5, 2020

When an R Markdown document is being compiled into HTML, we want something like the following for a glossary entry:

<a href="https://glosario.carpentries.org/en/#some_key">some term</a>

But when the same document is being compiled into LaTeX/PDF, we want:

\glossref{some term}{some\_key}

(Or something like that---the user may want some other LaTeX command for glossary references.) We cannot generate the former and hope that Pandoc will translate it into the latter. We also cannot generate LaTeX and hope that Pandoc will translate it into HTML, since Pandoc doesn't handle user-defined commands.

I have used a Lua filter to solve this problem in a book project merely-useful/py-rse#467, but we should think about how to configure the function for inserting definitions into text to handle this.

@gvwilson gvwilson added the help wanted Extra attention is needed label Sep 5, 2020
@fmichonneau
Copy link
Contributor

I have done things like this in the past by creating a function that looks like:

switch_include <- function(...) {
	if (knitr::is_latex_output()) {
	## returns something latex specific
    }
    ## returns something for HTML
}

@ian-flores
Copy link
Member

ian-flores commented Sep 7, 2020

In here we can see that what I implemented adds a Markdown link which then gets rendered as a PDF link or as an HTML anchor tag. It is surrounded by a <span> tag to add CSS to the defs but it's not obtrusive with the PDF version. Did that cause problems @gvwilson ?

@gvwilson
Copy link
Author

gvwilson commented Sep 7, 2020

  1. Clone https://github.com/yihui/bookdown-crc/
  2. Add a glossary reference.
  3. Build PDF.
    How do you see the glossary reference formatted?

@ian-flores ian-flores added the bug Something isn't working label Apr 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
Development

No branches or pull requests

3 participants