Skip to content

Commit cfd806a

Browse files
committed
small update
1 parent 11efebc commit cfd806a

File tree

6 files changed

+33
-11
lines changed

6 files changed

+33
-11
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: lingglosses
22
Type: Package
33
Title: Interlinear Glossed Linguistic Examples and Abbreviation Lists Generation
4-
Version: 0.0.11
4+
Version: 0.0.12
55
Depends: R (>= 4.2.0)
66
Authors@R: person("George", "Moroz",
77
role = c("aut", "cre"),

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ importFrom(knitr,is_html_output)
2323
importFrom(knitr,is_latex_output)
2424
importFrom(knitr,knit_hooks)
2525
importFrom(knitr,opts_current)
26+
importFrom(knitr,opts_knit)
2627
importFrom(methods,hasArg)
2728
importFrom(methods,missingArg)
2829
importFrom(rmarkdown,metadata)

R/gloss_example.R

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ gloss_example <- function(transliteration,
145145
glosses_by_word
146146
}
147147

148-
149148
# add example to the example list ------------------------------------------
150149
if(write_to_db){
151150
glossed_df <- lingglosses::convert_to_df(
@@ -159,10 +158,14 @@ gloss_example <- function(transliteration,
159158

160159
# add glosses to the document gloss list -----------------------------------
161160
glosses_by_word |>
162-
strsplit("(?=[-\\.=:\\)\\(!\\?<>\\~\\+\uFF3D\uFF3B])", perl = TRUE) |>
161+
gsub(pattern = "\uFF3B", replacement = "\\[") |>
162+
gsub(pattern = "\uFF3D", replacement = "\\]", glosses) |>
163+
strsplit("(?=[-\\.=:\\)\\(!\\?<>\\~\\+\\]\\[])", perl = TRUE) |>
163164
lapply(FUN = function(i){
164165
gsub(pattern = "<", replacement = "&lt;", x = i) |>
165-
gsub(pattern = ">", replacement = "&gt;", x = _)
166+
gsub(pattern = ">", replacement = "&gt;", x = _) |>
167+
gsub(pattern = "\\[", replacement = "\uFF3B", x = _) |>
168+
gsub(pattern = "\\]", replacement = "\uFF3D", x = _)
166169
}) ->
167170
single_gl
168171

R/zzz.r

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,14 @@ get_variable_name <- function(){
4545
#' @examples
4646
#' small_caps("NOM")
4747
#' @importFrom knitr is_latex_output
48+
#' @importFrom knitr opts_knit
4849

4950
small_caps <- function(gloss){
5051
if(knitr::is_latex_output()){
5152
paste(paste0('\\textsc{', tolower(gloss), '}'))
52-
} else {
53+
} else if(isTRUE(knitr::opts_knit$get('rmarkdown.pandoc.to') == "docx")) {
54+
gloss
55+
} else{
5356
paste(paste0('<span style="font-variant:small-caps;">',
5457
tolower(gloss),
5558
'</span>'))

docs/index.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ gloss_example("Learn to value yourself, which means: to fight for your happiness
202202

203203
## Multiline examples
204204

205-
Sometimes examples are too long and do not fit onto the page. In that case you need to add the argument `results='asis'` to your chunk. `gloss_example()` will then automatically split your example into multiple rows.
205+
Sometimes examples are too long and do not fit onto the page. In that case you need to add the argument `results='asis'` to your chunk in Rmarkdown document or `#| results: 'asis'` if you worl with Quarto document. `gloss_example()` will then automatically split your example into multiple rows.
206206

207207
(@tsa_ex) Mishlesh Tsakhur, East Caucasian [@maisak07: 386]
208208
```{r, results='asis'}

docs/index.html

Lines changed: 20 additions & 5 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)