From 04d6aed38b2f1591a8e708bb8aa9c5e42d1ec122 Mon Sep 17 00:00:00 2001 From: George Moroz Date: Sun, 10 Nov 2024 03:03:58 +0300 Subject: [PATCH] small fix --- DESCRIPTION | 2 +- NAMESPACE | 3 +++ NEWS.md | 6 ++++-- R/gloss_example.R | 15 ++++++++++++--- codemeta.json | 29 +++++++++++++++++++++++------ docs/index.Rmd | 2 +- 6 files changed, 44 insertions(+), 13 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 6763a75..3975c53 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: lingglosses Type: Package Title: Interlinear Glossed Linguistic Examples and Abbreviation Lists Generation -Version: 0.0.8 +Version: 0.0.9 Depends: R (>= 3.5.0) Authors@R: person("George", "Moroz", role = c("aut", "cre"), diff --git a/NAMESPACE b/NAMESPACE index 33bcc43..364ecd5 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -5,8 +5,10 @@ export(convert_to_df) export(get_examples_db) export(gloss_example) export(make_gloss_list) +importFrom(gt,as_word) importFrom(gt,fmt_markdown) importFrom(gt,gt) +importFrom(gt,md) importFrom(gt,opt_table_lines) importFrom(gt,tab_footnote) importFrom(gt,tab_options) @@ -18,6 +20,7 @@ importFrom(knitr,is_html_output) importFrom(knitr,is_latex_output) importFrom(knitr,knit_hooks) importFrom(knitr,opts_current) +importFrom(knitr,opts_knit) importFrom(methods,hasArg) importFrom(methods,missingArg) importFrom(rmarkdown,metadata) diff --git a/NEWS.md b/NEWS.md index aaddbb2..f8157ed 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# lingglosses 0.0.9 + +- move from `kableExtra` to `gt` package + # lingglosses 0.0.8 - add 2PL gloss @@ -6,12 +10,10 @@ - fix by @yihui - # lingglosses 0.0.6 - small fix for CRAN - # lingglosses 0.0.5 - add possibility to have a sole transliteration line; thx to @sverhees #19 diff --git a/R/gloss_example.R b/R/gloss_example.R index cbe8f05..db22a81 100644 --- a/R/gloss_example.R +++ b/R/gloss_example.R @@ -36,10 +36,13 @@ #' #' @importFrom knitr is_latex_output #' @importFrom knitr is_html_output +#' @importFrom knitr opts_knit #' @importFrom gt gt #' @importFrom gt tab_footnote #' @importFrom gt tab_options #' @importFrom gt fmt_markdown +#' @importFrom gt md +#' @importFrom gt as_word #' @importFrom gt opt_table_lines #' @importFrom methods missingArg #' @importFrom methods hasArg @@ -278,7 +281,7 @@ gloss_example <- function(transliteration, if(nchar(free_translation) > 0){ result <- gt::tab_footnote(data = result, footnote = paste0("'", - free_translation, + gt::md(free_translation), "'")) } @@ -286,7 +289,7 @@ gloss_example <- function(transliteration, # add comment -------------------------------------------------------------- if(nchar(comment) > 0){ result <- gt::tab_footnote(data = result, - footnote = comment) + footnote = gt::md(comment)) } # add audio --------------------------------------------------------------- @@ -317,7 +320,13 @@ gloss_example <- function(transliteration, # return output ------------------------------------------------------------ if(length(unique(splits_by_line)) > 1){ - for(i in multiline_result) {print(i)} + if (isTRUE(knitr::opts_knit$get('rmarkdown.pandoc.to') == "docx")) { + for(i in multiline_result) { + cat("```{=openxml}", gt::as_word(i), "```\n\n", sep = "\n") + } + } else { + for(i in multiline_result) {print(i)} + } } else{ return(result) } diff --git a/codemeta.json b/codemeta.json index 5f7664f..b82e687 100644 --- a/codemeta.json +++ b/codemeta.json @@ -8,13 +8,13 @@ "codeRepository": "https://CRAN.R-project.org/package=phonfieldwork", "issueTracker": "https://github.com/agricolamz/lingglosses/issues", "license": "https://spdx.org/licenses/GPL-3.0", - "version": "0.0.4", + "version": "0.0.9", "programmingLanguage": { "@type": "ComputerLanguage", "name": "R", "url": "https://r-project.org" }, - "runtimePlatform": "R version 4.2.0 (2022-04-22)", + "runtimePlatform": "R version 4.3.3 (2024-02-29)", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -63,15 +63,15 @@ }, "2": { "@type": "SoftwareApplication", - "identifier": "kableExtra", - "name": "kableExtra", + "identifier": "gt", + "name": "gt", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", "name": "Comprehensive R Archive Network (CRAN)", "url": "https://cran.r-project.org" }, - "sameAs": "https://CRAN.R-project.org/package=kableExtra" + "sameAs": "https://CRAN.R-project.org/package=gt" }, "3": { "@type": "SoftwareApplication", @@ -102,9 +102,26 @@ "identifier": "utils", "name": "utils" }, + "6": { + "@type": "SoftwareApplication", + "identifier": "htmltools", + "name": "htmltools", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=htmltools" + }, + "7": { + "@type": "SoftwareApplication", + "identifier": "methods", + "name": "methods" + }, "SystemRequirements": null }, - "fileSize": "53.058KB", + "fileSize": "59.745KB", "citation": [ { "@type": "SoftwareSourceCode", diff --git a/docs/index.Rmd b/docs/index.Rmd index 0946b39..978cd93 100644 --- a/docs/index.Rmd +++ b/docs/index.Rmd @@ -205,7 +205,7 @@ gloss_example("Learn to value yourself, which means: to fight for your happiness 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. (@tsa_ex) Mishlesh Tsakhur, East Caucasian [@maisak07: 386] -```{r} +```{r, results='asis'} gloss_example('za-s jaːluʁ **wo-b** **qa-b-ɨ**; turs-ubɨ qal-es-di ǯiqj-eː jaːluʁ-**o-b** **qa-b-ɨ**', '1SG.OBL-DAT shawl.3 AUX-3 PRF-3-bring.PFV woolen_sock-PL NPL.bring-PL-A.OBL place-IN shawl.3-AUX-3 PRF-3-bring.PFV', '(they) **brought** me a shawl; instead of (lit. in place of bringing) woolen socks, (they) **brought** a shawl.',