Skip to content

KyleDickersonComposer/lilypond-svg-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LilyPond to SVG Music Notation in HTML

This guide explains how to generate music notation using LilyPond, export it as SVG, and display it in an HTML file.

1. Install LilyPond

Install Lilypond using a package manager.

MacOS:

brew install lilypond

2. Create a LilyPond File

Create a new file called notation.ly and add the following content:

\version "2.24.0"
\relative c' {
  \key c \major
  \time 4/4
  c d e f | g a b c
}

3. Generate an SVG File

Run the following command in your terminal to generate an SVG file:

lilypond --svg notation.ly

Create a pdf by passing --pdf instead.

This will output a file called notation.svg in the same directory.

4. Display the SVG in HTML

Create an index.html file and include the SVG:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Music Notation</title>
</head>
<body>
    <h1>LilyPond Notation</h1>
    <img src="notation.svg" alt="Generated Music Notation">
</body>
</html>

5. Run a Local Server (Optional)

To view the file in a browser without CORS issues, start a simple local server:

python3 -m http.server 8000

Then, open http://localhost:8000/index.html in your browser.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published