import { readFileSync } from "fs";
import { resolve } from "path";
import { tokenize, toHTML } from "./html.js";
const gemtext = readFileSync(resolve("./example.gmi"), "utf-8");
test("--body", () => {
expect(toHTML(gemtext, { body: true })).toMatchInlineSnapshot(`
"
gmi-web
a bridge between HTML and Gemini
https://codeberg.org/talon/gmi-web
on NPM
line-types
gmi-web makes writing HTML documents as simple as learning the handful of Gemini line-types:
- paragraphs
- preformatted blocks
- lists
- quotes
- headings
if you are
familiar with markdown
it's kinda like that
but even simpler
inline media
video with title prop
image with title prop
audio with title prop
video-with-no-title.mp4
image-with-no-title.jpg
audio-with-no-title.mp3"
`);
expect(toHTML(gemtext, { body: true, css: "none" })).toMatchInlineSnapshot(`
"gmi-web
a bridge between HTML and Gemini
https://codeberg.org/talon/gmi-web
on NPM
line-types
gmi-web makes writing HTML documents as simple as learning the handful of Gemini line-types:
- paragraphs
- preformatted blocks
- lists
- quotes
- headings
if you are
familiar with markdown
it's kinda like that
but even simpler
inline media
video with title prop
image with title prop
audio with title prop
video-with-no-title.mp4
image-with-no-title.jpg
audio-with-no-title.mp3"
`);
});
test("--html en", () => {
expect(
toHTML(gemtext, {
html: "en",
author: "anon",
descriptions: true,
})
).toMatchInlineSnapshot(`
"
gmi-web
gmi-web
a bridge between HTML and Gemini
https://codeberg.org/talon/gmi-web
on NPM
line-types
gmi-web makes writing HTML documents as simple as learning the handful of Gemini line-types:
- paragraphs
- preformatted blocks
- lists
- quotes
- headings
if you are
familiar with markdown
it's kinda like that
but even simpler
inline media
video with title prop
image with title prop
audio with title prop
video-with-no-title.mp4
image-with-no-title.jpg
audio-with-no-title.mp3
"
`);
});
test("--image, --audio, --video", () => {
expect(
toHTML(gemtext, {
body: true,
image: ["jpg"],
video: ["mp4"],
audio: ["mp3"],
})
).toMatchInlineSnapshot(`
"gmi-web
a bridge between HTML and Gemini
https://codeberg.org/talon/gmi-web
on NPM
line-types
gmi-web makes writing HTML documents as simple as learning the handful of Gemini line-types:
- paragraphs
- preformatted blocks
- lists
- quotes
- headings
if you are
familiar with markdown
it's kinda like that
but even simpler
inline media
"
`);
});
test("tokenize", () => {
expect(tokenize(gemtext, { body: true })).toMatchInlineSnapshot(`
Array [
Object {
"h1": "gmi-web",
},
Object {
"quote": "a bridge between HTML and Gemini",
},
Object {
"href": "https://codeberg.org/talon/gmi-web",
},
Object {
"href": "https://www.npmjs.com/package/gmi-web-cli",
"title": "on NPM ",
},
Object {
"text": "",
},
Object {
"h2": "line-types",
},
Object {
"text": "",
},
Object {
"text": "gmi-web makes writing HTML documents as simple as learning the handful of Gemini line-types:",
},
Object {
"li": "paragraphs ",
},
Object {
"li": "preformatted blocks ",
},
Object {
"li": "lists",
},
Object {
"li": "quotes ",
},
Object {
"li": "headings ",
},
Object {
"text": "",
},
Object {
"alt": "if you are familiar with markdown it's kinda like that but even simpler",
"pre": "\`\`\`if you are familiar with markdown it's kinda like that but even simpler",
},
Object {
"text": "if you are",
},
Object {
"text": " familiar with markdown",
},
Object {
"text": "it's kinda like that",
},
Object {
"text": "",
},
Object {
"text": "",
},
Object {
"text": "but even simpler",
},
Object {
"pre": "\`\`\`",
},
Object {
"text": "",
},
Object {
"h3": "inline media",
},
Object {
"href": "video.mp4",
"title": "video with title prop",
},
Object {
"href": "image.jpg",
"title": "image with title prop",
},
Object {
"href": "audio.mp3",
"title": "audio with title prop",
},
Object {
"href": "video-with-no-title.mp4",
},
Object {
"href": "image-with-no-title.jpg",
},
Object {
"href": "audio-with-no-title.mp3",
},
Object {
"text": "",
},
]
`);
});