From cc17ae7dec8bcee2c3c82bd9ad497e683451f699 Mon Sep 17 00:00:00 2001 From: Thomas Letan Date: Sat, 14 Jan 2023 16:55:14 +0100 Subject: Move side and margin notes around --- plugins/notes.lua | 24 ++++++++++++++++++++++++ soupault.conf | 3 +++ style.css | 4 ++-- 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 plugins/notes.lua diff --git a/plugins/notes.lua b/plugins/notes.lua new file mode 100644 index 0000000..bfaa3e2 --- /dev/null +++ b/plugins/notes.lua @@ -0,0 +1,24 @@ +notes = HTML.select_all_of(page, {".marginnote", ".sidenote"}) + +local index = 1 +while notes[index] do + local note = notes[index] + + HTML.add_class(note, "note") + + index = index + 1 +end + +notes = HTML.select(page, ".note") +index = 1 +while notes[index] do + local note = notes[index] + + if index % 2 == 0 then + HTML.add_class(note, "note-right") + else + HTML.add_class(note, "note-left") + end + + index = index + 1 +end \ No newline at end of file diff --git a/soupault.conf b/soupault.conf index 0601acd..eddc21d 100644 --- a/soupault.conf +++ b/soupault.conf @@ -95,3 +95,6 @@ widget = "css" [widgets.clean-up] widget = "clean-up" + +[widgets.notes] +widget = "notes" \ No newline at end of file diff --git a/style.css b/style.css index 4a3e22c..96e4596 100644 --- a/style.css +++ b/style.css @@ -137,13 +137,13 @@ dd { width: var(--margin-width); } -.sidenote { +.note-right { margin-right: calc(-1 * (var(--margin-width) + var(--gutter-width))); float: right; clear: right; } -.marginnote { +.note-left { float: left; clear: left; margin-left: calc(-1 * (var(--margin-width) + var(--gutter-width))); -- cgit v1.2.3