Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add spacer shortcode #103

Merged
merged 6 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions _extensions/closeread/_extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ contributes:
html:
filters:
- closeread.lua
shortcodes:
- spacer.lua
css: closeread.css
page-layout: full
execute:
Expand Down
4 changes: 4 additions & 0 deletions _extensions/closeread/closeread.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions _extensions/closeread/closeread.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion _extensions/closeread/closeread.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@
margin-bottom: 0;
}
}


&:has(.cr-spacer) {
visibility: hidden;
padding-block: 0;
}
}
}

Expand Down
24 changes: 24 additions & 0 deletions _extensions/closeread/spacer.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
function spacer(args)
local spacerLength = "40svh"
if args[1] ~= nil then
spacerString = pandoc.utils.stringify(args[1])
end

-- split spacer height into number and units
local _, _, spacerNumStr, spacerUnits =
string.find(spacerString, "(%d+)%s?(%a+);?")
local spacerNum = tonumber(spacerNumStr)

if (spacerNum == nil) then
error("Spacer height should be a number followed by a CSS unit, not " ..
spacerString)
end

-- halve and join back up
local spacerHeightHalved = tostring(spacerNum / 2) .. (spacerUnits or "")

return pandoc.Div({},
pandoc.Attr("",
{ "cr-spacer" },
{ style = "padding-block: " .. spacerHeightHalved .. ";" }))
end
3 changes: 1 addition & 2 deletions docs/gallery/examples/minards-map/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ An especially effective device for enhancing the explanatory power of time-serie

:::{.cr-section}

:::{style="padding-block: 20svh"}
:::
{{< spacer 10svh >}}

The first is the classic of Charles Joseph Minard (1781-1870), the French engineer, which shows the terrible fate of Napoleon's army in Russia. Described by E. J. Marey as seeming to defy the pen of the historian by its brutal eloquence, 12 this combination of data map and time-series, drawn in 1869, portrays a sequence of devastating losses suffered in Napoleon's Russian campaign of 1812. @cr-map

Expand Down
2 changes: 2 additions & 0 deletions docs/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ Step four: create a trigger to make the sticky appear. [@cr-doc]{highlight="12"}
:::{style="height: 40dvh; visibility: hidden"}
:::

{{< spacer 40svh >}}

Triggers, like this text, scroll past while the stickies stay "stuck" on the page. [@cr-doc]{highlight=""}

:::{#cr-doc filename="myfirstcr.qmd" .scale-to-fill}
Expand Down
Loading