Stub out HTML generation
This commit is contained in:
parent
ba3a3b5a26
commit
a6c5f3e431
2 changed files with 25 additions and 2 deletions
|
@ -1,3 +1,4 @@
|
|||
import { ALL as HTML } from './lib/html';
|
||||
import { parse } from './parser';
|
||||
import { runNoctl, Vm } from './vm';
|
||||
import { AsHtml } from './words';
|
||||
|
@ -52,7 +53,7 @@ let theCard: Card = {
|
|||
|
||||
[button "No we want to render UI" \\{noop}]
|
||||
} {
|
||||
Since we want escapes to work, these blocks [i will] be subject to substitutions.
|
||||
Since we want escapes to work, these blocks [i will] be subject to substitutions, maybe via a relaxed bareWordTmpl.
|
||||
}
|
||||
# A comment
|
||||
para {
|
||||
|
@ -84,7 +85,7 @@ const debugDisplay = document.createElement("pre");
|
|||
function render() {
|
||||
const vm: Vm = {
|
||||
mode: "render",
|
||||
commands: {},
|
||||
commands: { ...HTML },
|
||||
output: "",
|
||||
};
|
||||
const html = renderCard(vm, theCard.code);
|
||||
|
|
22
src/lib/html.ts
Normal file
22
src/lib/html.ts
Normal file
|
@ -0,0 +1,22 @@
|
|||
import { AsHtml, Concat, TextPiece } from '../words';
|
||||
|
||||
const htmlTagCmd =
|
||||
(tag: string) =>
|
||||
({}, argv: TextPiece[]): TextPiece => {
|
||||
const [, ...words] = argv;
|
||||
return (
|
||||
words
|
||||
.map((word) => ({ html: `<${tag}>${AsHtml(word)}</${tag}>` }))
|
||||
.reduce(Concat, null) ?? { html: "" }
|
||||
);
|
||||
};
|
||||
|
||||
export const h1 = htmlTagCmd("h1");
|
||||
export const para = htmlTagCmd("p");
|
||||
export const block = htmlTagCmd("blockquote");
|
||||
|
||||
export const ALL = {
|
||||
h1,
|
||||
para,
|
||||
block,
|
||||
};
|
Loading…
Reference in a new issue