Adding special preparser for /b chords
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { get_chord_sheet_html } from "./Editor.js";
|
||||
import { get_chord_sheet_html } from "./Editor";
|
||||
|
||||
window.onload = () => {
|
||||
const chord_sheet_html = get_chord_sheet_html(`
|
||||
|
||||
@@ -48,13 +48,11 @@ function render_sheet_html(sheet: Sheet, renderChord:any): string {
|
||||
}
|
||||
|
||||
function render_chord(chord: Chord, renderer:any): string {
|
||||
return "<span class='chord' style='cursor: pointer;'>" + renderer(chord) + "</span>"
|
||||
return "<span class='chord'>" + renderer(chord) + "</span>"
|
||||
}
|
||||
|
||||
|
||||
|
||||
export function get_chord_sheet_html(normalized_txt: string): string {
|
||||
const parseChord = chordParserFactory();
|
||||
const parseChord = chordParserFactory( { customFilters : []} );
|
||||
const renderChord = chordRendererFactory({ useShortNamings: true });
|
||||
|
||||
const lines = normalized_txt.split("\n")
|
||||
@@ -65,11 +63,18 @@ export function get_chord_sheet_html(normalized_txt: string): string {
|
||||
let sheet_line = new Line();
|
||||
if (words.length > 1 || words[0] == '') {
|
||||
let space_before_chord = 0;
|
||||
for (const word of words) {
|
||||
for (let word of words) {
|
||||
if (word != '') {
|
||||
if (space_before_chord > 0 || sheet_line.chords.length > 0) {
|
||||
space_before_chord++;
|
||||
}
|
||||
//preprocessing for special slash notation
|
||||
if (word.indexOf('/') > -1) {
|
||||
const parts = word.split('/')
|
||||
if (/^(b|#)\d+$/.test(parts[1])) {
|
||||
word = parts[0] + "(" + parts[1] + ")"
|
||||
}
|
||||
}
|
||||
const chord = parseChord(word);
|
||||
if (chord.error) {
|
||||
sheet_line.lyrics = line;
|
||||
Reference in New Issue
Block a user