Skip to content

Conversation

@phensley
Copy link
Contributor

Proposal from Joe Wanko:

JSON-T Formatter Spec: line-breaks
Arguments: None - operates on the input string directly
Behavior: Converts newline characters ("\n") to HTML line break tags (<br/>).

Rationale: This formatter addresses the HTML whitespace collapsing issue where newlines in text content get compressed into single spaces. Converting \n to
ensures line breaks render correctly in HTML.

Edge Cases: Multiple consecutive newlines: Each "\n" becomes a <br/> (e.g., "\n\n" → <br/><br/>)
Empty string: Returns empty string
No newlines: Returns string unchanged

Input: "Line 1\nLine 2\nLine 3"
Output: "Line 1<br/>Line 2<br/>Line 3"

Usage Example

{quote | line-breaks}

@phensley phensley merged commit b4acc3d into main Jan 26, 2026
6 checks passed
@phensley
Copy link
Contributor Author

@joewanko This change is released in version 2.11.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants