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

consider --standalone output #123

Open
tjmahr opened this issue Nov 18, 2021 · 1 comment
Open

consider --standalone output #123

tjmahr opened this issue Nov 18, 2021 · 1 comment
Labels
feature a feature request or enhancement

Comments

@tjmahr
Copy link

tjmahr commented Nov 18, 2021

According to the pandoc documentation, yaml metadata is only written to markdown output if --standalone is used:

When pandoc is used with -t markdown to create a Markdown document, a YAML metadata block will be produced only if the -s/--standalone option is used. All of the metadata will appear in a single block at the beginning of the document.

As a result, downlit::downlit_md_path() discards YAML metadata when run on markdown files. This prevents me from performing markdown -> downlit -> markdown conversions.

The result of setting --standalone is:

When the -s/--standalone option is used, pandoc uses a template to add header and footer material that is needed for a self-standing document. To see the default template that is used, just type pandoc -D *FORMAT*

If I call system2(rmarkdown::pandoc_exec(), "-D gfm") or system2(rmarkdown::pandoc_exec(), "-D markdown_github"), I get a barebones template which should not otherwise affect the md output.

$if(titleblock)$
$titleblock$

$endif$
$for(header-includes)$
$header-includes$

$endfor$
$for(include-before)$
$include-before$

$endfor$
$if(toc)$
$table-of-contents$

$endif$
$body$
$for(include-after)$

$include-after$
$endfor$
@hadley hadley added the feature a feature request or enhancement label Jun 17, 2022
@JosiahParry
Copy link

I am running into similar issue here except in the context of HTML. I am using downlit to add autolinking to a rendered html document. It is only a partial html file but downlit adds the <html><body> tags

This is an excerpt of my current code. The output of pandoc does not have the tags, but using downlit adds them.

# render the section alone
rmarkdown::render(
  tmp,
  rmarkdown::github_document(),
  out_md
)

tmp_out <- tempfile(fileext = ".html")

# convert to html
pandoc::pandoc_convert(
  out_md,
  to = "html",
  output = tmp_out,
  standalone = FALSE
) 

# apply auto-linking
downlit::downlit_html_path(
  tmp_out,
  tmp_out,
  downlit::classes_pandoc()
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants