
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
plaintext-song-parser
Advanced tools
Allows you to parse plaintext lyrics file contents into a Javascript object
Allows you to parse plaintext lyrics file contents into a Javascript object
npm install plaintext-song-parser
npm install https://github.com/Miniontoby/plaintext-song-parser.js
<script src="https://cdn.jsdelivr.net/npm/plaintext-song-parser/dist/plaintext-song-parser.min.js"></script>
This package ships in three types. Select your way for importing it:
require):
const Song = require('plaintext-song-parser');
"type": "module"):
import Song from 'plaintext-song-parser';
window.SongAfter you imported the Song class, you can start using it:
const content = `<GET YOUR CONTENT FROM SOMEWHERE>`;
const song = new Song(content);
console.log(song.couplets);
new Song(content: string[]|string, identifier: number|string|null = null, title: string|null = null)
Makes a new Song object and processes the supplied content.
You can supply an identifier in order to keep track of which Song is which
And if you really need to, you can also supply an title, but this will also be parsed from the first line of the content if it starts with #Song.content: string
Returns the content you suppliedSong.identifier: number|string|null
Returns the identifier you suppliedSong.title: string|null
Returns the title you supplied or the title that was parsedSong.coupletsWithReferences: string[][]
Returns an array containing an array of strings which is the parsed lyrics.
This includes the references and can be seen as plain parsingSong.couplets: string[][]
Returns the same as Song.coupletsWithReferences, but the references are replaced by the lyrics connected to that reference.
This is the recommended property to use.Song.modifiers: {any}
Returns the modifiers that had been detected, such as titlestatic Song.getTitleFromText(content: string[]|string)
Returns the title from the text
This will just run static Song.getModifiersFromText(content) and then return the .title field or null
If no title can be found, it will return null, so if you always need an string, just add ?? '' after the method...static Song.getModifiersFromText(content: string[]|string)
Returns the modifiers from the text
This will be parsed from the first lines of the content if it starts with #
If no comments can be found, it will return {}.
This is the place where you would find the title.For parsing the songs, you need to supply the songtext into the content parameter when creating the Song object
The format for the content parameter/the songfile, is the following:
# Put your title on the first line after an '#'
Here is the first line of your song
And here is the second line
This is a new paragraph
and this line belongs to it
If you have paragraphs that
need to be split up, just add a
[split]
and this paragraph will
belong to the same couplet
Refrain:
^^ this will create a reference
that this paragraph is named 'Refrain'
It may not include spaces!
[split]
You can also split these up
into multiple parts
[split]
And you would name them if you want
to reuse these lines of the song later.
If you want to sing this again, just add
(Refrain)
and if you need to repeat
that paragraph more than once
just add the amount and an x
after the name of the reference
(Refrain 2x)
Well,
Since the beginning of 2023 I started working on SongTextProjector, which is a songtext presentation software/website/app. For that I wanted it to be as easy as it could be to make new song files and to edit them during usage of the app, so I wanted to use plain .txt files for the songs, so you could edit them using your favorite editor.
In the begining, I made a working, but bad first Song class, but it lacked a lot of parsing extra stuff. Then when I was at school and I had to do a little research project, I decided to do it about parsing songs. In the project I did three steps: Finding the best place where to get songs from, finding the most used keywords/format in songs, and making a song parser.
The document (in Dutch) is inside of this repository for you to read it if you want. (see the extra_stuff folder)
I might translate it into English if people want to read it.
And for the record, I got an 7.2 out of 10 as grade for the research project.
This package/class is the result of that last step.
FAQs
Allows you to parse plaintext lyrics file contents into a Javascript object
The npm package plaintext-song-parser receives a total of 1 weekly downloads. As such, plaintext-song-parser popularity was classified as not popular.
We found that plaintext-song-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.