-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparseHTML.ts
More file actions
38 lines (30 loc) · 869 Bytes
/
parseHTML.ts
File metadata and controls
38 lines (30 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
async function inlineHTMLContent(fileName: string)
{
let appended = ""
const content = await Deno.readTextFile(`./src/pages/html/${fileName}`);
content.split(/\r?\n/).forEach(line => {
appended += line.trim().replaceAll("\"", `\\"`)
});
return appended
}
async function parseHTML()
{
const files = Deno.readDir("./src/pages/html")
const contents: string[] = [];
for await (const file of files)
{
contents.push(`String ${file.name.replaceAll(".", "_")} = "${await inlineHTMLContent(file.name)}";\r\n`)
}
const pages_h = `
//auto generated file. Run parseHTML.mjs to parse html files
#ifndef PAGES_H
#define PAGES_H
#include <Arduino.h>
${contents.map(content => {
return content
}).join('')}
#endif`
Deno.writeTextFile(`./src/pages/pages.h`, pages_h)
console.log("Deno: HTML Files Parsed")
}
parseHTML();