From 8d678d9f4688266d12323b06fa23810731147bef Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 29 Jan 2021 12:42:22 -0400 Subject: let lyrics be specified w/o terrible
format --- upd8.js | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/upd8.js b/upd8.js index 94cb436..77e2a3d 100644 --- a/upd8.js +++ b/upd8.js @@ -571,7 +571,40 @@ function transformMultiline(text, treatAsDocument=false) { } return outLines.join('\n'); -}; +} + +function transformLyrics(text) { + // Different from transformMultiline 'cuz it joins multiple lines together + // with line 8reaks (
); transformMultiline treats each line as its own + // complete paragraph (or list, etc). + + // If it looks like old data, then like, oh god. + // Use the normal transformMultiline tool. + if (text.includes(' outLines.push(`

${buildLine}

`); + const outLines = []; + for (const line of text.split('\n')) { + if (line.length) { + if (buildLine.length) { + buildLine += '
'; + } + buildLine += line; + } else if (buildLine.length) { + addLine(); + buildLine = ''; + } + } + if (buildLine.length) { + addLine(); + } + return outLines.join('\n'); +} function getCommentaryField(lines) { const text = getMultilineField(lines, 'Commentary'); @@ -2174,7 +2207,7 @@ async function writeTrackPage(track) { ${track.lyrics && fixWS`

Lyrics:

- ${transformMultiline(track.lyrics)} + ${transformLyrics(track.lyrics)}
`} ${commentary && fixWS` -- cgit 1.3.0-6-gf8a5