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

issue with as_paragraph_md(from = "commonmark+strikeout") #97

Closed
davidgohel opened this issue Feb 23, 2024 · 7 comments
Closed

issue with as_paragraph_md(from = "commonmark+strikeout") #97

davidgohel opened this issue Feb 23, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@davidgohel
Copy link
Contributor

Hello @atusy and @hughjonesd

I was trying to fix errors with huxtable or ftExtra I introduced in flextable because of a recent refactoring, and I found this from 'huxtable' using 'ftExtra'. I did not find the reason and realized with CRAN version of 'flextable' and 'ftExtra' I could reproduce the error.

library(ftExtra)
#> Registered S3 method overwritten by 'ftExtra':
#>   method                  from     
#>   as_flextable.data.frame flextable
as_paragraph_md("Thematic break\n\n----\n")
#> [[1]]
#>         txt font.size italic bold underlined color shading.color font.family
#> 1  Thematic        NA     NA   NA         NA  <NA>          <NA>        <NA>
#> 2                  NA     NA   NA         NA  <NA>          <NA>        <NA>
#> 3 break\n\n        NA     NA   NA         NA  <NA>          <NA>        <NA>
#>   hansi.family eastasia.family cs.family vertical.align width height  url
#> 1         <NA>            <NA>      <NA>           <NA>    NA     NA <NA>
#> 2         <NA>            <NA>      <NA>           <NA>    NA     NA <NA>
#> 3         <NA>            <NA>      <NA>           <NA>    NA     NA <NA>
#>   eq_data word_field_data img_data seq_index
#> 1    <NA>            <NA>     NULL         1
#> 2    <NA>            <NA>     NULL         2
#> 3    <NA>            <NA>     NULL         3
#> 
#> attr(,"class")
#> [1] "paragraph"
as_paragraph_md("Thematic break\n\n----\n", .from = "commonmark+strikeout")
#> Error in `dplyr::bind_rows()`:
#> ! Argument 4 must be a data frame or a named atomic vector.

