Myriad-Dreamin / shiroa

shiroa is a simple tool for creating modern online books in pure typst.
https://myriad-dreamin.github.io/shiroa/
Apache License 2.0
246 stars 16 forks source link

Difficulty creating “book-meta summary” from a dictionary #82

Closed TeoEchavarria closed 1 month ago

TeoEchavarria commented 1 month ago

My idea is something like this, where the chapters can come from an excel or csv, and it automatically creates the summary that is inside the “book.typ”, but it's causing me some problems

#let chapters = (
  (“Set Theory”, (
    (“240724113358”, “Multiplicity Zeros”),
    ("240724113558", "Probabilidad"),
  )),
)

#let summary = [
  #chapters.map(one => [
    = #one.in(0)
    #one.in(1).map(content=>[
      - #chapter(“content/”+content.at(0)+“.typ”)[#content.at(1)])
    ]).join().children.at(1)
  ]).join()
]

This code would have to be equivalent to something like.

[
= set theory
- #chapter(“content/240724113358.typ”)[Multiplicity Zeros].
- #chapter(“content/240724113558.typ”)[Probabilidad]
]
Myriad-Dreamin commented 1 month ago

Please check:

#let summary = chapters.map(((cat, subs)) => {
  heading(depth: 1, cat)
  subs.map(((id, title)) => chapter("content/" + id + ".typ", title)).map(c => [- #c]).join()
})

#repr(summary)

#repr[
  = Set Theory
  - #chapter("content/240724113358.typ", "Multiplicity Zeros")
  - #chapter("content/240724113558.typ", "Probabilidad")
]
TeoEchavarria commented 1 month ago
#let chapters = (
  ("Set Theory", (
    ("240724113358", "Multiplicity Zeros"),
    ("240724120916", "Conjunto"),
  )),
)

#let summary_dir = chapters.map(((cat, subs)) => {
  heading(depth: 1, cat)
  subs.map(((id, title)) => chapter("content/" + id + ".typ", title)).map(c => [- #c]).join()
})
// Crear un Python para crear el archivo de typs : Obtener una evaluacion del codigo de typs

#book-meta(
  title: "TeoNotes",
  summary : summary_dir.join()
)

Finally I am left with something like this, as soon as I integrate the part of bringing the data from a document I show it. Thank you very much