Compare commits

...

3 Commits

3 changed files with 109 additions and 12 deletions

View File

@ -22,11 +22,17 @@ Or to create a new note:
typst init @local/notes <directory> typst init @local/notes <directory>
``` ```
A useful alias to generate a new note *in the current directory*:
```
alias new-note='TMP_ENV="$(mktemp -d)" && typst init @local/notes "${TMP_ENV}/note" 2>/dev/null && mv -i ${TMP_ENV}/note/* . && rm -r ${TMP_ENV} && mv -i main.typ '
```
## Features ## Features
### Graph ### Graph
This package import gviz and can render dot graphs: This package import gviz and pintora to render graphs:
``` ```
\```dot-render \```dot-render
@ -55,6 +61,23 @@ c -- a;
\``` \```
``` ```
```
\```pintora
mindmap
@param layoutDirection TB
* Pintora diagrams
** UML Diagrams
*** Sequence Diagram
*** Activity Diagram
*** Component Diagram
** Non-UML Diagrams
*** Entity Relationship Diagram
*** Mind Map
*** Gantt Diagram
*** DOT Diagram
\```
```
### Todo ### Todo
Todos can be defined with the `todo` function. In addition to being highlighted, the unresolved totos are listed at the end of the generated document. Todos can be defined with the `todo` function. In addition to being highlighted, the unresolved totos are listed at the end of the generated document.
@ -75,6 +98,14 @@ To hid todos, you can add this line at the top of the document:
#show-todos.update(_ => false) #show-todos.update(_ => false)
``` ```
### Templates
Parameters can be passed to the template depending on the usage. The `doc_type` parameter indicate the specific template to use:
```
#show: notes-template.with(doc_type: "research_journal", keywords: ("ipsum",))
```
## TODO: ## TODO:
- biblio - biblio

71
lib.typ
View File

@ -1,4 +1,5 @@
#import "@preview/gviz:0.1.0": * #import "@preview/gviz:0.1.0"
#import "@preview/pintorita:0.1.0"
#let todo-list = state("todo-list",()) #let todo-list = state("todo-list",())
#let show-todos = state("show-todos", true) #let show-todos = state("show-todos", true)
@ -22,12 +23,62 @@
} }
} }
#let notes-template(doc) = [ #let note_header(title: "Notes", ..args) = {
#show raw.where(lang: "dot-render"): it => render-image(it.text) [ = #title ]
#show raw.where(lang: "digraphLR"): it => render-image("digraph mygraph { rankdir=\"LR\";" + it.text + "}") }
#show raw.where(lang: "digraphTB"): it => render-image("digraph mygraph { rankdir=\"TB\";" + it.text + "}")
#show raw.where(lang: "graphLR"): it => render-image("graph mygraph { rankdir=\"TB\";" + it.text + "}") #let research_journal_header(title: "Research Journal", ..args) = {
#show raw.where(lang: "graphTB"): it => render-image("graph mygraph { rankdir=\"TB\";" + it.text + "}") show link: underline
#doc show heading.where(level: 2): it => {
#todos() it
] v(5pt, weak: true)
line(length: 100%)
}
// Setup level3 headings
show heading.where(level: 3): it => {
block(smallcaps(it.body))
}
// Set Make title
align(center, text(size: 20pt, font: "Indie Flower", title))
v(2em)
}
#let notes-template(title: none, doc_type: none, keywords: (), doc) = {
show raw.where(lang: "dot-render"): it => gviz.render-image(it.text)
show raw.where(lang: "digraphLR"): it => gviz.render-image("digraph mygraph { rankdir=\"LR\";" + it.text + "}")
show raw.where(lang: "digraphTB"): it => gviz.render-image("digraph mygraph { rankdir=\"TB\";" + it.text + "}")
show raw.where(lang: "graphLR"): it => gviz.render-image("graph mygraph { rankdir=\"TB\";" + it.text + "}")
show raw.where(lang: "graphTB"): it => gviz.render-image("graph mygraph { rankdir=\"TB\";" + it.text + "}")
show raw.where(lang: "pintora"): it => pintorita.render(it.text)
// Make keywords bold
show: rest => {
for keyword in keywords {
rest = {
show keyword: set text(weight: "bold")
rest
}
}
rest
}
let args = (:)
for (arg, val) in ("title": title, "keywords": keywords) {
if val != none {
args.insert(arg, val)
}
}
if doc_type == "notes" {
note_header(..args)
} else if doc_type == "research_journal" {
research_journal_header(..args)
} else {
assert.eq(doc_type, none, message: "unknown document type: " + doc_type)
}
doc
todos()
}

View File

@ -1,5 +1,5 @@
#import "@local/notes:0.0.1": * #import "@local/notes:0.0.1": *
#show: notes-template #show: notes-template.with(doc_type: "research_journal", keywords: ("ipsum",))
```dot-render ```dot-render
digraph mygraph { digraph mygraph {
@ -23,3 +23,18 @@ c -- a;
``` ```
Lorem ipsum dolore #todo[sit] amet Lorem ipsum dolore #todo[sit] amet
```pintora
mindmap
@param layoutDirection TB
* Pintora diagrams
** UML Diagrams
*** Sequence Diagram
*** Activity Diagram
*** Component Diagram
** Non-UML Diagrams
*** Entity Relationship Diagram
*** Mind Map
*** Gantt Diagram
*** DOT Diagram
```