From 5388cff47b8a4edf1599fd09886316ba7f81ca64 Mon Sep 17 00:00:00 2001 From: nessan Date: Mon, 26 Aug 2024 10:59:49 +0100 Subject: [PATCH] extension update --- .../nessan/admonitions/_extension.yml | 2 +- .../nessan/admonitions/admonitions.lua | 37 +++++++++++-------- .../nessan/admonitions/assets/admonitions.css | 33 ++++++----------- 3 files changed, 33 insertions(+), 39 deletions(-) diff --git a/docs/_extensions/nessan/admonitions/_extension.yml b/docs/_extensions/nessan/admonitions/_extension.yml index 06e6119..42861d5 100644 --- a/docs/_extensions/nessan/admonitions/_extension.yml +++ b/docs/_extensions/nessan/admonitions/_extension.yml @@ -1,6 +1,6 @@ title: admonitions author: nessan -version: 1.0.0 +version: 1.1.0 quarto-required: ">=1.5.0" contributes: filters: diff --git a/docs/_extensions/nessan/admonitions/admonitions.lua b/docs/_extensions/nessan/admonitions/admonitions.lua index 2b49408..d29d080 100644 --- a/docs/_extensions/nessan/admonitions/admonitions.lua +++ b/docs/_extensions/nessan/admonitions/admonitions.lua @@ -1,13 +1,13 @@ --[[ -Quarto extension to process AsciiDoc style 'admonitions' +Quarto extension to process AsciiDoc type 'admonitions' See: https://docs.asciidoctor.org/asciidoc/latest/blocks/admonitions/ For now we only support paragraph syntax for admonitions and only have HTML output. SPDX-FileCopyrightText: 2024 Nessan Fitzmaurice SPDX-License-Identifier: MIT --]] --- Here are the admonition styles we recognize. --- For example, a paragraph starting with 'NOTE: ' will trigger a NOTE style admonition. +-- Here are the admonition types we recognize. +-- For example, a paragraph starting with 'NOTE: ' will trigger a NOTE type admonition. local admonitions = { NOTE = { name = "note", title = "Note"}, TIP = { name = "tip", title = "Tip" }, @@ -16,14 +16,18 @@ local admonitions = { IMPORTANT = { name = "important", title = "Important" } } --- We process each admonition into an one row, two cell HTML table decorated with CSS classes etc. --- Need to inject the the appropriate links and CSS for those to get those tables rendered correctly. -local need_html_dependencies = true -local function process_admonition_dependencies() - if need_html_dependencies then - -- Inject a link to the fontawesome stylesheet (we use some of their icons to mark the admonition) - local fontawesome_link = '' - quarto.doc.include_text('in-header', fontawesome_link) +-- We process each admonition into a one row, two cell HTML table decorated with CSS classes. +-- Need to inject the the appropriate links and CSS to render those tables. +-- That injection needs to done just once as all admonitions share that styling. +local need_to_inject_dependencies = true + +-- Inject the needed CSS if necessary +local function inject_dependencies() + if need_to_inject_dependencies then + + -- Inject a link to the fontawesome stylesheet (we use some of their icons to mark the admonition). + local fa_link = '' + quarto.doc.include_text('in-header', fa_link) -- Inject our own CSS for styling admonition content and icons -- we have those CSS rules in a local stylesheet. quarto.doc.add_html_dependency({ @@ -33,18 +37,19 @@ local function process_admonition_dependencies() }) -- Don't need to call this again - need_html_dependencies = false + need_to_inject_dependencies = false + end end --- Given an admonition style and its content we create an apporiate HTML table to insert in its place. +-- Given an admonition type and its content we return the equiavalent HTML table as a pandoc Block local function process_admonition(admonition, content) -- Add the HTML dependencies if we need to. - if need_html_dependencies then process_admonition_dependencies() end + if need_to_inject_dependencies then inject_dependencies() end -- Create an HTML div containing a table with one row and two cells [icon, content]. - -- The div & table cells are decorated with classes that depend on the particular admonition style. + -- The div & table cells are decorated with classes that depend on the particular admonition type. -- The HTML for that looks like the following where we use placeholders for the class names etc. local pre_template = [[
@@ -52,7 +57,7 @@ local function process_admonition(admonition, content)
]] - -- Turn the template into the specific HTML for this admonition style. + -- Turn the template into the specific HTML for this admonition type. local pre_html = pre_template:gsub('{{}}', admonition.name):gsub('{{}}', admonition.title) -- The cell/row/table/div block needs to get closed out with a bunch of closure tags. diff --git a/docs/_extensions/nessan/admonitions/assets/admonitions.css b/docs/_extensions/nessan/admonitions/assets/admonitions.css index 1e963f9..418caac 100644 --- a/docs/_extensions/nessan/admonitions/assets/admonitions.css +++ b/docs/_extensions/nessan/admonitions/assets/admonitions.css @@ -1,53 +1,43 @@ -/* More or less the same as AsciiDoc admonitions */ +/* Similar to AsciiDoc admonition styling */ .admonition > table { width: 100%; margin-bottom: 1.25em; - word-wrap: normal; border-collapse: separate; border: 0; - background: none; } -.admonition > table tr th, .admonition > table tr td { + line-height: 1.6; padding: 0.5625em 0.625em; - font-size: inherit; - color: rgba(0, 0, 0, 0.8); + font-size: 1.1em; } -.admonition > table tr td { - line-height: 1.6; +.admonition > table td.content { + padding-left: 1.125em; + padding-right: 1.25em; + border-left: 1px solid #dddddf; + word-wrap: anywhere; + opacity: 70%; } .admonition > table td.icon { text-align: center; width: 80px; } -.admonition > table td.icon img { - max-width: none; -} + .admonition > table td.icon .title { font-weight: bold; font-family: "Open Sans", "DejaVu Sans", sans-serif; text-transform: uppercase; } -.admonition > table td.content { - padding-left: 1.125em; - padding-right: 1.25em; - border-left: 1px solid #dddddf; - color: rgba(0, 0, 0, 0.6); - word-wrap: anywhere; -} - .admonition > table td.content > :last-child > :last-child { margin-bottom: 0; } .admonition td.icon [class^="fa icon-"] { font-size: 2.5em; - text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5); cursor: default; } @@ -58,8 +48,7 @@ .admonition td.icon .icon-tip::before { content: "\f0eb"; - text-shadow: 1px 1px 2px rgba(155, 155, 0, 0.8); - color: #111; + color: #719920; } .admonition td.icon .icon-warning::before {