Fix chord parsing, formatting.

This commit is contained in:
2025-04-11 15:47:46 -05:00
parent 2712f9ff52
commit a57aed0715
5 changed files with 113 additions and 6 deletions

View File

@@ -52,7 +52,7 @@ h3 .section-text {
.line {
display: flex;
flex-direction: row;
align-items: flex-end;
align-items: end;
margin-left: 0.5em;
margin-bottom: 0.5em;
@@ -65,10 +65,104 @@ h3 .section-text {
}
.word.space-after { margin-right: 0.5em; }
.word.no-chord { align-self: flex-end; }
.chord {
font-weight: 600;
margin-right: 0.5em;
white-space: nowrap;
}
.chord .flavor {
font-variant-position: super;
}
.song-order h3 {
font-style: italic;
font-weight: normal;
}
.song-order li {
list-style: none;
margin-left: 1em;
}
@media screen {
body { margin: 1em; }
}
@media print {
.page-contents { column-count: 2; }
}
</style>
"""
const LARGE_PRINT_STYLESHEET* = """
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html {
font-family: sans-serif;
font-size: 1.5em;
}
.page-contents {
column-width: 336px;
column-width: 3.5in;
}
.column-break { margin-bottom: auto; }
h2 { font-size: 1.25em; }
section {
break-inside: avoid;
padding-top: 1em;
}
h3 {
font-size: 1.125rem;
margin-bottom: 0.5em;
text-decoration: underline;
}
h3 .section-text {
font-style: italic;
font-size: 1em;
font-weight: normal;
margin: 0 0.5em;
}
.line {
display: flex;
flex-direction: row;
align-items: baseline;
margin-left: 0.5em;
margin-bottom: 0.5em;
}
.word {
display: flex;
flex-direction: column;
align-items: flex-start;
}
.word.space-after { margin-right: 0.5em; }
.word.no-chord { align-self: flex-end; }
.lyric {
font-weight: 600;
}
.chord {
font-style: italic;
font-weight: 500;
margin-right: 0.5em;
}
.chord .flavor {
@@ -191,6 +285,7 @@ proc toHtml(ctx: var FormatContext, node: ChordChartNode, indent: string): strin
result &= "<span class='word"
#if node.spaceBefore: result&=" space-before"
if node.spaceAfter: result&=" space-after"
if node.chord.isNone: result&=" no-chord"
result &= "'>"
if node.chord.isSome:
@@ -254,7 +349,7 @@ proc toHtml*(
result = """<!doctype html>
<html>
<head>
<title>""" & cc.metadata.title & "</title>\p"
<title>""" & cc.metadata.title & "" & $ctx.currentKey & "</title>\p"
for ss in stylesheets:
if ss.startsWith("<style>"): result &= ss