Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwilby committed Dec 5, 2023
0 parents commit 65c50df
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.html
*.pdf
*_files/
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# openlinksinnewpage Extension For Quarto

With the `openlinksinnewpage` filter [hyperlinks](https://quarto.org/) automatically open in a new page, similarly to adding `{target="_blank"}` to your markdown hyperlinks.

Packaged up as an extension following suggestion by @cscheid on a discussion [here](https://github.com/quarto-dev/quarto-cli/discussions/3169){target="_blank"}.

This provides an alternative to using the following syntax

```md
[quarto](https://quarto.org/){target="_blank"}
```

if you want all links to be opened in a new page.

## Installing

```bash
quarto add davidwilby/openlinksinnewpage
```

This will install the extension under the `_extensions` subdirectory.
If you're using version control, you will want to check in this directory.

## Using

Carry on as usual! Ensure that the following is in your yaml frontmatter:

```yaml
filters:
- openlinksinnewpage
```
All the links in your quarto document or presentation will open in a new page or tab.
## Example
Here is the source code for a minimal example: [example.qmd](example.qmd).
8 changes: 8 additions & 0 deletions _extensions/openlinksinnewpage/_extension.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
title: openlinksinnewpage
author: davidwilby
version: 0.0.1
quarto-required: ">=1.3.0"
contributes:
filters:
- openlinksinnewpage.lua

6 changes: 6 additions & 0 deletions _extensions/openlinksinnewpage/openlinksinnewpage.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- As suggested by @cscheid: https://github.com/quarto-dev/quarto-cli/discussions/3169

function Link(link)
link.attributes["target"] = "_blank"
return link
end
15 changes: 15 additions & 0 deletions example.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: "`openlinksinnewpage` Filter Example"
format:
html: default
pdf: default
filters:
- openlinksinnewpage
---

## Heading

This filter adds formatting to heading text.

With the `openlinksinnewpage` filter [hyperlinks](https://quarto.org/) automatically open in a new page, similarly to adding `{target="_blank"}` to your markdown hyperlinks.

0 comments on commit 65c50df

Please sign in to comment.