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

Knitting to word with hyperlink in footnote #128

Open
ppanko opened this issue Oct 30, 2023 · 1 comment
Open

Knitting to word with hyperlink in footnote #128

ppanko opened this issue Oct 30, 2023 · 1 comment

Comments

@ppanko
Copy link

ppanko commented Oct 30, 2023

Attempting to add a hyperlink in a footnote via Rmd and knit to rdocx_document results in an "unreadable" file per Microsoft Word. See Rmd reprex below:

---
output: 
  officedown::rdocx_document
---

`` ```{r}
library(officer)
url <- "https://github.com"
ft  <- fp_text(font.size = 10)
hl  <- hyperlink_ftext(href = url, text = url, prop = ft)
`` ```

The github website^[`r hl`]

sessionInfo()

R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default


locale:
[1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8    LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C                           LC_TIME=English_United States.utf8    

time zone: America/New_York
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] officedown_0.3.1 officer_0.6.3   

loaded via a namespace (and not attached):
 [1] jsonlite_1.8.7          compiler_4.3.1          crayon_1.5.2            promises_1.2.0.1        Rcpp_1.0.11             zip_2.3.0              
 [7] xml2_1.3.5              later_1.3.1             fontquiver_0.2.1        systemfonts_1.0.4       textshaping_0.3.6       uuid_1.1-0             
[13] yaml_2.3.7              fastmap_1.1.1           mime_0.12               R6_2.5.1                gfonts_0.2.0            gdtools_0.3.3          
[19] curl_5.0.1              knitr_1.43              openssl_2.1.0           crul_1.4.0              shiny_1.7.4.1           rlang_1.1.1            
[25] rvg_0.3.3               cachem_1.0.8            httpcode_0.3.0          httpuv_1.6.11           xfun_0.39               memoise_2.0.1          
[31] cli_3.6.1               magrittr_2.0.3          digest_0.6.33           xtable_1.8-4            rstudioapi_0.15.0       askpass_1.2.0          
[37] lifecycle_1.0.3         evaluate_0.21           glue_1.6.2              fontLiberation_0.1.0    ragg_1.2.5              fontBitstreamVera_0.1.1
[43] rmarkdown_2.25          ellipsis_0.3.2          tools_4.3.1             htmltools_0.5.5        
@WilDoane
Copy link

WilDoane commented Oct 31, 2023

Here are two footnotes, the first inserted using the code from OP and the second inserted using

some text^[http://DrDoane.com]

In the resulting .md

[^1]: `<w:hyperlink r:id="https://github.com"><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:eastAsia="Arial" w:cs="Arial"/><w:i w:val="false"/><w:b w:val="false"/><w:u w:val="none"/><w:sz w:val="20"/><w:szCs w:val="20"/><w:color w:val="000000"/></w:rPr><w:t xml:space="preserve">https://github.com</w:t></w:r></w:hyperlink>`{=openxml}
[^2]: http://DrDoane.com

Tweaking the r:id to remove potentially special characters results in no difference (MS Word still errors on open).

The entire openxml format in the footnote seems to be an issue.

in the generated docx foot

 <w:footnote w:id="20">
    <w:p>
      <w:pPr>
        <w:pStyle w:val="Notedebasdepage"/>
      </w:pPr>
      <w:r>
        <w:rPr>
          <w:rStyle w:val="Appelnotedebasdep"/>
        </w:rPr>
        <w:footnoteRef/>
      </w:r>
      <w:r>
        <w:t xml:space="preserve"> </w:t>
      </w:r>
      <w:hyperlink r:id="https://github.com">
        <w:r>
          <w:rPr>
            <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:eastAsia="Arial" w:cs="Arial"/>
            <w:i w:val="false"/>
            <w:b w:val="false"/>
            <w:u w:val="none"/>
            <w:sz w:val="20"/>
            <w:szCs w:val="20"/>
            <w:color w:val="000000"/>
          </w:rPr>
          <w:t xml:space="preserve">https://github.com</w:t>
        </w:r>
      </w:hyperlink>
    </w:p>
  </w:footnote>
  <w:footnote w:id="21">
    <w:p>
      <w:pPr>
        <w:pStyle w:val="Notedebasdepage"/>
      </w:pPr>
      <w:r>
        <w:rPr>
          <w:rStyle w:val="Appelnotedebasdep"/>
        </w:rPr>
        <w:footnoteRef/>
      </w:r>
      <w:r>
        <w:t xml:space="preserve"> </w:t>
      </w:r>
      <w:hyperlink r:id="rId22">
        <w:r>
          <w:rPr>
            <w:rStyle w:val="Lienhypertexte"/>
          </w:rPr>
          <w:t xml:space="preserve">https://DrDoane.com</w:t>
        </w:r>
      </w:hyperlink>
    </w:p>
  </w:footnote>

@davidgohel davidgohel transferred this issue from davidgohel/officer Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants