Skip to content

Commit 26cb65d

Browse files
authored
Initial commit
0 parents  commit 26cb65d

File tree

8 files changed

+269
-0
lines changed

8 files changed

+269
-0
lines changed

.github/FUNDING.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# These are supported funding model platforms
2+
3+
github: mcanouil # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
12+
polar: # Replace with a single Polar username
13+
buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
14+
thanks_dev: # Replace with a single thanks.dev username
15+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
interval: "monthly"

.github/workflows/deploy.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Deploy
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
concurrency:
15+
group: "pages"
16+
cancel-in-progress: false
17+
18+
jobs:
19+
deploy:
20+
runs-on: ubuntu-latest
21+
environment:
22+
name: github-pages
23+
url: ${{ steps.deployment.outputs.page_url }}
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- uses: quarto-dev/quarto-actions/setup@v2
28+
with:
29+
version: pre-release
30+
tinytex: true
31+
32+
- name: Render Quarto Project
33+
shell: bash
34+
run: |
35+
echo -e "project:\n output-dir: _site" > _quarto.yml
36+
# Render to all formats via for loop to avoid LaTeX error "pdf/beamer" formats
37+
for format in html typst pdf docx revealjs beamer pptx; do
38+
quarto render --to ${format}
39+
done
40+
41+
- uses: actions/configure-pages@v5
42+
43+
- uses: actions/upload-pages-artifact@v3
44+
with:
45+
path: '_site'
46+
47+
- name: Deploy to GitHub Pages
48+
id: deployment
49+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.DS_Store
2+
*.html
3+
*.pdf
4+
*_files/
5+
/.luarc.json

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Mickaël Canouil
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Repository Template for Quarto Extension
2+
3+
An opinionated repository template for Quarto extension.
4+
5+
## Installing
6+
7+
```bash
8+
quarto add mcanouil/quarto-{{EXTENSION}}
9+
```
10+
11+
This will install the extension under the `_extensions` subdirectory.
12+
If you're using version control, you will want to check in this directory.
13+
14+
## Using
15+
16+
## Example
17+
18+
Here is the source code for a minimal example: [example.qmd](example.qmd).
19+
20+
Outputs of `example.qmd`:
21+
22+
- [HTML](https://m.canouil.dev/quarto-{{EXTENSION}}/)
23+
- [Typst (PDF)](https://m.canouil.dev/quarto-{{EXTENSION}}/example-typst.pdf)
24+
- [LaTeX (PDF)](https://m.canouil.dev/quarto-{{EXTENSION}}/example-latex.pdf)
25+
- [Word (DOCX)](https://m.canouil.dev/quarto-{{EXTENSION}}/example-openxml.docx)
26+
- [Reveal.js (HTML)](https://m.canouil.dev/quarto-{{EXTENSION}}/example-revealjs.html)
27+
- [Beamer (PDF)](https://m.canouil.dev/quarto-{{EXTENSION}}/example-beamer.pdf)
28+
- [PowerPoint (PPTX)](https://m.canouil.dev/quarto-{{EXTENSION}}/example-pptx.pptx)

create-extension.sh

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#!/usr/bin/env bash
2+
3+
REPO_NAME=""
4+
REPO_USER="mcanouil"
5+
REPO_TEMPLATE="mcanouil/quarto-extension"
6+
OPEN=false
7+
8+
# bash ./create-extension.sh --repository quarto-{{EXTENSION}} --what filter --path ~/Projects/quarto
9+
10+
usage() {
11+
echo "Usage: $0 --repository <repo_name> --what <extension_type> [--template <repo_template>] [--path <path>] [--open] [--help]"
12+
echo " -r, --repository Repository name (required)"
13+
echo " -w, --what Quarto extension type (shortcode, filter, theme) (required)"
14+
echo " -p, --path Repository path"
15+
echo " -o, --open Open repository in Visual Studio Code"
16+
echo " -t, --template Repository template (default: mcanouil/quarto-extension)"
17+
echo " -h, --help Display this help message"
18+
}
19+
20+
while [[ "$#" -gt 0 ]]; do
21+
case $1 in
22+
-r|--repository) REPO_NAME="$2"; shift ;;
23+
-p|--path) REPO_PATH="$2"; shift ;;
24+
-w|--what) EXTENSION_TYPE="$2"; shift ;;
25+
-o|--open) OPEN=true ;;
26+
-t|--template) REPO_TEMPLATE="$2"; shift ;;
27+
-h|--help) usage; exit 0 ;;
28+
*) echo "Unknown parameter passed: $1"; usage; exit 1 ;;
29+
esac
30+
shift
31+
done
32+
33+
if [ -z "${REPO_NAME}" ]; then
34+
echo "Error: Repository name is required."
35+
usage
36+
exit 1
37+
fi
38+
39+
if [ -z "${EXTENSION_TYPE}" ]; then
40+
echo "Error: Quarto extension type is required."
41+
usage
42+
exit 1
43+
fi
44+
45+
gh repo create "${REPO_USER}/${REPO_NAME}" --template "${REPO_TEMPLATE}" --private --disable-wiki
46+
sleep 2
47+
labels=$(gh label list --repo "${REPO_USER}/${REPO_NAME}" --json name -q '.[].name')
48+
while IFS= read -r label; do
49+
gh label delete "${label}" --repo "${REPO_USER}/${REPO_NAME}" --yes
50+
done <<< "${labels}"
51+
52+
gh label clone "${REPO_TEMPLATE}" --repo "${REPO_USER}/${REPO_NAME}"
53+
gh repo edit "${REPO_USER}/${REPO_NAME}" --allow-update-branch --delete-branch-on-merge --enable-auto-merge --enable-projects=false
54+
55+
rulesets=$(
56+
gh api \
57+
-H "Accept: application/vnd.github+json" \
58+
-H "X-GitHub-Api-Version: 2022-11-28" \
59+
"/repos/${REPO_TEMPLATE}/rulesets" --jq '.[] | ._links.self.href | sub("https://api.github.com"; "")'
60+
)
61+
62+
while IFS= read -r ruleset; do
63+
ruleset_json=$(
64+
gh api \
65+
-H "Accept: application/vnd.github+json" \
66+
-H "X-GitHub-Api-Version: 2022-11-28" \
67+
"${ruleset}"
68+
)
69+
gh api \
70+
-H "Accept: application/vnd.github+json" \
71+
-H "X-GitHub-Api-Version: 2022-11-28" \
72+
"repos/${REPO_USER}/${REPO_NAME}/rulesets" \
73+
--method POST \
74+
--input <(echo "${ruleset_json}") > /dev/null 2>&1
75+
done <<< "${rulesets}"
76+
77+
if [ -n "${REPO_PATH}" ]; then
78+
gh repo clone "${REPO_USER}/${REPO_NAME}" "${REPO_PATH}/${REPO_NAME}"
79+
else
80+
gh repo clone "${REPO_USER}/${REPO_NAME}"
81+
fi
82+
83+
(
84+
if [ -n "${REPO_PATH}" ]; then
85+
cd "${REPO_PATH}/${REPO_NAME}" || exit
86+
else
87+
cd ${REPO_NAME} || exit
88+
fi
89+
90+
rm create-extension.sh
91+
92+
EXTENSION=${REPO_NAME#quarto-}
93+
quarto create extension ${EXTENSION_TYPE} ${EXTENSION} --no-open
94+
if [ -d ${EXTENSION}/_extensions ]; then
95+
mv ${EXTENSION}/_extensions ./
96+
fi
97+
if [ -f ${EXTENSION}/example.qmd ]; then
98+
mv ${EXTENSION}/example.qmd ./example-${EXTENSION_TYPE}.qmd
99+
fi
100+
rm -rf ${EXTENSION}
101+
sed -i '' "s/{{EXTENSION}}/${EXTENSION}/g" README.md
102+
)
103+
104+
if [ "${OPEN}" = true ]; then
105+
if [ -n "${REPO_PATH}" ]; then
106+
code ${REPO_PATH}/${REPO_NAME}
107+
else
108+
code ${REPO_NAME}
109+
fi
110+
fi

example.qmd

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
title: "{{EXTENSION}} Quarto Extension"
3+
format-links: true
4+
embed-resources: true
5+
format:
6+
html:
7+
output-file: index
8+
code-tools: true
9+
typst:
10+
output-file: example-typst
11+
papersize: a4
12+
margin:
13+
x: 2.5cm
14+
y: 2.5cm
15+
pdf:
16+
output-file: example-latex
17+
papersize: a4
18+
margin:
19+
x: 2.5cm
20+
y: 2.5cm
21+
docx:
22+
output-file: example-docx
23+
revealjs:
24+
output-file: example-revealjs
25+
beamer:
26+
output-file: example-beamer
27+
aspectratio: 169
28+
pptx:
29+
output-file: example-pptx
30+
---

0 commit comments

Comments
 (0)