diff --git a/docsrc/nimconf2022.nim b/docsrc/nimconf2022.nim index e58afa9..63092ac 100644 --- a/docsrc/nimconf2022.nim +++ b/docsrc/nimconf2022.nim @@ -639,7 +639,7 @@ slide: nbText: "## Using Templates" nimConfAutoSlide: nbText: "## Using Templates" - nbCodeDontRunAnimate([@[1..1, 3..3, 6..6]]): + nbCodeDontRunAnimate({1, 3, 6}): slide(slideOptions(autoAnimate=true)): nbText: "## Animate header" slide(slideOptions(autoAnimate=true)): diff --git a/docsrc/tutorials/code_block.nim b/docsrc/tutorials/code_block.nim index 14b2df3..d8def38 100644 --- a/docsrc/tutorials/code_block.nim +++ b/docsrc/tutorials/code_block.nim @@ -50,14 +50,14 @@ Poof! The output is gone! One cool feature of Reveal.js is the animated code blocks. It allows you to create a code block like the ones we have created above, but highlight specific lines. This is done using the `animateCode` template by providing which lines to highlight and in which order. -The lines can be specified either as a slice `x..y` or a single line number `x`. +The lines can be specified either as a slice `x..y`, a single line number `x`, or a set of lines `{x, y}`. Note that the first line has line number 1 (and not 0). """ codeAndSlides: slide: - animateCode(1, 2..3, 5, 3..4): + animateCode(1, 2..3, 5, {2, 4}): let x1 = 1 let x2 = 2 let x3 = 3 @@ -65,7 +65,7 @@ codeAndSlides: let x5 = 5 nbText: hlMd""" -As you can see, first line 1 is highlighted, then lines 2 through 3, then line 5 and lastly line 3 through 4. Neat! +As you can see, first line 1 is highlighted, then lines 2 through 3, then line 5 and lastly line 2 through 4. Neat! Note that there exists no `animateCodeInBlock` currently, but you can always wrap your `animateCode` inside a `block:` to get the same effect. The animated code block is also useful if you have a very long code snippet that you want to show as it will auto-scroll for you: """ diff --git a/nimiSlides.nimble b/nimiSlides.nimble index 1246496..41fefca 100644 --- a/nimiSlides.nimble +++ b/nimiSlides.nimble @@ -1,6 +1,6 @@ # Package -version = "0.2.2" +version = "0.2.3" author = "Hugo Granström" description = "Reveal.js theme for nimib" license = "MIT" @@ -14,22 +14,21 @@ requires "nimib >= 0.3.9" import os task docsDeps, "install dependencies required to build docs": - exec "nimble -y install ggplotnim@0.5.6 karax numericalnim nimibook" + exec "nimble -y install ggplotnim@0.5.6 karax numericalnim nimibook@#head" task buildDocs, "build all .nim files in docsrc/": - for (kind, path) in walkDir("docsrc/"): - if path.endsWith(".nim"): - if "index" in path: continue - echo "Building: " & path - let buildCommand = "nim r " & path + for path in ["showcase.nim", "nimconf2022.nim", "miscSlides.nim", "index_old.nim", "fragments.nim"]: + let path = "docsrc" / path + echo "Building: " & path + let buildCommand = "nim r " & path + exec buildCommand + if "showcase" in path: + let buildCommand = "nim r -d:themeWhite " & path exec buildCommand - if "showcase" in path: - let buildCommand = "nim r -d:themeWhite " & path - exec buildCommand task buildBook, "Builds the nimiBook docs": - selfExec(" r -d:release nbook.nim init") - selfExec(" r -d:release -f -d:nimibMaxProcesses=1 -d:nimibParallelBuild=false nbook.nim build") + selfExec(" r nbook.nim init") + selfExec(" r nbook.nim build") task docs, "Generate automatic docs": exec "nim doc --project --index:on --git.url:https://github.com/HugoGranstrom/nimiSlides --git.commit:main --outdir:docs/docs src/nimiSlides.nim" diff --git a/src/nimiSlides.nim b/src/nimiSlides.nim index 4a627ac..a1cc717 100644 --- a/src/nimiSlides.nim +++ b/src/nimiSlides.nim @@ -159,6 +159,9 @@ template showSlideNumber*() = template disableVerticalCentering*() = nb.context["disableCentering"] = true +proc addStyle*(doc: NbDoc, style: string) = + doc.context["nb_style"] = doc.context["nb_style"].vString & "\n" & style + proc revealTheme*(doc: var NbDoc) = doc.partials["document"] = document doc.partials["head"] = head @@ -190,6 +193,15 @@ proc revealTheme*(doc: var NbDoc) = doc.context["slidesTheme"] = "black" doc.context["nb_style"] = "" + doc.addStyle: """ + .nimislides-li { + position: relative; + } + + .nimislides-li::before { + position: absolute; + } + """ try: let slidesConfig = loadTomlSection(doc.rawCfg, "nimislides", NimiSlidesConfig) @@ -199,9 +211,6 @@ proc revealTheme*(doc: var NbDoc) = except CatchableError: discard # if it doesn't exists, just let it be -proc addStyle*(doc: NbDoc, style: string) = - doc.context["nb_style"] = doc.context["nb_style"].vString & "\n" & style - var currentFragment*, currentSlideNumber*: int proc slideOptionsToAttributes*(options: SlideOptions): string = @@ -378,7 +387,7 @@ template listItem*(animation: seq[FragmentAnimation], body: untyped) = for an in animation: classString &= $an & " " fadeInNext: - nbRawHtml: """