Formatters
TypographyFormatter
Trek::TypographyFormatter applies French typography rules to strings and ProseMirror documents (only text nodes are modified):
- non-breaking spaces before
: ; ! ? % € $ »and after«, dashes,n° - non-breaking spaces before units (km, kg, h, min, °C…) and between digit groups
...→…, ASCII apostrophes → typographic'- removes double spaces and spaces before periods/commas
Wire it to attributes with Formattable:
ruby
include Trek::Formattable
format_attributes Trek::TypographyFormatter, :titleProseMirror → HTML pipeline
formatted_content (from Contentable) renders ProseMirror JSON to safe HTML through the prosemirror_to_html gem, extended with:
| Piece | Role |
|---|---|
Nodes::ImageBlock | renders image_block nodes as figures (Shrine image, alt, caption, size) |
Nodes::PromptsBlock | renders prompts_block nodes as call-to-action buttons |
RemoveEmptyParagraphsFormatter | strips empty <p></p> tags |
GlobalIdToLinksFormatter | resolves gid:// references in links to real record URLs |
The pipeline is orchestrated by the Prosemirror model — extend it with your own node renderers when you add custom blocks to the editor.