A more concise way to add hyperlinks to Rmd files

I can add a hyperlink to an Rmd report in the following fashion [text](https://here.is.my.superlong.link/G01HPJFLS1W/p1608076284001900).

This will appear fine in the knitted report, but it can really clutter up the Rmarkdown report which is where I spend the bulk of my time. Is there a way to create hyperlinks using a reference? e.g., [text](link1) and then have the value for link1 at the bottom of the file?

link1: https://here.is.my.superlong.link/G01HPJFLS1W/p1608076284001900

Hi @joepowers16,

Not a direct answer to your specific question but you could be interesting in the new visual markdown editor included in RStudio 1.4 (currently in Preview)

Only the text of the link would be shown.

I would be interested to know if you find it useful for your usage! Hope so.

Regarding coding solution, that is hack-ish but you could rely on R with the Rmd format compare to only md format. Custom solution that you may found (or not) useful

---
title: 'insert link helper'
output: html_document
---

```{r links-db, include = FALSE}
md_link <- function(text, link) {
  sprintf("[%s](%s)", text, link)
}
links <- c("https://here.is.my.superlong.link/G01HPJFLS1W/p1608076284001900", 
           "https://here.is.my.other.superlong.link/G01HPJFLS1W/p1608076284001900")
```

See `r md_link("text", links[1])`

2 Likes

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.