Created on 2024-02-23 with reprex v2.1.0

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.3.2 (2023-10-31)
#>  os       macOS Sonoma 14.2.1
#>  system   x86_64, darwin20
#>  ui       X11
#>  language (EN)
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       Europe/Paris
#>  date     2024-02-23
#>  pandoc   3.1.1 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package           * version date (UTC) lib source
#>  askpass             1.2.0   2023-09-03 [1] CRAN (R 4.3.0)
#>  cli                 3.6.2   2023-12-11 [1] CRAN (R 4.3.0)
#>  crayon              1.5.2   2022-09-29 [1] CRAN (R 4.3.0)
#>  crul                1.4.0   2023-05-17 [1] CRAN (R 4.3.0)
#>  curl                5.2.0   2023-12-08 [1] CRAN (R 4.3.0)
#>  data.table          1.15.0  2024-01-30 [1] CRAN (R 4.3.2)
#>  digest              0.6.34  2024-01-11 [1] CRAN (R 4.3.0)
#>  dplyr               1.1.4   2023-11-17 [1] CRAN (R 4.3.0)
#>  ellipsis            0.3.2   2021-04-29 [1] CRAN (R 4.3.0)
#>  evaluate            0.23    2023-11-01 [1] CRAN (R 4.3.0)
#>  fansi               1.0.6   2023-12-08 [1] CRAN (R 4.3.0)
#>  fastmap             1.1.1   2023-02-24 [1] CRAN (R 4.3.0)
#>  flextable           0.9.4   2023-10-22 [1] CRAN (R 4.3.0)
#>  fontBitstreamVera   0.1.1   2017-02-01 [1] CRAN (R 4.3.0)
#>  fontLiberation      0.1.0   2016-10-15 [1] CRAN (R 4.3.0)
#>  fontquiver          0.2.1   2017-02-01 [1] CRAN (R 4.3.0)
#>  fs                  1.6.3   2023-07-20 [1] CRAN (R 4.3.0)
#>  ftExtra           * 0.6.1   2023-09-29 [1] CRAN (R 4.3.0)
#>  gdtools             0.3.6   2024-02-22 [1] CRAN (R 4.3.2)
#>  generics            0.1.3   2022-07-05 [1] CRAN (R 4.3.0)
#>  gfonts              0.2.0   2023-01-08 [1] CRAN (R 4.3.0)
#>  glue                1.7.0   2024-01-09 [1] CRAN (R 4.3.0)
#>  htmltools           0.5.7   2023-11-03 [1] CRAN (R 4.3.0)
#>  httpcode            0.3.0   2020-04-10 [1] CRAN (R 4.3.0)
#>  httpuv              1.6.14  2024-01-26 [1] CRAN (R 4.3.2)
#>  jsonlite            1.8.8   2023-12-04 [1] CRAN (R 4.3.0)
#>  knitr               1.45    2023-10-30 [1] CRAN (R 4.3.0)
#>  later               1.3.2   2023-12-06 [1] CRAN (R 4.3.0)
#>  lifecycle           1.0.4   2023-11-07 [1] CRAN (R 4.3.0)
#>  magrittr            2.0.3   2022-03-30 [1] CRAN (R 4.3.0)
#>  mime                0.12    2021-09-28 [1] CRAN (R 4.3.0)
#>  officer             0.6.4   2024-02-05 [1] CRAN (R 4.3.2)
#>  openssl             2.1.1   2023-09-25 [1] CRAN (R 4.3.0)
#>  pillar              1.9.0   2023-03-22 [1] CRAN (R 4.3.0)
#>  pkgconfig           2.0.3   2019-09-22 [1] CRAN (R 4.3.0)
#>  promises            1.2.1   2023-08-10 [1] CRAN (R 4.3.0)
#>  purrr               1.0.2   2023-08-10 [1] CRAN (R 4.3.0)
#>  R.cache             0.16.0  2022-07-21 [1] CRAN (R 4.3.0)
#>  R.methodsS3         1.8.2   2022-06-13 [1] CRAN (R 4.3.0)
#>  R.oo                1.26.0  2024-01-24 [1] CRAN (R 4.3.2)
#>  R.utils             2.12.3  2023-11-18 [1] CRAN (R 4.3.0)
#>  R6                  2.5.1   2021-08-19 [1] CRAN (R 4.3.0)
#>  ragg                1.2.7   2023-12-11 [1] CRAN (R 4.3.0)
#>  Rcpp                1.0.12  2024-01-09 [1] CRAN (R 4.3.0)
#>  reprex              2.1.0   2024-01-11 [1] CRAN (R 4.3.0)
#>  rlang               1.1.3   2024-01-10 [1] CRAN (R 4.3.0)
#>  rmarkdown           2.25    2023-09-18 [1] CRAN (R 4.3.0)
#>  rstudioapi          0.15.0  2023-07-07 [1] CRAN (R 4.3.0)
#>  sessioninfo         1.2.2   2021-12-06 [1] CRAN (R 4.3.0)
#>  shiny               1.8.0   2023-11-17 [1] CRAN (R 4.3.0)
#>  stringi             1.8.3   2023-12-11 [1] CRAN (R 4.3.0)
#>  stringr             1.5.1   2023-11-14 [1] CRAN (R 4.3.0)
#>  styler              1.10.2  2023-08-29 [1] CRAN (R 4.3.0)
#>  systemfonts         1.0.5   2023-10-09 [1] CRAN (R 4.3.0)
#>  textshaping         0.3.7   2023-10-09 [1] CRAN (R 4.3.0)
#>  tibble              3.2.1   2023-03-20 [1] CRAN (R 4.3.0)
#>  tidyselect          1.2.0   2022-10-10 [1] CRAN (R 4.3.0)
#>  utf8                1.2.4   2023-10-22 [1] CRAN (R 4.3.0)
#>  uuid                1.2-0   2024-01-14 [1] CRAN (R 4.3.0)
#>  vctrs               0.6.5   2023-12-01 [1] CRAN (R 4.3.0)
#>  withr               3.0.0   2024-01-16 [1] CRAN (R 4.3.0)
#>  xfun                0.42    2024-02-08 [1] CRAN (R 4.3.2)
#>  xml2                1.3.6   2023-12-04 [1] CRAN (R 4.3.0)
#>  xtable              1.8-4   2019-04-21 [1] CRAN (R 4.3.0)
#>  yaml                2.3.8   2023-12-11 [1] CRAN (R 4.3.0)
#>  zip                 2.3.1   2024-01-27 [1] CRAN (R 4.3.2)
#> 
#>  [1] /Users/davidgohel/Library/R/x86_64/4.3/library
#>  [2] /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

I don't really understand why this fails on my computer but not in the check page of huxtable. Do you have an idea of what is happening?

@hughjonesd
Copy link

My guess would be that huxtable checks don't hit that particular case but I haven't looked...?

@atusy
Copy link
Owner

atusy commented Feb 23, 2024 via email

@atusy
Copy link
Owner

atusy commented Feb 24, 2024

I reproduced the error without .from = "commonmark+strikeout".

as_paragraph_md("---")

It seems like ---- is a HorizontalRule, which needs a special care...

Is there any way to add horizontal break in a cell of flextable?

If not, I would do warn if there is a horizontal rule, and then replace it with a plain ---.

@atusy
Copy link
Owner

atusy commented Feb 24, 2024

📝 HorizontalRule is a block-element without content. That is a unique characteristic compared to other block-elements (e.g., Para, Header, Div, ...)

$ echo '---\n\nfoo bar' | pandoc -t native
[ HorizontalRule , Para [ Str "foo" , Space , Str "bar" ] ]

@davidgohel
Copy link
Contributor Author

Is there any way to add horizontal break in a cell of flextable?

No sorry, in flextable, a cell can only contain a paragraph

@atusy
Copy link
Owner

atusy commented Feb 26, 2024

Alright, then I will add some warnings.

@atusy
Copy link
Owner

atusy commented Feb 26, 2024

closing via #98

I will make a release in a few days.

@atusy atusy closed this as completed Feb 26, 2024
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

3 participants