#Exporting everything across templates
22 messages · Page 1 of 1 (latest)
To clarify a bit more
I have a file at src/codeblock/codeblock.typ whose structure is:
#import "@preview/codly:0.2.1"
#show: codly.codly-init.with()
#let icon(codepoint) = {
let path = "assets/" + codepoint + ".svg"
box(
height: 0.8em,
baseline: 0.01em,
image(path)
)
h(0.3em)
}
#codly.codly(
languages: (
python: (name: "Python", icon: icon("python"), color: rgb("#f9e2af")),
julia: (name: "Julia", icon: icon("julia"), color: rgb("#cba6f7")),
r: (name: "R", icon: icon("r"), color: rgb("#89b4fa")),
)
)
I was wondering if something like this is possible for my main template file. template.typ:
#import "src/codeblock/codeblock.typ": *
(triple backticks here)python
test
(triple backticks here)
include
I am probably using this incorrectly, can I get an example or link to docs?
#include "src/codeblock/codeblock.typ"
(triple ticks)python
test
(triple ticks)
does not work
#include "src/codeblock/codeblock.typ"
#import "@preview/codly:0.2.1"
#show: codly.codly-init.with()
'''python
test
'''
So this works
Any clue why the previous does not?
show is scoped.
includeing introduces a new inner scope for the corresp. file.
Ahh hmm
Any way to get around this?
I will also get this issue one down the ladder when I try to go from a "template" to a normal file
Not directly. include is no macro substitution.
The pattern used for templates is what comes the closest to what's being a work-around.
#import "/templ.typ": templ; #show: templ
Ahh so there is no user friendly way of doing this atleast
Needs to be case specific if I understand correctly?
Not in a sense that it wouldn't fit your use-case:
[0m[35m#import[0m [0m[32m"@preview/codly:0.2.1"[0m: [0m[36m*[0m
[0m[35m#let[0m [0m[3m[34mcodlify[0m(all) [0m[36m=[0m {
[0m[35mshow[0m: [0m[3m[34mcodly-init[0m
[0m[3m[34mcodly[0m(
languages: (
python: (name: [0m[32m"Python"[0m, icon: [], color: [0m[3m[34mrgb[0m([0m[32m"#f9e2af"[0m)),
julia: (name: [0m[32m"Julia"[0m, icon: [], color: [0m[3m[34mrgb[0m([0m[32m"#cba6f7"[0m)),
r: (name: [0m[32m"R"[0m, icon: [], color: [0m[3m[34mrgb[0m([0m[32m"#89b4fa"[0m)),
),
)
all
}
So that codlify could be utilized as templ here …
Uhh could you also explain this entire thing if thats not too much to ask 😅