mirror of
https://github.com/kennethreitz/rhymepad.org.git
synced 2026-06-11 17:08:33 +00:00
( lines are lyrics, not ignored annotations
Only # and [ lines are skipped now; full-line parentheticals are real lyrics (MF DOOM's whole style) and get analyzed, sid'd, and rhymed. Inline-paren ad-lib handling (rhyme internally, never claim the end slot) is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -527,7 +527,7 @@ def analyze(draft: Draft):
|
||||
sids.append(None)
|
||||
prev_blank = True
|
||||
continue
|
||||
if stripped[0] in "#([":
|
||||
if stripped[0] in "#[":
|
||||
# annotation line ([Chorus], (yeah), # notes) — no highlighting,
|
||||
# no scheme letter, and it doesn't split the stanza either
|
||||
sids.append(None)
|
||||
|
||||
+2
-2
@@ -675,7 +675,7 @@ function render(){
|
||||
h += `<span class="hseg"${tk}${dg} style="${style}">${text}</span>`;
|
||||
}
|
||||
}
|
||||
const lcls = 'lmark' + (/^\s*#/.test(line) ? ' hdr' : /^\s*[([]/.test(line) ? ' anno' : '');
|
||||
const lcls = 'lmark' + (/^\s*#/.test(line) ? ' hdr' : /^\s*\[/.test(line) ? ' anno' : '');
|
||||
html += (line ? `<span class="${lcls}" data-l="${i}">${h}</span>` : '') + '\n';
|
||||
});
|
||||
highlight.innerHTML = html;
|
||||
@@ -1117,7 +1117,7 @@ document.getElementById('exportBtn').addEventListener('click', async ()=>{
|
||||
});
|
||||
|
||||
// 2) base text (ink, or dim for headers/annotations)
|
||||
const isHdr = /^\s*#/.test(line), isAnno = /^\s*[([]/.test(line);
|
||||
const isHdr = /^\s*#/.test(line), isAnno = /^\s*\[/.test(line);
|
||||
x.font = isHdr ? '700 ' + font : font;
|
||||
x.fillStyle = isHdr ? '#8a7d6c' : isAnno ? '#6a5f52' : ink;
|
||||
x.fillText(line, PAD, y);
|
||||
|
||||
@@ -267,23 +267,28 @@ def test_weak_phrase_attaches_but_never_founds():
|
||||
assert "were up" not in highlighted("it were up to him\nit were up to her")
|
||||
|
||||
|
||||
def test_annotation_lines_ignored():
|
||||
def test_bracket_and_hash_lines_ignored():
|
||||
text = ("[Chorus]\n"
|
||||
"the cat\n"
|
||||
"a hat\n"
|
||||
"# note: tighten this verse\n"
|
||||
"(yeah)\n"
|
||||
"so blue\n"
|
||||
"so true")
|
||||
res = analyze(Draft(text=text))
|
||||
assert "chorus" not in highlighted(text)
|
||||
assert "note" not in highlighted(text)
|
||||
# annotations don't split the stanza or earn scheme letters
|
||||
# [ and # lines don't split the stanza or earn scheme letters
|
||||
(st,) = res["stanzas"]
|
||||
assert st["lines"] == [1, 2, 5, 6]
|
||||
assert st["lines"] == [1, 2, 4, 5]
|
||||
assert st["scheme"] == "aabb"
|
||||
|
||||
|
||||
def test_paren_lines_are_lyrics():
|
||||
# ( lines are real lyrics now (MF DOOM style), not ignored ad-libs
|
||||
text = "the city bright tonight\n(shining all the light)"
|
||||
group_with(text, "tonight", "light")
|
||||
|
||||
|
||||
def test_perfect_subgroup_fuses_with_slant_family():
|
||||
# shoulder/older/colder (perfect, OW L D ER) live inside the bigger
|
||||
# OW-schwa family — one color for the whole column
|
||||
|
||||
Reference in New Issue
Block a user