Skip to content

Commit

Permalink
escape <> in Typst
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentarelbundock committed Feb 11, 2024
1 parent 2a9f3c5 commit 9730aaf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: tinytable
Type: Package
Title: Simple and Configurable Tables in 'HTML', 'LaTeX', 'Markdown', 'Word', 'PNG', 'PDF', and 'Typst' Formats
Description: Create highly customized tables with this simple and dependency-free package. Data frames can be converted to 'HTML', 'LaTeX', 'Markdown', 'Word', 'PNG', 'PDF', or 'Typst' tables. The user interface is minimalist and easy to learn. The syntax concise. 'HTML' tables can be customized using the flexible 'Bootstrap' framework, and 'LaTeX' code with the 'tabularray' package.
Version: 0.0.4
Version: 0.0.4.9000
Depends:
R (>= 4.1.0)
Enhances:
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# News

## Development

* `format_tt()` escapes <> tags in Typst.

## 0.0.4

New:
Expand Down
5 changes: 5 additions & 0 deletions R/escape.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@ escape_text <- function(x, output = "latex") {
latex_special_chars[x]
})
regmatches(out[!na_out], m) <- escaped_chars

} else if (isTRUE(output == "html")) {
out <- htmlEscape(out)

} else if (isTRUE(output == "typst")) {
out <- gsub("<", "\\<", out, fixed = TRUE)
out <- gsub(">", "\\>", out, fixed = TRUE)
}

return(out)
Expand Down
2 changes: 2 additions & 0 deletions R/format_tt.R
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ format_tt_lazy <- function(x,
o <- "latex"
} else if (isTRUE(escape == "html")) {
o <- "html"
} else if (isTRUE(escape == "typst")) {
o <- "typst"
} else {
o <- meta(out)$output
}
Expand Down

0 comments on commit 9730aaf

Please sign in to comment.