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

Add a new section about new output_format_dependency() #395

Open
cderv opened this issue Sep 4, 2023 · 1 comment
Open

Add a new section about new output_format_dependency() #395

cderv opened this issue Sep 4, 2023 · 1 comment

Comments

@cderv
Copy link
Collaborator

cderv commented Sep 4, 2023

Idea from @atusy in rstudio/rmarkdown#2508 following the example shared in

---
title: referring sections
output:
  html_document:
    keep_md: true
---

```{cat, engine.opts=list(file = "example.lua")}
local headers = {}

local function collect_header(header)
  headers["#" .. el.identifier] = header
end

local function link_header(link)
  if #link.content == 0 and headers[link.target] then
    link.content = headers[link.target].content
  end
  return link
end

return {
  { Header = collect_header },
  { Link = link_header },
}
```

```{r}
ref <- function(id) {
  dep <- rmarkdown::output_format_dependency(
    name = "example",
    pandoc = list(lua_filters = "example.lua"),
  )
  rmarkdown:::attach_output_format_dependency(dep)
  return(sprintf("[](#%s)", id))
}
```

# awesome section {#awesome} 

see `r ref("brilliant")`

# brilliant section {#brilliant}

see `r ref("awesome")`
@cderv cderv moved this from Backlog to Next / Ready for Dev in R Markdown Team Projects Sep 4, 2023
@cderv
Copy link
Collaborator Author

cderv commented Sep 6, 2023

@yihui yihui changed the title Add chapter about new output_format_dependency() Add a new section about new output_format_dependency() Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

No branches or pull requests

1 participant