From ab501fbc1c7a2a472e1bb79611a3f7cd860b39d3 Mon Sep 17 00:00:00 2001 From: Duncan Murdoch Date: Sun, 13 Jan 2019 14:48:03 -0500 Subject: [PATCH 1/2] Add support for @aref --- R/ebook.R | 4 ++-- R/html.R | 16 ++++++++++++---- R/latex.R | 6 +++--- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/R/ebook.R b/R/ebook.R index d51a5bcbe..f4a49695e 100644 --- a/R/ebook.R +++ b/R/ebook.R @@ -126,8 +126,8 @@ resolve_refs_md = function(content, ref_table, to_md = output_md()) { # replace (\#eq:label) with equation numbers content = add_eq_numbers(content, ids, ref_table, to_md) - # look for \@ref(label) and resolve to actual figure/table/section numbers - m = gregexpr('(???' } - # equation references should include paratheses + ar <- magyar_article(num[aref]) + # equation references should include parentheses i = grepl('^eq:', ref) num[i] = paste0('(', num[i], ')') + num[aref] <- paste(ar, num[aref]) res = sprintf('%s', ref, num) # do not add relative links to equation numbers in ePub/Word (not implemented) ifelse(backslash & i, num, res) diff --git a/R/latex.R b/R/latex.R index 78e7c39bb..f73dcbe85 100644 --- a/R/latex.R +++ b/R/latex.R @@ -109,12 +109,12 @@ tufte_book2 = function(...) { resolve_refs_latex = function(x) { # equation references \eqref{} x = gsub( - '(? Date: Sat, 19 Jan 2019 16:04:09 -0500 Subject: [PATCH 2/2] Update for some bug fixes. --- R/html.R | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/R/html.R b/R/html.R index e1744071f..dadbb7e0f 100644 --- a/R/html.R +++ b/R/html.R @@ -453,7 +453,8 @@ source_link_setting = function(config, type) { #' #' Post-process the HTML content to resolve references of figures, tables, and #' sections, etc. The references are written in the form \code{\@ref(key)} in -#' the R Markdown source document. +#' or \code{\@aref(key)} the R Markdown source document, the latter intended +#' for use with Hungarian language text. #' @param content A character vector of the HTML content. #' @param global Whether to number the elements incrementally throughout the #' whole document, or number them by the first-level headers. For an R @@ -488,15 +489,16 @@ resolve_refs_html = function(content, global = FALSE) { content } -magyar_article = function(num) { - ifelse(grepl("^5", num) | - (grepl("^1", num) & (nchar(num) %% 3 == 1)), "ar", "a") -} - is_img_line = function(x) grepl('^%s', ref, num) + res[aref] <- paste(az, res[aref]) # do not add relative links to equation numbers in ePub/Word (not implemented) ifelse(backslash & i, num, res) }