#Exporting everything across templates

22 messages · Page 1 of 1 (latest)

viscid summit
#

I have a file that contains some codly configurations. I want to have them applied when I import the file. Is this possible?

#

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)
torn torrent
#

include

viscid summit
#
#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?

torn torrent
#

includeing introduces a new inner scope for the corresp. file.

viscid summit
#

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

torn torrent
torn torrent
#

#import "/templ.typ": templ; #show: templ

viscid summit
#

Ahh so there is no user friendly way of doing this atleast

#

Needs to be case specific if I understand correctly?

torn torrent
# viscid summit Needs to be case specific if I understand correctly?

Not in a sense that it wouldn't fit your use-case:

#import "@preview/codly:0.2.1": *

#let codlify(all) = {
    show: codly-init
    codly(
        languages: (
            python: (name: "Python", icon: [], color: rgb("#f9e2af")),
            julia: (name: "Julia", icon: [], color: rgb("#cba6f7")),
            r: (name: "R", icon: [], color: rgb("#89b4fa")),
        ),
    )
    all
}
torn torrent
viscid summit
#

Uhh could you also explain this entire thing if thats not too much to ask 😅