ChordSheetJS icon indicating copy to clipboard operation
ChordSheetJS copied to clipboard

HtmlDivFormatter behaves differently than HtmlTableFormatter

Open beltonk opened this issue 1 year ago • 4 comments

I recently switched from HtmlTableFormatter to HtmlDivFormatter, and seems there are some logical different, e.g. sot in HtmlDivFormatter renders .lyrics but not .literals? I'm not sure about other difference, just feel some nuances.

beltonk avatar May 20 '24 18:05 beltonk

seems comment directives not rendered as well.

beltonk avatar May 21 '24 19:05 beltonk

Hey @beltonk. What chord sheet and ChordSheetJS are you using?

I ran a small test:

import { ChordProParser, HtmlDivFormatter } from "https://esm.sh/chordsheetjs";

const chordProTestSong = `
{sot}
One
Two
Three
{eot}`;

const song = new ChordProParser().parse(chordProTestSong);
const output = new HtmlDivFormatter().format(song);
console.log(output);

The output is:

<div class='chord-sheet'>
  <div class='paragraph tab'>
    <div class='row'>
      <h3 class='label'>null</h3>
      <div class='literal'>
        One<br>
        Two<br>
        Three
      </div>
    </div>
  </div>
</div>

So it renders a .literal. I do spot a bug when rendering a null label.

martijnversluis avatar May 22 '24 19:05 martijnversluis

My fault... I assumed comment & literal are under columns, and mistakenly did some sanitization. Let me test again...

beltonk avatar May 26 '24 17:05 beltonk

I can reproduce the issue, whenever there is any other {c: }, {soc}, {sov} directives in the ChordPro, the tab will become lyrics lines instead of literal, no matter where these tags are.

For example,

const chordProTestSong = `
{sot}
One
Two
Three
{eot}
{c:Verse}
`;
const chordProTestSong = `
{c:Intro}
{sot}
One
Two
Three
{eot}
`;
const chordProTestSong = `
{sot}
One
Two
Three
{eot}
{sov}
...
{eov}
`;

Also tested {t:} {st:} has no effect on literal rendering

beltonk avatar May 27 '24 05:05 beltonk

@beltonk I published 10.2.0 containing a bugfix that should resolve your issue. Please let me know if it does the job 👍

martijnversluis avatar Aug 24 '24 19:08 martijnversluis