Skip to content
This repository has been archived by the owner on Jul 17, 2023. It is now read-only.

Fix for inline maths/ list elements not getting translated #157

Open
tom-from-goss opened this issue Oct 18, 2022 · 0 comments
Open

Fix for inline maths/ list elements not getting translated #157

tom-from-goss opened this issue Oct 18, 2022 · 0 comments

Comments

@tom-from-goss
Copy link

The following changes to translate.R fix some issues I've been having with inline latex in confluence:

# Include this after line 64:
  # Mark $ and $$ in plain <li> so that we can replace them safely later.
list_item_nodes <- xml2::xml_find_all(html_doc, "//li/text()")
for (node in list_item_nodes) {
    text <- xml2::xml_text(node)
    text <- mark_math(text)
    text <- mark_inline_math(text)
    xml2::xml_text(node) <- text
}

Change the regex in mark_inline_math to:

x <- stringi::stri_replace_all_regex(x, "(?<=[^\\s\\\\])\\$($|(?=[\\s:.,]))", "%1%D%O%L%L%A%R%", multiline = TRUE)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant