TableauExcerptExtension is a Tableau extension that extracts excerpts from posts for use in index pages and feeds.
Core Principle
If a post already has an excerpt field, it is unmodified. Otherwise, the
extension extracts an excerpt using one of three methods (in order of
precedence):
- Range markers - Content between
<!--excerpt:start-->and<!--excerpt:end--> - Split marker - Content before
<!--more--> - Structural extraction - First paragraph(s), sentence(s), or word(s) based on text structure
Configuration
# config/config.exs
config :tableau, TableauExcerptExtension,
enabled: true,
range: %{
start: "<!--\\s*excerpt:start\\s*-->",
end: "<!--\\s*excerpt:end\\s*-->",
remove: false
},
marker: %{
pattern: "<!--\\s*more\\s*-->",
remove: true
},
fallback: %{
strategy: :paragraph,
count: 1,
more: "…"
},
processors: [
md: TableauExcerptExtension.Processor.Markdown
]Required Configuration
:enabled(defaultfalse) - Enable/disable the extension
Optional Configuration
:range- Range marker configuration (set tofalseto disable):start(default"<!--\\s*excerpt:start\\s*-->") - Start marker pattern:end(default"<!--\\s*excerpt:end\\s*-->") - End marker pattern:remove(defaultfalse) - Remove markers from post body
:marker- Split marker configuration (set tofalseto disable):pattern(default"<!--\\s*more\\s*-->") - Regex pattern string:remove(defaulttrue) - Remove marker from post body
:fallback- Structural extraction strategy (set tofalseto disable):strategy(default:paragraph) -:paragraph,:sentence, or:word:count- Number of units to extract (defaults vary by strategy):more(default"…") - Suffix for truncated word excerpts
:processors- Format-specific processors (keyword list or map)- Default:
[md: TableauExcerptExtension.Processor.Markdown] - Processors handle paragraph filtering and content cleaning
- Unknown formats use
TableauExcerptExtension.Processor.Passthrough
- Default:
Decision Guide: When to Use What
Choose Your Extraction Method
Use range markers when:
- Need precise control over excerpt content
- Excerpt should come from middle of post
- Want different content than opening paragraphs
- Example: Pull a key quote or summary section
Use split marker when:
- Natural break point in content
- Excerpt is always the opening section
- Compatible with other static site generators
- Most common manual approach
Use structural extraction when:
- Consistent automatic excerpts needed
- No manual marker management
- Opening content works as excerpt
- Fallback for posts without markers
Choose Your Range Marker Pattern
Use default <!--excerpt:start--> / <!--excerpt:end--> when:
- Standard HTML comment markers are sufficient
- Clear, explicit marker names
- No conflicts with existing content
Use custom patterns when:
- Different marker convention in existing content
- Need shorter or different marker names
- Example:
<!--begin-->/<!--end-->
Set to false when:
- Not using range markers
- Only using split marker or structural extraction
Choose Your Split Marker Pattern
Use default "<!--\\s*more\\s*-->" when:
- Standard HTML comment marker is sufficient
- Compatibility with other static site generators
- Simple, recognizable marker
Use custom pattern when:
- Different marker convention in existing content
- Need multiple marker variations
- Example:
"<!--\\s*(more|excerpt|break)\\s*-->"
Set to false when:
- No manual split markers in content
- Only using range markers or structural extraction
- Split marker detection not needed
Choose Your Structural Extraction Strategy
Use :paragraph (default) when:
- Content has clear paragraph structure
- Want complete thoughts in excerpts
- Most common use case
Use :sentence when:
- Paragraphs are too long
- Want more control over excerpt length
- Need consistent excerpt sizes
Use :word when:
- Need precise length control
- Character/word limits required
- Excerpts for cards or previews with strict sizing
Set to false when:
- All posts have manual markers (range or split)
- No automatic extraction needed
- Explicit excerpts only
Choose Your Count
For :paragraph strategy:
count: 1(default) - Single opening paragraphcount: 2- Opening and second paragraph- Higher counts rarely needed
For :sentence strategy:
count: 2(default) - Two sentencescount: 1- Single sentence (very brief)count: 3-4- Longer excerpts
For :word strategy:
count: 25(default) - Brief excerptcount: 50-75- Medium excerptcount: 100+- Long excerpt
Common Configuration Patterns
Range Markers Only
config :tableau, TableauExcerptExtension,
enabled: true,
range: %{
start: "<!--\\s*excerpt:start\\s*-->",
end: "<!--\\s*excerpt:end\\s*-->",
remove: false
},
marker: false,
fallback: falseSplit Marker Only
config :tableau, TableauExcerptExtension,
enabled: true,
range: false,
marker: %{
pattern: "<!--\\s*more\\s*-->",
remove: true
},
fallback: falseStructural Extraction Only
config :tableau, TableauExcerptExtension,
enabled: true,
range: false,
marker: false,
fallback: %{
strategy: :paragraph,
count: 1
}Custom Split Marker with Structural Extraction
config :tableau, TableauExcerptExtension,
enabled: true,
marker: %{
pattern: "<!--\\s*(more|excerpt)\\s*-->",
remove: true
},
fallback: %{
strategy: :sentence,
count: 2
}Word-Based Structural Extraction
config :tableau, TableauExcerptExtension,
enabled: true,
range: false,
marker: false,
fallback: %{
strategy: :word,
count: 50,
more: "…"
}Keep Split Marker in Body
config :tableau, TableauExcerptExtension,
enabled: true,
marker: %{
pattern: "<!--\\s*more\\s*-->",
remove: false
},
fallback: %{
strategy: :paragraph,
count: 1
}Format Processing
Excerpts are processed by format-specific processors. For Markdown (.md files):
- Structural extraction filtering - Headings and horizontal rules excluded from paragraph detection
- Footnotes removed - Both references
[^1]and definitions[^1]: text - Reference links converted -
[text][ref]becomes[text](url)
Unknown formats use the Passthrough processor (no filtering or cleaning).
Rendering Excerpts
Excerpts are stored in the same format as the source and must be rendered with
the appropriate converter (e.g., Tableau.markdown/1 for Markdown excerpts).
See the Basic Usage guide for rendering examples and the Deduplicating Rendered Elements guide for handling duplicate scripts/styles when rendering multiple excerpts.
Common Gotchas
All extraction methods disabled - Setting
:range,:marker, and:fallbackall tofalselogs a warning and disables the extension.Pattern is string - The
:patternand:start/:endvalues are strings that get compiled to Regex, not Regex literals.Marker removal affects body - When
:removeistrue, the post:bodyfield is updated to remove the marker(s).Range marker removal default - Range markers default to
:removebeingfalse(kept in body), while split marker defaults totrue(removed).Count defaults vary - When using structural extraction, the default
:countdepends on:strategy::paragraph→ 1:sentence→ 2:word→ 25
Word truncation mid-sentence - When using
:wordstrategy, the:morestring is only appended if truncation happens mid-sentence (no ending punctuation).Paragraph detection - Paragraphs are split on double newlines (
\n\n+). Single newlines within paragraphs are preserved.
Resources
- Hex Package - Package on Hex.pm
- HexDocs - Complete API documentation
- GitHub Repository - Source code
- Tableau - Static site generator
- Tableau PostExtension - Post processing extension