Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some markdown cannot be parsed in md_to_officer() #13

Open
DanChaltiel opened this issue Nov 12, 2023 · 0 comments
Open

Some markdown cannot be parsed in md_to_officer() #13

DanChaltiel opened this issue Nov 12, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@DanChaltiel
Copy link

Hi John,

It seems that you and I have the same problem in parsing markdown into officer.

For instance, the following example, with intricated tokens, will give an unexpected, truncated result:

library(officer)
x = "**Be bold and *italic* **: "
res = onbrand::md_to_officer(x)
fpar_obj = eval(parse(text=res$pgraph_1$fpar_cmd))
read_docx() %>%
  body_add_fpar(fpar_obj) %>%
  crosstable::write_and_open()

It happens that I finally managed to correct this bug in crosstable using a very different approach.
This will now work (in the dev version)): body_add_fpar(crosstable:::parse_md(fpar_obj)).

Since I'm going to inspire a lot from onbrand (subscript and superscript are quite nice to have), I thought that might help you a bit, so feel free to adapt the following code to your needs.
https://github.com/DanChaltiel/crosstable/blob/main/R/officer.R#L884

@john-harrold john-harrold added the bug Something isn't working label Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants