cho2txt

Extract lyrics from chordpro files
git clone git://git.relim.de/cho2txt.git
Log | Files | Refs | README | LICENSE

commit 31ba6c906c5bf50af03c45482fe01642f953fc83
parent 20278755fc7e82f0fb599fd0fb989e4c8a4485b6
Author: nibo <kroekerrobin@gmail.com>
Date:   Wed, 19 Jun 2024 21:19:14 +0200

Ignore comments

Diffstat:
MREADME.md | 4++++
Mcho2txt.c | 11+++++++++++
2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/README.md b/README.md @@ -9,3 +9,7 @@ Then you have access to the command line program named `cho2txt`. Documentation is available via `man cho2txt`. <img src="https://github.com/devnibo/cho2txt/raw/master/cho2txt.gif" alt="example" /> + +## See Also + +[https://chordpro.org](https://chordpro.org) diff --git a/cho2txt.c b/cho2txt.c @@ -122,15 +122,23 @@ char *extractLyrics(int fd, enum print printTitle) int i = 0; int d = 0; char buf; + char prev_buf = '\n'; bool isLyric = true; bool isLyricInLine = false; bool isDirectiveInLine = false; bool isCurlyBrace = false; + bool isComment = false; char *directive = NULL; while (1) { if (read(fd, &buf, 1) == 1) { + if (buf == '#' && prev_buf == '\n') { + isComment = true; + } + if (isComment) { + goto SKIP; + } if (buf == '[') { isLyric = false; @@ -204,11 +212,14 @@ char *extractLyrics(int fd, enum print printTitle) } if (buf == ']') isLyric = true; + SKIP: if (buf == '\n') { + isComment = false; isDirectiveInLine = false; isLyricInLine = false; } + prev_buf = buf; } else break;