Get started with the manifest-driven content generator in 5 minutes.
Extracts content from markdown files based on patterns and inserts it into templates.
Example: Extract all objectives from all modules and put them in a website document.
cd tools/content-generator
npm installThe example configuration is already set up for you:
node manifest-generator.js --validateYou should see:
✓ Validation passed
Documents: 1
Extractions: 2
Warnings: 0
node manifest-generator.jsThis creates output/website.md with extracted objectives and topics from the guide template.
cat output/website.mdYou'll see objectives and topics extracted from the source guide and inserted into the template.
Defines what to extract and where to put it:
primary_source: "../merge-markdown/merged/guide/Guide Template.md"
documents:
output/website.md:
template: website.md
extractions:
objectives:
pattern: "#### Objectives" # Find this heading
scope: bullets # Collect bullets until next heading
topics:
pattern: "## " # Find any H2 heading
scope: self_plain # Collect just the heading textContains placeholders where content will be inserted:
## Objectives
//Generated by content-generator
//objectives
## Topics
//Generated by content-generator
//topicsThe generator:
- Finds all instances of
"#### Objectives"in the source - Collects all bullets from each until the next heading
- Combines them into one list
- Replaces
//objectivesplaceholder with the list
Same process for topics!
modules:
pattern: "# Module"
scope: self_plainprerequisites:
pattern: "## Prerequisites"
scope: bulletsintro:
pattern: "## Introduction"
scope: textcode:
pattern: "## Example"
scope: code| Scope | What It Collects | Example Use |
|---|---|---|
self |
Just the matched line | Headings with formatting |
self_plain |
Matched line, no formatting | Clean heading text |
bullets |
All bullets until next heading | Objectives, prerequisites |
text |
Paragraph text | Descriptions, intros |
code |
Code blocks | Examples |
all |
Everything | Complete sections |
Add _plain to any scope to strip markdown formatting.
- Read the full docs: MANIFEST_README.md
- Explore scope types: SCOPE_TYPES.md
- Understand validation: VALIDATION.md
- Modify manifest.yml to extract different content
- Create your own templates for different output formats
Problem: No content extracted
Solution:
- Check that pattern matches lines in source (case-sensitive!)
- Verify scope type is correct (bullets for lists, text for paragraphs)
Problem: Content not inserted in template
Solution:
- Ensure placeholder key matches extraction key exactly
- Use proper two-line format:
//Generated by content-generatorthen//key
Problem: Wrong content extracted
Solution:
- Make pattern more specific (e.g.,
"## Activity"instead of"## ") - Collection stops at ANY heading - this might include sub-sections
See the output/ directory for generated examples:
website.md- Course metadata with objectives and topics- (Add more as you create them)
- Test with
--validatebefore generating to catch errors - Start simple - one extraction, one template
- Pattern specificity - more specific patterns = more control
- Use primary_source for documents that share the same source
- Check the output - verify extracted content is what you expect
- Validation errors? Check VALIDATION.md
- Scope confusion? See SCOPE_TYPES.md
- Complex setup? Read MANIFEST_README.md
Try creating a new document:
- Create a template file with placeholders
- Add it to
manifest.ymlunderdocuments: - Define your extractions
- Run
node manifest-generator.js --validate - Run
node manifest-generator.js - Check your output!
Happy generating! 🎉