RFC-002: Text Formatting Strategy
RFC 002: Text Formatting Strategy
Section titled “RFC 002: Text Formatting Strategy”Status: Implemented Date: 2026-01-26 Topics: Syntax, Formatting, Standard Library
Objective
Section titled “Objective”Define a strategy for handling character-level and block-level text formatting (e.g., bold, italics, lists, paragraphs) within the Vyasa language.
Context
Section titled “Context”Vyasa currently focuses on semantic structure (chapter, verse, translation, purport). However, users often need to structure text within these blocks (e.g., emphasizing a word in a purport, or creating a list of points).
Alternatives
Section titled “Alternatives”Option A: Embedded Markdown
Section titled “Option A: Embedded Markdown”Allow users to write Markdown syntax directly within Vyasa text blocks.
Prerequisites:
- Templates must route text content through a Markdown parser (e.g.,
markdown-itlogic invyasacor in the template engine).
Pros:
- Familiar syntax for users (
**bold**,*italics*, etc.). - Robust tooling ecosystem.
- Clean and concise.
Cons:
- Increases compiler complexity (managing two grammars).
- Potential syntax conflicts (e.g., brackets
[]used by both). - “Black box” chunks of text that Vyasa logic cannot easily inspect or transform.
Option B: Native Vyasa Commands (Proposed)
Section titled “Option B: Native Vyasa Commands (Proposed)”Introduce a “Standard Formatting Library” of commands that act as semantic markers for formatting.
Syntax (Refined Proposal):
We propose using Explicit Semantic Commands with optional shorthands (aliases) for brevity. This avoids cryptic names while allowing efficiency for power users.
-
Emphasis:
emphasis { level=1 } [text](Primary, bold)emphasis { level=2 } [text](Secondary, italics)- Aliases:
e1->emphasis { level=1 },e2->emphasis { level=2 }
-
Breaks:
break { type="line" }(Manual line break)break { type="column" }(Column break)break { type="page" }(Page break)- Aliases:
br,col-break,pg-break - Note: These are presentational breaks. They do not interrupt the semantic flow of content (e.g., a
referencestream). Achaptercommand creates a structural boundary; abreak { type="page" }merely suggests where a page might end in print. - Best Practice: Use explicit
`brcommands for line breaks within text blocks (like purports) instead of relying on double newlines. This ensures consistent rendering across different templates and output formats.
-
Lists:
`list[`item[Point 1]`item[Point 2]]- Note: We recommend requiring explicit
`item(or aliased as-) commands. This avoids ambiguity for multi-line items.
- Note: We recommend requiring explicit
Analysis of Command Mingling:
- Drawback: Visual noise. Mixing
chapter(structural) withe1(inline) in the same backtick syntax might be visually dense. - Mitigation:
- Structural commands (
chapter,verse,reference) are typically block-level. - Formatting commands (
e1,br) are inline. - Good syntax highlighting in editors will help distinguish them.
- Structural commands (
- Benefit: Uniform parsing logic. The compiler doesn’t need to know “this is formatting” vs “this is structure”; it just builds the AST. The template decides how to render it.
Recommendation
Section titled “Recommendation”Pursue Option B (Native Commands).
Rationale:
- Semantic Integrity: Vyasa’s core value is semantic enrichment. Mixing in “dumb” formatting syntax (Markdown) dilutes the purity of the AST.
- Extensibility: Native commands can carry attributes.
list { type="ordered" } [ ... ]is natural in Vyasa. - Control: We define exactly how these render in the templates, rather than relying on a generic Markdown-to-HTML implementation.
Implementation Steps
Section titled “Implementation Steps”- Define the standard formatting library (names and arguments).
- Update
vyasacto handle these (if special parsing is needed beyond standard command parsing). - Update the default templates to render these commands (e.g., map
node.Command.cmd == "e1"to<strong>or<b>).