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

export some pandoc syntax helper #2331

Closed
cderv opened this issue Mar 20, 2024 · 3 comments
Closed

export some pandoc syntax helper #2331

cderv opened this issue Mar 20, 2024 · 3 comments

Comments

@cderv
Copy link
Collaborator

cderv commented Mar 20, 2024

I saw we have some helpers

knitr/R/hooks-md.R

Lines 228 to 238 in 031e08c

pandoc_div = function(x, .attr = NULL, .class = NULL) {
if (is.null(.attr) && is.null(.class)) return(x)
fenced_block(c(x, ''), .attr, .class, .char = ':', .sep = ' ', .outer = '')
}
# add a fence around content (either fenced code block ``` or Div :::)
fenced_block = function(x, ..., .char = '`', .sep = '', .outer = '\n\n') {
x = one_string(c('', x))
f = create_fence(x, .char)
paste0(.outer, paste(f, block_attr(...), sep = .sep), x, f, .outer)
}

What about exporting pandoc_div in addition to knitr::raw_block (which could probably be rewritten using fenced_block() 🤔

I often try to create some Divs or RawBlock as raw Markdow output, and having hepler function for that (support classes and attributes) can be useful.

I can also put them in quarto R package directly;

@cderv cderv moved this to To discuss / To plan in R Markdown Team Projects Mar 20, 2024
@yihui
Copy link
Owner

yihui commented Mar 20, 2024

I think that's a good idea. I'd probably move them to xfun, so they can be shared across more packages.

@github-project-automation github-project-automation bot moved this from To discuss / To plan to Done in R Markdown Team Projects Mar 25, 2024
@yihui
Copy link
Owner

yihui commented Mar 25, 2024

FYI I just added a function fenced_block() to xfun. Note that classes are just a special case of attributes, i.e., class = 'foo' is equivalent to attr = '.foo', so I didn't provide a specific class argument to xfun::fenced_block().

clrpackages pushed a commit to clearlinux-pkgs/R-xfun that referenced this issue Mar 27, 2024
Yihui Xie (9):
      close #83: move knitr::imgur_upload() to xfun::upload_imgur()
      forgot to suggest xml2 in the previous commit
      use R Markdown v1 for vignette
      shouldn't paste() here because `code` could be a vector of length > 1, and each line may be an incomplete expression
      update packages only in libraries that are writable by the current user
      close yihui/knitr#2331: provide a fenced_block() function to be reused in knitr and possibly pandoc/litedown
      add {} if any attribute contains =
      add a test for 5a63018c7cd9e31e84168536825bdf9d02d54215
      CRAN release v0.43
Copy link

github-actions bot commented Oct 2, 2024

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 2, 2024
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

2 participants