I have a basic Nuxt3 + #nuxt/content v2 setup. There is a .yaml file in the content folder that has fields whose values are markdown strings ( this file is produced by Netlify CMS) i.e:
# content/post.yaml
title: Some title
body: Some **markdown** content
I can fetch the file using queryContent, but what do I use to parse and render the markdown in those fields?
The provided <Markdown /> component seems to accept only parsed markdown in the format that is returned when queryContent is called on .md files. But I cannot find an API exposed by #nuxt/content to parse markdown string into that format runtime (i.e in my useAsynData hook ).
Related
I have a list of papers that I'd like to extract from arXiv (I have the arxiv links / name of the arxvi file), but in the LaTeX format. How can I do this in Python?
If we go to this page: https://arxiv.org/format/2010.11645
We can read the following text:
Source:
Delivered as a gzipped tar (.tar.gz) file if there are multiple files, otherwise as a PDF file, or a gzipped TeX, DVI, PostScript or HTML (.gz, .dvi.gz, .ps.gz or .html.gz) file depending on submission format. [ Download source ]
We can download the file by clicking on [ Download source ], but I have no idea what type of file I'm getting back. The filename is simple 2010.11645.
I'd like to download the file in LaTeX format (which I believe it .tex) and then convert it into .txt using pandoc. I believe I'd need to download the files via requests somehow?
How can I do this? Thanks!
I am creating a bookdown document in which I provide a link for people to download the PDF, DOCX and TEX outputs of the current section they are looking at.
All output documents are in a folder named "Compilation" and have the same name of the original Rmd documents they were retrieved.
For exemple, I have the file "1.2-Endowment-effect.Rmd" in which I coded:
Download Links: [[PDF]](./Compilation/1.2-Endowment-effect.pdf)
[[DOCX]](./Compilation/1.2-Endowment-effect.docx)
[[TEX]](./Compilation/1.2-Endowment-effect.tex)
I wanted to know if, instead of writting "1.2-Endowment-effect" in the code, there would be a way to take the name of the current Rmd file and add the extension. Something like:
Download Links: [[PDF]](./Compilation/NameCurrentFile.pdf)
[[DOCX]](./Compilation/NameCurrentFile.docx)
[[TEX]](./Compilation/NameCurrentFile.tex)
I have to repeat that process for lots of Rmd files, and I want to avoid always updating the links.
Thank you for your help.
The output filenames can be generated with inline R expressions, e.g.,
Download Links: [PDF](./Compilation/`r xfun::with_ext(knitr::current_input(), 'pdf'`)
Please read the help pages of the functions xfun::with_ext() and knitr::current_input() if you are not familiar with them.
To include this part in all other Rmd documents, you can put the content in a child document named, say, _download.Rmd, and in your main Rmd documents, use
```{r, child='_download.Rmd'}
```
When using Rstudio, one can use File -> New File -> R markdown... to create a new R markdown file from a template, with YAML headers and some examples already buffered. Is there a function to replicate this without an IDE (in this case, saving the template Rstudio would buffer in a new file)?
I'd rather start my .Rmd file from template rather than from scratch, but not using an IDE.
rmarkdown::draft seems to do what you want. It creates a new file, based on a template. You can provide a link to a custom template. See the help page for details.
I am attempting my first Rmarkdown Parameterized report. The first section will download a dataset from one of two sources (and internal vs external database) based on the params 'dataSource' selected by the user. The Rscript/code required is different for the different options.
title: "Optionally DL from external vs internal database"
output: html_document
params:
dataSource:
label: "Select the database for download:"
value: IntD
input: radio
choiceNames: [External DB, Internal DB]
choiceValues: [ExtD, IntD]
inline: TRUE
The following code does work, but is there a way to optionally run an entire Rchunk based on a params selection (some code put directly in the Rchunk header, for example)?
```{r downloadData, include=TRUE}
#Can I run different rchunk or code based on the params$dataSource value??
#Can this be done directly in the Rchunk header?
if(params$dataSource=="IntD"){
source(here::here("R", "Intdownload.R")
}else{
source(here::here("R", "Extdownload.R")
}
```
Other options I've explored (and am working on understanding how to implement) are listed below. Are any of these better options to investigate if download code is likely to be used in other reports/Rscript/Rmarkdown documents? I am a bit confused as to when these might be better than using 'source'?
creating seperate chunks in an external Rscript and use read_chunk to read in the external script, then call each chunk based on the params option selected.
Creating a separate Rmarkdown document for datadownload, and then calling that within this Rmarkdown document using child. Does this option essentially allow you to create 2 reports (1 by calling a child Rmarkdown doc, and another for main Rmarkdown document) while using objects created in the child document in the main document?
Why is it important? My collaborators would like to be able to modify my .pdf reports and they are not able to modify the actual .tex code. They are sooo used to word !
How I write my reports? I use knitr. What a great and useful tool; thanks Yihui :)
What I'm looking for? convert the generated pdf report into .doc (my collaborators favorite !)
a solution might help: Pandoc (http://johnmacfarlane.net/pandoc/). As it's explained in the introduction of page of Pandoc, it can be used to convert LaTex to .docx and to markup. I then thought converting the .tex file of each of my reports (a .tex file is generated when I run my knitr .Rnw file) and convert it to .docx using pandoc:
pandoc -s myTexRepot.tex -o aDocReport.docx
issue: 1) Figures are missing in my .docx file. 2) I generate all my tables in my reports using xtable(), none of them can be converted! 3) Also, I lose all table of contents, section numbering.
Markup to Word: Issue (1) above is still an issue in converting Markup code to .doc
Is there any better idea to approach the issue of converting latex to doc. If Pandoc is the best, would you know how I can solve the issues above?
I really appreciate your help.
since you are already using knitr, you can call the rmarkdown:render() function to knit the document.
there is a parameter in render() called output_format[1]. the parameter along with the YAML header in your knitr document will allow you do generate the pdf and word document simultaneously
[1] output_format
R Markdown output format to convert to. Pass "all" to render all formats defined within the file. Pass the name of a format (e.g. "html_document") to render a single format or pass a vector of format names to render multiple formats. Alternatively you can pass an output format object; e.g. html_document(). If NULL is passed then the output format is the first one defined in the YAML metadata of the input file (defaulting to HTML if none is specified).