diff --git a/src/App.ts b/src/App.ts index 888f63e..13df853 100644 --- a/src/App.ts +++ b/src/App.ts @@ -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(` diff --git a/src/Editor.js.ts b/src/Editor.ts similarity index 84% rename from src/Editor.js.ts rename to src/Editor.ts index c1c272a..3627476 100644 --- a/src/Editor.js.ts +++ b/src/Editor.ts @@ -48,13 +48,11 @@ function render_sheet_html(sheet: Sheet, renderChord:any): string { } function render_chord(chord: Chord, renderer:any): string { - return "" + renderer(chord) + "" + return "" + renderer(chord) + "" } - - 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;