Add support for specifying the song order in the metadata section.
This commit is contained in:
parent
4833cc4f37
commit
2acfb42a38
@ -1,6 +1,6 @@
|
||||
# Package
|
||||
|
||||
version = "0.3.1"
|
||||
version = "0.4.0"
|
||||
author = "Jonathan Bernard"
|
||||
description = "Chord chart formatter compatible with Planning Center Online"
|
||||
license = "MIT"
|
||||
|
@ -1,4 +1,4 @@
|
||||
import std/logging, std/nre, std/strtabs, std/strutils
|
||||
import std/[nre, strtabs, strutils]
|
||||
import zero_functional
|
||||
|
||||
type
|
||||
|
@ -1,4 +1,4 @@
|
||||
const PCO_CHORDS_VERSION* = "0.3.1"
|
||||
const PCO_CHORDS_VERSION* = "0.4.0"
|
||||
|
||||
const USAGE* = """Usage:
|
||||
pco_chords [options]
|
||||
|
@ -62,6 +62,16 @@ h3 {
|
||||
margin-right: 0.5em;
|
||||
}
|
||||
|
||||
.song-order h3 {
|
||||
font-style: italic;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.song-order li {
|
||||
list-style: none;
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
@media screen {
|
||||
body { margin: 1em; }
|
||||
}
|
||||
@ -84,6 +94,14 @@ proc transpose(ctx: FormatContext, chord: ChordChartChord): string =
|
||||
|
||||
else: result = chord.original
|
||||
|
||||
func makeSongOrder(songOrder, indent: string): string =
|
||||
result = indent & "<section class=song-order>\p" &
|
||||
indent & " <h3>Song Order</h3>\p" &
|
||||
indent & " <ul>\p"
|
||||
result &= join(songOrder.split(",") -->
|
||||
map(indent & " <li>" & it.strip & "</li>\p"), "")
|
||||
result &= indent & " </ul>\p" & indent & "</section>\p"
|
||||
|
||||
proc toHtml(ctx: var FormatContext, node: ChordChartNode, indent: string): string =
|
||||
result = ""
|
||||
case node.kind
|
||||
@ -195,6 +213,10 @@ proc toHtml*(
|
||||
|
||||
result &= "<div class=page-contents>"
|
||||
result &= join(cc.nodes --> map(ctx.toHtml(it, indent & " ")), "\p")
|
||||
|
||||
if cc.metadata.contains("song order"):
|
||||
result &= makeSongOrder(cc.metadata["song order"], indent)
|
||||
|
||||
result &= "</div>"
|
||||
|
||||
result &= " </body>\p</html>"
|
||||
|
Loading…
x
Reference in New Issue
Block a user