Search code examples
htmlrquartoglossary

How to prevent raw html code from being printed in my output file


I'm trying to create a website using quarto and R (Rstudio).

I'm trying to create a glossary using the glossary package. I am able to create the table, but each table also output the raw html information (s. image) html

I have treid to add some filtering to my yml header of the quarto file:

...
format: 
  html:
    toc: true
    toc-depth: 4
    toc-expand: true
    number-sections: true
    number-depth: 4
    code-fold: true
    strip-comments: true
    from: 'markdown-markdown_in_html_blocks'
filters:
  - parse-latex
  - code-visibility
execute: 
  echo: false
...

But I can't make it disappear. Any ideas if this is possible at all?

thanks

Assa

Edit: As requested, I'm adding here a qmd file to reproduce the error:

the header:

---
title: "Glossary"
format: 
  html:
    toc: true
    toc-depth: 4
    toc-expand: true
    number-sections: true
    number-depth: 4
    code-fold: true
    strip-comments: true
    from: 'markdown-markdown_in_html_blocks'
filters:
  - parse-latex
  - code-visibility
execute: 
  echo: false
---

the R script to reproduce the problem:

library(glossary)

glossary_reset()
# add a definition to the table
glossary("term", def = "definition")
glossary("term 2", def = "definition 2")

glossary_table() # show table as kable

Solution

  • Add echo=FALSE, results='asis' to your chunk header. You also need to capture the returned value from each call to glossary. Options:

    • capture into a variable (and no need to use it), such as ign <- glossary(..)
    • wrap in invisible(glossary(..))

    Here's a complete working example:

    ---
    title: "Glossary"
    format: 
      html:
        toc: true
        toc-depth: 4
        toc-expand: true
        number-sections: true
        number-depth: 4
        code-fold: true
        strip-comments: true
        from: 'markdown-markdown_in_html_blocks'
    filters:
      - parse-latex
      - code-visibility
    execute: 
      echo: false
    ---
    
    ```{r, results='asis', echo=FALSE}
    library(glossary)
    
    glossary_reset()
    # add a definition to the table
    ign <- glossary("term", def = "definition")
    ign <- glossary("term 2", def = "definition 2")
    
    glossary_table() # show table as kable
    ```
    

    Renders as:

    html rendered from rmarkdown