Keep alphabetical ordering and color PDF files.

finite-set-exercises
Joshua Potter 2023-07-16 14:46:28 -06:00
parent 62d0cf38b2
commit 143b23cbab
3 changed files with 20 additions and 8 deletions

View File

@ -15,7 +15,7 @@ open scoped DocGen4.Jsx
def moduleListFile (file : NameExt) : BaseHtmlM Html := do
return <div class={if (← getCurrentName) == file.name then "nav_link visible" else "nav_link"}>
<a href={← moduleNameExtToLink file}>{file.getString!}</a>
<a class={if file.ext == .pdf then "pdf_link" else ""} href={← moduleNameExtToLink file}>{file.getString!}</a>
</div>
/--
@ -23,11 +23,14 @@ Build the HTML tree representing the module hierarchy.
-/
partial def moduleListDir (h : Hierarchy) : BaseHtmlM Html := do
let children := Array.mk (h.getChildren.toList.map Prod.snd)
let dirs := children.filter (fun c => c.getChildren.toList.length != 0)
let files := children.filter (fun c => Hierarchy.isFile c && c.getChildren.toList.length = 0)
|>.map Hierarchy.getNameExt
let dirNodes ← dirs.mapM moduleListDir
let fileNodes ← files.mapM moduleListFile
let nodes ← children.mapM (fun c =>
if c.getChildren.toList.length != 0 then
moduleListDir c
else if Hierarchy.isFile c && c.getChildren.toList.length = 0 then
moduleListFile (Hierarchy.getNameExt c)
else
pure ""
)
let moduleLink ← moduleNameToHtmlLink h.getName
let summary :=
if h.isFile then
@ -38,8 +41,7 @@ partial def moduleListDir (h : Hierarchy) : BaseHtmlM Html := do
pure
<details class="nav_sect" "data-path"={moduleLink} [if (← getCurrentName).any (h.getName.isPrefixOf ·) then #[("open", "")] else #[]]>
{summary}
[dirNodes]
[fileNodes]
[nodes]
</details>
/--

View File

@ -18,6 +18,12 @@ def cmp : Extension → Extension → Ordering
| pdf, pdf => Ordering.eq
| pdf, _ => Ordering.gt
instance : BEq Extension where
beq e1 e2 :=
match cmp e1 e2 with
| Ordering.eq => true
| _ => false
def toString : Extension → String
| html => "html"
| pdf => "pdf"

View File

@ -14,6 +14,10 @@ a {
color: var(--link-color);
}
a.pdf_link {
color: purple;
}
h1, h2, h3, h4, h5, h6 {
font-family: 'Merriweather', serif;
}