format
This commit is contained in:
parent
2a75fc8223
commit
1bfb3e3715
12
html.js
12
html.js
|
@ -5,7 +5,11 @@ import * as CSS from "./css.js";
|
|||
|
||||
export const GMI_REGEX = /^((=>\s?(?<href>[^\s]+)\s?(?<title>.+)?)|(?<pre>```\s?(?<alt>.+)?)|(###\s?(?<h3>.+))|(##\s?(?<h2>.+))|(#\s?(?<h1>.+))|(\*\s?(?<li>.+))|(>\s?(?<quote>.+))|(?<text>(.+)?))$/;
|
||||
export const tokenize = (gemtext) =>
|
||||
JSON.parse(JSON.stringify(gemtext.split("\n").map((line) => GMI_REGEX.exec(line).groups)));
|
||||
JSON.parse(
|
||||
JSON.stringify(
|
||||
gemtext.split("\n").map((line) => GMI_REGEX.exec(line).groups)
|
||||
)
|
||||
);
|
||||
|
||||
export function block(
|
||||
{ text, href, title, pre, alt, h1, h2, h3, li, quote },
|
||||
|
@ -42,15 +46,15 @@ export function block(
|
|||
exts.some((ext) => new RegExp(`\.${ext}$`).test(url));
|
||||
if (options.image && matchesExt(href, options.image)) {
|
||||
type = "img";
|
||||
props += ` src="${href}"`
|
||||
props += ` src="${href}"`;
|
||||
props += title ? ` title="${title}"` : "";
|
||||
} else if (options.audio && matchesExt(href, options.audio)) {
|
||||
type = "audio";
|
||||
props += ` controls src="${href}"`
|
||||
props += ` controls src="${href}"`;
|
||||
props += title ? ` title="${title}"` : "";
|
||||
} else if (options.video && matchesExt(href, options.video)) {
|
||||
type = "video";
|
||||
props += ` controls src="${href}"`
|
||||
props += ` controls src="${href}"`;
|
||||
props += title ? ` title="${title}"` : "";
|
||||
} else {
|
||||
type = "a";
|
||||
|
|
|
@ -75,7 +75,7 @@ test("--body", () => {
|
|||
`);
|
||||
});
|
||||
|
||||
test("--html en", () => {
|
||||
test("--html en --author anon --description", () => {
|
||||
expect(
|
||||
toHTML(gemtext, {
|
||||
html: "en",
|
||||
|
|
Loading…
Reference in a new issue