npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

parse-ditty

v1.1.0

Published

A markdown-like parser for lyrics and chords

Downloads

4

Readme

Travis – build status
David – status of dependencies
Code style: airbnb

ditty

Basically, it’s markdown for song lyrics and chords

 

In the wild

Let’s start with the exciting bits:

  • You can stuff the lyrics for a bunch of ditty songs on a well-designed PDF layout with git.io/ditty-to-pdf.
  • A great installable songbook web app is in the making at magnificat.surge.sh.
  • Even the raw source of ditty songs is usable enough to make a website out of it.

 

TL;DR

Ditty is a plain text syntax for lyrics and chords. It’s really natural to read and write.

Let’s start with a demo! Here's an example song written in ditty:

12 | Jak ożywczy deszcz
=======================

D     G              h      A
 Jak ożywczy deszcz – Duchu Święty przyjdź!

D        G             h       A
 Dotknij naszych serc – rozpal ognia żar!  /×2



        e               fis  e                fis
         Dziś przenikaj nas – tchnieniem mocy Swej.

        e                  fis    G          Fis
         Bądź nam światłem dnia – i nadzieją serc!  /×2

 

The syntax

ditty is quite a young format, in active development. Here are the rules we have so far:

  1. A ditty file should start with a title line.
  2. The title line may begin with a song number followed by the pipe character (|). The pipe may be preceded and followed by one or more spaces. We recommend one space before and one space afterwards.
  3. A song number is any combination of decimal digits (0-9) and dots (.). It should start and end with a digit. The shortest valid number is a single digit.
  4. The rest of the title line is the song title. It consists of one or more character other than a
  5. The title line should be followed by a title underline.
  6. The title underline consists of one or more equals signs (=). You can make it as long as the title line to make it stand out and look good.
  7. The title underline should be followed by one or more blank lines.
  8. The blank line under the title underline should be followed by one or more stanzas and/or refrains, separated from one another by two or more blank lines.
  9. Both a stanza and a refrain consists of one or more song lines separated from one another by exactly one blank line.
  10. A song line consists of one or two lines. If it’s one line, it’s parsed as the lyrics line. If it’s two lines, the first one is a chords line and the second is a lyrics line.
  11. A lyrics line can start with one or more spaces. We call this the indent. The line with the smallest indent in a block determines the type of the containing block. If it’s less than 4 spaces, the block is a stanza. Otherwise, it’s a refrain. The indent should be followed by one or more characters, the first of which should be a printable characters.
  12. A chords line consists of one or more sequences of printable characters. Make sure the beginning of the chord matches the beginning of the related syllable in the lyrics line.

We have to include a rather boring common-sense note. The format is based on characters, printable characters, lines and blank lines. A character is any Unicode character, excluding characters with an ASCII code lower than 32 (space) and the character at 127 (DEL). A printable character is a character other than a space. A line is a sequence of characters followed by an End Of Line character (\n), including the End Of Line character. The last character in a line before the End Of Line should be a printable character. A blank line consists of exactly one End Of Line character (\n).

Some things are reserved for future use. Please don’t use them yet:

  1. Characters other than the characters listed above – particularly the line feed character (\r) and the tab character (\t). For editing ditty files please use an editor which supports Unix-style line endings (not Microsoft Notepad).
  2. Trailing spaces (spaces at the end of a line).
  3. A line consisting of no other characters than a space ( ), a hyphen-minus (-), an asterisk (*), a hash (#) and an underscore (_).

 

Helpful hints

Some things we recommend:

  • Make sure the name of every ditty file ends with the extension .ditty.
  • Set up syntax highlighting in your editor so that it displays *.ditty files as markdown.

 

The parser

This repo comes with a simple parser. Install it on node v4.0+ with:

npm install parse-ditty

Here’s the output for the above song:

▸ const ditty = require('parse-ditty');

▸ ditty(inputSameAsAbove);
◂ {
    number: '12',
    title: 'Jak ożywczy deszcz',
    blocks: [
      {
        type: 'stanza',
        lyrics:
`Jak ożywczy deszcz – Duchu Święty przyjdź!
Dotknij naszych serc – rozpal ognia żar!  /×2
`
      },
      {
        type: 'refrain',
        lyrics:
`Dziś przenikaj nas – tchnieniem mocy Swej.
Bądź nam światłem dnia – i nadzieją serc!  /×2
`
      },
    ],
  }

 

License

MIT © Tomek Wiszniewski