• Townie
    AI
  • Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
postpostscript

postpostscript

multiFormat

Public
Like
multiFormat
Home
Code
2
README.md
main.tsx
Branches
1
Pull requests
Remixes
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
Code
/
Search
README.md

multiFormat: easily create outputs of multiple formats (e.g. text/html for Email) using tagged templates

Examples

Create val
import { format } from "https://esm.town/v/postpostscript/multiFormat"; console.log(format.Plain` ${format.Heading1`Some Heading`} Lorem ipsum dolor ${format.Strong`sit`} amet `);
{ "text": "\nSome Heading\n\nLorem ipsum dolor sit amet\n", "html": "\n<br><h1>Some Heading</h1>\n<br>\n<br>Lorem ipsum dolor <strong>sit</strong> amet\n<br>" }

Create Your Own Formatters

Create val
import { createFormatMethod, wrapHTMLTag, type MultiFormatWithHTML } from "https://esm.town/v/postpostscript/multiFormat"; export const Red = createFormatMethod<MultiFormatWithHTML>((value) => { return wrapHTMLTag("span", value, { style: "color: red;", }); }); console.log(Red`red text!`)
{ "text": "red text!", "html": "<span style=\"color: red;\">red text!</span>" }

Sanitization

Text is automatically sanitized when converted to HTML:

Create val
console.log(format.Trim` ${format.Heading1`Some Heading`} <script>alert(1)</script> `.html.toString())
<h1>Some Heading</h1> <br> <br>&lt;script&gt;alert(1)&lt;/script&gt;

Migrated from folder: HTML/multiFormat

Code
README.mdmain.tsx
FeaturesVersion controlCode intelligenceCLI
Use cases
TeamsAI agentsSlackGTM
ExploreDocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.