Skip to content

Commit

Permalink
v0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kazuyanagimoto committed Sep 15, 2024
1 parent b757673 commit 8d1b8a3
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 77 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
*.pdf
/.luarc.json
/template.typ
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
# Quarto-CleanTouying-Typst Format
# Quarto-clean-Typst Format

A minimalistic presentation theme for Quarto + Typst + [Touying](https://touying-typ.github.io).
Theme design is deeply inspired by Grant McDermott's [Clean theme](https://github.com/grantmcdermott/quarto-revealjs-clean) for Quarto + Reveal.js.


Click the image below to see a long [demo](https://kazuyanagimoto.com/quarto-slides-typst/slides/cleantouying/cleantouying.pdf).
Code is available [here](https://github.com/kazuyanagimoto/quarto-slides-typst/blob/main/slides/cleantouying/cleantouying.qmd).
Click the image below to see a long [demo](https://kazuyanagimoto.com/quarto-slides-typst/slides/clean/clean.pdf).
Code is available [here](https://github.com/kazuyanagimoto/quarto-slides-typst/blob/main/slides/clean/clean.qmd).

[![Demo](thumbnail.png)](https://kazuyanagimoto.com/quarto-slides-typst/slides/cleantouying/cleantouying.pdf)
[![Demo](thumbnail.png)](https://kazuyanagimoto.com/quarto-slides-typst/slides/clean/clean.pdf)

## Install


If you would like to add the clean theme to an existing directory:

```bash
quarto install extension kazuyanagimoto/quarto-cleantouying-typst
quarto install extension kazuyanagimoto/quarto-clean-typst
```

or you can use a Quarto template that bundles a .qmd starter file:


```bash
quarto use template kazuyanagimoto/quarto-cleantouying-typst
quarto use template kazuyanagimoto/quarto-clean-typst
```


Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
title: Clean Touying
title: Quarto Clean Theme
author: Kazuharu Yanagimoto
version: 0.1.0
version: 0.2.0
quarto-required: ">=1.5.0"
contributes:
format:
typst:
shortcodes:
- shortcodes.lua
filters:
- filters.lua
- typst-environment.lua
template-partials:
- typst-template.typ
- typst-show.typ
File renamed without changes.
139 changes: 139 additions & 0 deletions _extensions/clean/typst-environment.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
local classEnvironments = pandoc.MetaMap({
["only"] = "only",
["uncover"] = "uncover",
})
local classCommands = pandoc.MetaMap({
["alert"] = "alert",
["fg"] = "fg",
["bg"] = "bg",
["button"] = "button",
["only"] = "only",
["uncover"] = "uncover",
})

-- helper that identifies arrays
local function tisarray(t)
local i = 0
for _ in pairs(t) do
i = i + 1
if t[i] == nil then return false end
end
return true
end

-- reads the environments
local function readEnvironments(meta)
local env = meta['environments']
if env ~= nil then
if tisarray(env) then
-- read an array of strings
for i, v in ipairs(env) do
local value = pandoc.utils.stringify(v)
classEnvironments[value] = value
end
else
-- read key value pairs
for k, v in pairs(env) do
local key = pandoc.utils.stringify(k)
local value = pandoc.utils.stringify(v)
classEnvironments[key] = value
end
end
end
end

local function readCommands(meta)
local env = meta['commands']
if env ~= nil then
if tisarray(env) then
-- read an array of strings
for i, v in ipairs(env) do
local value = pandoc.utils.stringify(v)
classCommands[value] = value
end
else
-- read key value pairs
for k, v in pairs(env) do
local key = pandoc.utils.stringify(k)
local value = pandoc.utils.stringify(v)
classCommands[key] = value
end
end
end
end

local function readEnvsAndCommands(meta)
readEnvironments(meta)
readCommands(meta)
end

local function endTypstBlock(blocks)
local lastBlock = blocks[#blocks]
if lastBlock.t == "Para" or lastBlock.t == "Plain" then
lastBlock.content:insert(pandoc.RawInline('typst', '\n]'))
return blocks
else
blocks:insert(pandoc.RawBlock('typst', ']\n'))
return blocks
end
end


local function writeEnvironments(el)
if quarto.doc.is_format("typst") then
for k, v in pairs(classEnvironments) do
if el.attr.classes:includes(k) then

local blocks = pandoc.List({
pandoc.RawBlock('typst', '#' .. pandoc.utils.stringify(v) .. '('),
})
local opts = el.attr.attributes['options']
if opts then
blocks:insert(pandoc.RawBlock('typst', opts))
end
blocks:insert(pandoc.RawBlock('typst', ')['))
blocks:extend(el.content)
return endTypstBlock(blocks)
end
end

if el.classes:includes("complex-anim") then
local repeat_value = el.attr.attributes["repeat"]
local typst_command = "#slide(repeat: " .. repeat_value .. ", self => [\n#let (uncover, only, alternatives) = utils.methods(self)"
local blocks = pandoc.List({
pandoc.RawBlock('typst', typst_command),
})
blocks:extend(el.content)
blocks:insert(pandoc.RawBlock('typst', '\n])'))
return blocks
end
end
end

local function writeCommands(el)
if quarto.doc.is_format("typst") then
for k, v in pairs(classCommands) do
if el.attr.classes:includes(k) then

local inlines = pandoc.List({
pandoc.RawInline('typst', '#' .. pandoc.utils.stringify(v) .. '('),
})
local opts = el.attr.attributes['options']
if opts then
inlines:insert(pandoc.RawInline('typst', opts))
end
inlines:insert(pandoc.RawInline('typst', ')['))
inlines:extend(el.content)
inlines:insert(pandoc.RawInline('typst', ']'))
return inlines
end
end
end
end

-- Run in two passes so we process metadata
-- and then process the divs
return {
{ Meta = readEnvsAndCommands },
{ Div = writeEnvironments, Span = writeCommands }
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
set text(
size: 1.4em,
fill: self.colors.neutral-darkest,
weight: "light",
weight: self.store.font-weight-heading,
font: self.store.font-heading,
)
utils.call-or-display(self, self.store.header)
Expand Down Expand Up @@ -85,6 +85,7 @@
slide-fn: slide,
new-section-slide-fn: new-section-slide,
handout: handout,
enable-frozen-states-and-counters: false // https://github.com/touying-typ/touying/issues/72
),
config-methods(
init: (self: none, body) => {
Expand Down Expand Up @@ -143,6 +144,7 @@
font-size-title: font-size-title,
font-size-subtitle: font-size-subtitle,
font-weight-title: font-weight-title,
font-weight-heading: font-weight-heading,
..args,
),
)
Expand Down Expand Up @@ -228,11 +230,4 @@
]
}

#let _small-cite(self: none, it) = text(
size: 0.7em,
fill: self.colors.neutral-darkest.lighten(30%),
it
)

#let button(it) = touying-fn-wrapper(_button.with(it))
#let small-cite(it) = touying-fn-wrapper(_small-cite.with(it))
#let button(it) = touying-fn-wrapper(_button.with(it))
43 changes: 0 additions & 43 deletions _extensions/cleantouying/filters.lua

This file was deleted.

13 changes: 0 additions & 13 deletions quarto-cleantouying-typst.Rproj

This file was deleted.

6 changes: 3 additions & 3 deletions template.qmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: A title
subtitle: A subtitle
format: cleantouying-typst
format: clean-typst
author:
- name: Your Name
orcid: 0000-0000-0000-0000
Expand Down Expand Up @@ -55,13 +55,13 @@ Cross-references
Add the theme to an existing project

```{.bash}
quarto install extension kazuyanagimoto/quarto-cleantouying-typst
quarto install extension kazuyanagimoto/quarto-clean-typst
```

... or, create a new project using this slide deck as a lean template

```{.bash}
quarto use template kazuyanagimoto/quarto-cleantouying-typst
quarto use template kazuyanagimoto/quarto-clean-typst
```


Expand Down

0 comments on commit 8d1b8a3

Please sign in to comment.