# Mermaid railroad diagram in Markdown to PDF

A grammar is drawn as railroad tracks: each rule is a track, with branches for choices and loops for repeats. This sample is written in ABNF, and EBNF and PEG work too.

Grammar rules drawn as tracks with choices, repeats and optional parts, written in ABNF, for the booking reference format of a ferry company.

- PDF: https://legivel.com/examples/mermaid-diagrams/railroad-diagram.pdf
- Page: https://legivel.com/examples/mermaid-diagrams/railroad-diagram
- Open in the editor: https://legivel.com/markdown-to-pdf?sample=mermaid-railroad
- More mermaid diagrams in Markdown to PDF: https://legivel.com/examples/mermaid-diagrams

## Markdown source

````markdown
---
title: Booking reference format
author: Ferry reservations
---

# Booking reference format

A ferry company in Greece prints a booking reference on every ticket. The grammar below is the one the ticket scanners accept.

```mermaid
railroad-abnf
    title Booking reference
    reference = route "-" date "-" serial ;
    route = 3ALPHA ;
    date = 6DIGIT ;
    serial = 4*6( ALPHA / DIGIT ) ;
```

Example: PIR-250614-K7Q2X is a sailing from Piraeus on 14 June 2025.
````
