Skip to content

Commit

Permalink
Merge pull request #103 from qmd-lab/feature-spacers
Browse files Browse the repository at this point in the history
Add spacer shortcode
  • Loading branch information
jimjam-slam authored Oct 31, 2024
2 parents f3b21a2 + 982bf5f commit 12e6098
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 3 deletions.
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

0 comments on commit 12e6098

Please sign in to comment.