# Command Log — Storytelling: Course Notes 3.2 Conversion
**Source:** AlanMoore_Storytelling_BBCMaestro_CourseNotes-1.pdf
**Date:** 2026-03-22

---

## PDF Inspection

```bash
# Get PDF metadata
pdfinfo AlanMoore_Storytelling_BBCMaestro_CourseNotes-1.pdf
# CreationDate: Thu Oct 30 12:04:51 2025

# List all images with dimensions and type
pdfimages -list AlanMoore_Storytelling_BBCMaestro_CourseNotes-1.pdf
# Full-bleed photos: ~808×1109px, jpeg, icc color, ~80–120K
# Decorative icons: ~189×181px, indexed — ignored

# Extract full text with layout
pdftotext -layout AlanMoore_Storytelling_BBCMaestro_CourseNotes-1.pdf /tmp/storytelling-full.txt

# Extract text by page range
pdftotext -layout -f 5  -l 10 [pdf] /tmp/part1.txt   # Part One
pdftotext -layout -f 11 -l 19 [pdf] /tmp/part2.txt   # Part Two
pdftotext -layout -f 20 -l 26 [pdf] /tmp/part3.txt   # Part Three
pdftotext -layout -f 27 -l 35 [pdf] /tmp/part4.txt   # Part Four
pdftotext -layout -f 36 -l 43 [pdf] /tmp/part5.txt   # Part Five
pdftotext -layout -f 44 -l 51 [pdf] /tmp/part6.txt   # Part Six
```

---

## Image Extraction

```bash
# Extract full-bleed JPEG from each part opener page
pdfimages -f 1  -l 1  -j [pdf] /tmp/img-p1  && cp /tmp/img-p1-000.jpg  images/cover.jpg
pdfimages -f 3  -l 3  -j [pdf] /tmp/img-p3  && cp /tmp/img-p3-000.jpg  images/introduction-alan-moore.jpg
pdfimages -f 4  -l 4  -j [pdf] /tmp/img-p4  && cp /tmp/img-p4-000.jpg  images/introduction-part-one-preview.jpg
pdfimages -f 11 -l 11 -j [pdf] /tmp/img-p11 && cp /tmp/img-p11-000.jpg images/part-2-opener.jpg
pdfimages -f 19 -l 19 -j [pdf] /tmp/img-p19 && cp /tmp/img-p19-000.jpg images/part-2-part-three-preview.jpg
pdfimages -f 27 -l 27 -j [pdf] /tmp/img-p27 && cp /tmp/img-p27-000.jpg images/part-4-opener.jpg
pdfimages -f 36 -l 36 -j [pdf] /tmp/img-p36 && cp /tmp/img-p36-000.jpg images/part-5-opener.jpg
pdfimages -f 44 -l 44 -j [pdf] /tmp/img-p44 && cp /tmp/img-p44-000.jpg images/part-6-opener.jpg
pdfimages -f 50 -l 50 -j [pdf] /tmp/img-p50 && cp /tmp/img-p50-000.jpg images/part-6-extroduction.jpg

# Resize all images to 50%
mogrify -resize 50% images/*.jpg
```

---

## Combine Markdown Files

```bash
# Concatenate all storytelling markdown files in alphabetical order
cat storytelling-h1-header.md \
    storytelling-h2-toc.md \
    storytelling-introduction.md \
    storytelling-part-1.md \
    storytelling-part-2.md \
    storytelling-part-3.md \
    storytelling-part-4.md \
    storytelling-part-5.md \
    storytelling-part-6.md \
    > storytelling-course-notes.md
```

---

## EPUB Conversion

```bash
pandoc storytelling-course-notes.md \
  -o storytelling-course-notes.epub \
  --epub-cover-image=images/cover.jpg \
  --metadata title="Storytelling: Course Notes 3.2" \
  --metadata author="Alan Moore"
```

---

## EPUB Link Verification

```bash
# Unzip EPUB and check for broken internal links
unzip -o storytelling-course-notes.epub -d /tmp/epub-check

# Extract all anchor IDs defined in the document
grep -o 'id="[^"]*"' /tmp/epub-check/EPUB/text/ch001.xhtml

# Extract all hrefs used in TOC links
grep -oP 'href="#[^"]*"' /tmp/epub-check/EPUB/text/ch001.xhtml

# Diff hrefs against ids — empty output = no broken links
comm -23 \
  <(sed 's/href="#//;s/"//' hrefs.txt | sort) \
  <(sed 's/id="//;s/"//'   ids.txt  | sort)
# Result: (no output — all links resolved)
```

---

## Issues Found and Fixed

### 1. Obsidian links not recognised by pandoc
Obsidian `[[#Heading|Display]]` syntax renders as literal text in pandoc.
**Fix:** Convert to standard markdown `[Display](#pandoc-id)`.

### 2. Part One and Part Three headings absorbed into blockquote
Missing blank line between closing `>` blockquote and `## Part N` heading caused pandoc to include the heading text inside the blockquote paragraph.
**Fix:** Add blank line after blockquote before each affected heading.

```markdown
# Before (broken)
> This first section is concerned with the origins of writing...
## Part One ~ Origins

# After (fixed)
> This first section is concerned with the origins of writing...

## Part One ~ Origins
```

### 3. Pandoc anchor ID mapping
Pandoc strips number prefixes and special characters from heading IDs.
Key mappings required for TOC links:

| Heading | Pandoc ID |
|---|---|
| `## 01. Introduction` | `#introduction` |
| `## Part One ~ Origins` | `#part-one-origins` |
| `## Part Two ~ Language` | `#part-two-language` |
| `## Part Three ~ Story` | `#part-three-story` |
| `## Part Four ~ Cast & Setting` | `#part-four-cast-setting` |
| `## Part Five ~ A Variety Of Forms` | `#part-five-a-variety-of-forms` |
| `## Part Six ~ Progressive Writing` | `#part-six-progressive-writing` |
| `### 09. Hemingway vs. Baudelaire ~ Who Would Win?` | `#hemingway-vs.-baudelaire-who-would-win` |
| `### 14. Mode` | `#mode` |
| `### 15. Time & Timing` | `#time-timing` |
| `### 25. Words, Music & Performance` | `#words-music-performance` |

---

## Copyright

© 2025 BBC Maestro. All rights reserved. www.bbcmaestro.com
