How-to
Website
Web app
Slides
Custom elements
Desktop / phone
Show code on a page
Code shows code: inline inside a sentence, or as a block, coloured by its language. This page mixes inline code into a sentence and shows two coloured blocks:
Needs: nothing besides the page. It claims /: paste it into a new project, or replace the starter's src/pages/Home.wf with it.
page Snippets(path: "/", title: "Snippets", description: "Code on the page.") {
Heading("Snippets").h1
Text("Run ") Code("wf serve") Text(" to start.")
Code("page Home(path: \"/\") {\n Text(\"Hi\")\n}", language: "wf").block
Code("$ wf build", language: "bash").block
}
How it works
Code("…")is inline code. Placed between twoTexts, it reads as part of the sentence.Code("…").blockis a block, for code over several lines.language:colours it —wf,json,bashorcss. The colouring is done at build time and in the browser alike, with the theme'ssyntax-*tokens, and aMarkdownfence in one of those languages is coloured the same way.