diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..ffc8fbb --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_style = space +trim_trailing_whitespace = true +insert_final_newline = true + +[*.{rs,toml,json}] +indent_size = 4 + +[*.{typ,md}] +indent_size = 2 diff --git a/.gitignore b/.gitignore index 558b320..f39e1f7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ .DS_Store /.luarc.json + +.vscode diff --git a/README.md b/README.md index 8ce77fd..d637cea 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,6 @@ This repository provides Quarto custom formats for the core templates provided b | [Letter](https://github.com/quarto-ext/typst-templates/tree/main/letter) | `quarto use template quarto-ext/typst-templates/letter` | | [Fiction](https://github.com/quarto-ext/typst-templates/tree/main/fiction) | `quarto use template quarto-ext/typst-templates/fiction` | | [Poster](https://github.com/quarto-ext/typst-templates/tree/main/poster) | `quarto use template quarto-ext/typst-templates/poster` | -| [Dept News](https://github.com/quarto-ext/typst-templates/tree/main/dept-news) | `quarto use template quarto-ext/typst-templates/dept-news` | +| [Dashing Dept News](https://github.com/quarto-ext/typst-templates/tree/main/dept-news) | `quarto use template quarto-ext/typst-templates/dept-news` | -These formats are published under the [CC0 1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/) public domain license. \ No newline at end of file +These formats are published under the [CC0 1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/) public domain license. diff --git a/dept-news/README.md b/dept-news/README.md index fd60220..54ee2a9 100644 --- a/dept-news/README.md +++ b/dept-news/README.md @@ -22,7 +22,7 @@ title: "Chemistry Department" edition: | March 18th, 2023 \ Purview College -hero-image: +hero-image: path: "newsletter-cover.jpg" caption: "Award winning science" publication-info: | diff --git a/dept-news/_extensions/dept-news/_extension.yml b/dept-news/_extensions/dept-news/_extension.yml index c3fc9c3..492ac89 100644 --- a/dept-news/_extensions/dept-news/_extension.yml +++ b/dept-news/_extensions/dept-news/_extension.yml @@ -1,7 +1,7 @@ title: Dept-news author: J.J. Allaire -version: 0.2.0 -quarto-required: ">=1.4.11" +version: 0.3.0 +quarto-required: ">=1.7.31" contributes: formats: typst: diff --git a/dept-news/_extensions/dept-news/dept-news.lua b/dept-news/_extensions/dept-news/dept-news.lua index d4411bc..6c42838 100644 --- a/dept-news/_extensions/dept-news/dept-news.lua +++ b/dept-news/_extensions/dept-news/dept-news.lua @@ -2,6 +2,23 @@ function Div(el) + if el.identifier == "quote" then + local blocks = pandoc.List({}) + -- Create the opening part of the quote with optional attribution + local opening = '#quote(block: true' + if el.attributes and el.attributes.attribution then + opening = opening .. ', attribution: [' .. el.attributes.attribution .. ']' + end + -- Complete the opening with the starting bracket for content + opening = opening .. ')[' + -- Add the opening to blocks + blocks:insert(pandoc.RawBlock('typst', opening)) + -- Add the content + blocks:extend(el.content) + -- Close the quote + blocks:insert(pandoc.RawBlock('typst', ']')) + return blocks + end if el.classes:includes('article') then local blocks = pandoc.List({ pandoc.RawBlock('typst', '#article[') diff --git a/dept-news/_extensions/dept-news/typst-show.typ b/dept-news/_extensions/dept-news/typst-show.typ index 258c63a..ea37921 100644 --- a/dept-news/_extensions/dept-news/typst-show.typ +++ b/dept-news/_extensions/dept-news/typst-show.typ @@ -1,15 +1,15 @@ -#show: dept-news.with( +#show: newsletter.with( $if(title)$ - title: "$title$", + title: [$title$], $endif$ $if(edition)$ edition: [$edition$], $endif$ $if(hero-image)$ hero-image: ( - path: "$hero-image.path$", + image: image("$hero-image.path$"), caption: [$hero-image.caption$] - ), + ), $endif$ $if(dedication)$ dedication: [$dedication$], diff --git a/dept-news/_extensions/dept-news/typst-template.typ b/dept-news/_extensions/dept-news/typst-template.typ index 5c4759f..eb8d394 100644 --- a/dept-news/_extensions/dept-news/typst-template.typ +++ b/dept-news/_extensions/dept-news/typst-template.typ @@ -3,9 +3,9 @@ // This function gets your whole document as its `body` and formats // it as the fun newsletter of a college department. -#let dept-news( +#let newsletter( // The newsletter's title. - title: "Newsletter title", + title: [Newsletter title], // The edition, displayed at the top of the sidebar. edition: none, @@ -52,6 +52,7 @@ show link: underline // Configure figures. + set figure(gap: 24pt) show figure: it => block({ // Display a backdrop rectangle. move(dx: -3%, dy: 1.5%, rect( @@ -62,12 +63,15 @@ // Display caption. if it.has("caption") { - set align(center) - set text(font: "Syne") - v(if it.has("gap") { it.gap } else { 24pt }, weak: true) - if it.supplement != none and it.numbering != none { - [#it.supplement #counter(figure).display(it.numbering): ] + show figure.caption: caption => { + set align(center) + set text(font: "Syne") + if it.supplement != none and it.numbering != none { + [#it.supplement #counter(figure).display(it.numbering): ] + } } + + v(if it.has("gap") { it.gap } else { 24pt }, weak: true) it.caption } @@ -88,17 +92,20 @@ text(fill: white, weight: "medium", 14pt, align(right + bottom, edition)), // Hero image. - style(styles => { + context { if hero-image == none { return } // Measure the image and text to find out the correct line width. // The line should always fill the remaining space next to the image. - let img = image(hero-image.path, width: 14cm) + let img = { + set image(width: 14cm) + hero-image.image + } let text = text(size: 25pt, fill: white, font: "Syne Tactile", hero-image.caption) - let img-size = measure(img, styles) - let text-width = measure(text, styles).width + 12pt + let img-size = measure(img) + let text-width = measure(text).width + 12pt let line-length = img-size.height - text-width grid( @@ -116,13 +123,36 @@ line(angle: 90deg, length: line-length, stroke: 3pt + white), ), ) - }), + }, // Nothing next to the hero image. none, // The main flow with body and publication info. { + // A stylized block with a quote and its author. + show quote: it => { + if not it.block { + return it + } + + box(inset: (x: 0.4em, y: 12pt), width: 100%, { + set text(font: "Syne") + grid( + columns: (1em, auto, 1em), + column-gutter: 12pt, + rows: (1em, auto), + row-gutter: 8pt, + text(5em)["], + line(start: (0pt, 0.45em), length: 100%), + none, none, + text(1.4em, align(center, it.body)), + none, none, + v(8pt) + align(right, text(font: "Barlow")[---#it.attribution]), + ) + }) + } + set par(justify: true) body v(1fr) @@ -131,35 +161,18 @@ }, // The sidebar with articles. - locate(loc => { + context { set text(fill: white, weight: 500) show heading: underline.with(stroke: 2pt, offset: 4pt) v(44pt) - for element in articles.final(loc) { + for element in articles.final() { element v(24pt, weak: true) } - }), + }, ) } -// A stylized block with a quote and its author. -#let blockquote(body) = box(inset: (x: 0.4em, y: 12pt), width: 100%, { - set text(font: "Syne") - grid( - columns: (1em, auto, 1em), - column-gutter: 12pt, - rows: (1em, auto), - row-gutter: 8pt, - text(5em)["], - line(start: (0pt, 0.45em), length: 100%), - none, none, - text(1.4em, align(center, body)), - none, none - ) -}) - - // An article that is displayed in the sidebar. Can be added // anywhere in the document. All articles are collected automatically. #let article(body) = articles.update(it => it + (body,)) diff --git a/dept-news/dept-news.png b/dept-news/dept-news.png index 364cb44..1ba9489 100644 Binary files a/dept-news/dept-news.png and b/dept-news/dept-news.png differ diff --git a/dept-news/template.qmd b/dept-news/template.qmd index 50c8e4c..f39effd 100644 --- a/dept-news/template.qmd +++ b/dept-news/template.qmd @@ -3,7 +3,7 @@ title: "Chemistry Department" edition: | March 18th, 2023 \ Purview College -hero-image: +hero-image: path: "newsletter-cover.jpg" caption: "Award winning science" publication-info: | @@ -18,8 +18,9 @@ format: It's our pleasure to announce that our department has recently been awarded the highly-coveted Sixtus Award for Excellence in Chemical Research. This is a massive achievement for our department, and we couldn't be prouder. -> Our Lab has synthesized the most elements of them all.\ -> --- Prof. Herzog +::: {#quote attribution="Prof. Herzog"} +Our Lab has synthesized the most elements of them all. +::: The Sixtus Award is a prestigious recognition given to institutions that have demonstrated exceptional performance in chemical research. The award is named after the renowned chemist Sixtus Leung, who made significant contributions to the field of organic chemistry. @@ -29,7 +30,7 @@ The award will be presented to our department in a formal ceremony that will tak ::: {.article} ## Guest lecture from Dr. Elizabeth Lee - + Elizabeth Lee, a leading researcher in the field of biochemistry, spoke about her recent work on the development of new cancer treatments using small molecule inhibitors, and the lecture was very well-attended by both students and faculty. In case you missed it, there's a recording on [EDGARP](http://purview.edu/lts/2023-lee") @@ -45,6 +46,6 @@ These trainings are crucial for ensuring that all members of the department are ## Another Success -Aliquam sit amet lectus ut libero congue viverra. Morbi quis diam ullamcorper, iaculis ex non, fermentum mauris. Aliquam consectetur vitae purus vitae laoreet. Sed elementum ligula et mauris eleifend dignissim. +Aliquam sit amet lectus ut libero congue viverra. Morbi quis diam ullamcorper, iaculis ex non, fermentum mauris. Aliquam consectetur vitae purus vitae laoreet. Sed elementum ligula et mauris eleifend dignissim. -Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ultrices, dolor molestie viverra interdum, nibh urna dignissim nisi, et rhoncus libero nibh a nulla. Etiam ac augue vel leo vehicula finibus at non tortor. +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ultrices, dolor molestie viverra interdum, nibh urna dignissim nisi, et rhoncus libero nibh a nulla. Etiam ac augue vel leo vehicula finibus at non tortor.