From 583f9a56dd80484ddb472a0d76578ac4b0d4c281 Mon Sep 17 00:00:00 2001 From: Martijn van der Ven Date: Thu, 23 Jul 2026 11:38:41 +0200 Subject: [PATCH 1/4] Implement redesign --- views/index.html.ejs | 212 +++++++++++++++++++++++-------------------- 1 file changed, 112 insertions(+), 100 deletions(-) diff --git a/views/index.html.ejs b/views/index.html.ejs index 511a013..034f487 100644 --- a/views/index.html.ejs +++ b/views/index.html.ejs @@ -1,5 +1,5 @@ - + Node Microformats Parser - - + -
+

Microformats Parser (Node) <%- version -%>

-
-
- - -
- - -
- -

OR parse just a snippet of HTML

- -
-
- - -
- -
- - -
- - -
- -
- -

- Drag this link to your bookmarks toolbar to parse a page with one - click!
-

- mf2 parser - -
+
+
+

Parse a URL

+ +
+
+ + +
+ + +
+
+ +
+

OR parse just a snippet of HTML

+ +
+
+ + +
+ +
+ + +
+ + +
+
+ +
+
+

Bookmarklet

+

+ Drag this link to your bookmarks toolbar to parse a page with one + click! +

+ mf2 parser +
+
+
-
+ + + From f0de16c1ec6cd6ac7cf2e688b9857565dfcc8329 Mon Sep 17 00:00:00 2001 From: Martijn van der Ven Date: Thu, 23 Jul 2026 11:38:41 +0200 Subject: [PATCH 2/4] Show the site and library versions as badges in the footer --- index.js | 3 ++- views/index.html.ejs | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index f909106..369b564 100644 --- a/index.js +++ b/index.js @@ -46,7 +46,8 @@ app.get("/", async (req, res) => { }); } else { res.render("index.html.ejs", { - version: `${pkg.version} (lib: ${mf2version})`, + site_version: pkg.version, + mf2_version: mf2version, }); } }); diff --git a/views/index.html.ejs b/views/index.html.ejs index 034f487..d4e2274 100644 --- a/views/index.html.ejs +++ b/views/index.html.ejs @@ -24,7 +24,7 @@
-

Microformats Parser (Node) <%- version -%>

+

Microformats Parser (Node)

@@ -104,11 +104,13 @@ href="https://github.com/microformats/microformats-parser-website-node" >Source code for this site + v<%- site_version -%>
  • Source code for the Microformats JavaScript Parser + v<%- mf2_version -%>
  • Other Microformats Parser websites: From 0436a663c279b56be640f8238eddba9dce9187d1 Mon Sep 17 00:00:00 2001 From: Martijn van der Ven Date: Thu, 23 Jul 2026 11:38:41 +0200 Subject: [PATCH 3/4] Expose the microformats-parser experimental options as checkboxes --- index.js | 17 +++++++++--- views/index.html.ejs | 63 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 369b564..071264d 100644 --- a/index.js +++ b/index.js @@ -16,9 +16,17 @@ function getDependencyVersion(dependencyName) { } const mf2version = getDependencyVersion("microformats-parser"); -function htmlToMf2(url, html, res) { +function readExperimental(params) { + const experimental = {}; + for (const flag of ["lang", "textContent", "metaformats"]) { + if (params[flag] === "true") experimental[flag] = true; + } + return Object.keys(experimental).length > 0 ? { experimental } : {}; +} + +function htmlToMf2(url, html, experimental, res) { try { - const body = mf2(html, { baseUrl: url }); + const body = mf2(html, { baseUrl: url, ...experimental }); res .header("content-type", "application/json; charset=UTF-8") .send(JSON.stringify(body, null, 2)); @@ -35,6 +43,7 @@ app.use(express.static("public")); app.get("/", async (req, res) => { if (req.query.url) { const url = req.query.url; + const experimental = readExperimental(req.query); await fetch(url, { headers: { accept: "text/html, text/mf2+html", @@ -42,7 +51,7 @@ app.get("/", async (req, res) => { method: "GET", }).then(async (response) => { const html = await response.text(); - htmlToMf2(url, html, res); + htmlToMf2(url, html, experimental, res); }); } else { res.render("index.html.ejs", { @@ -52,7 +61,7 @@ app.get("/", async (req, res) => { } }); app.post("/", express.urlencoded({ extended: false }), (req, res) => { - htmlToMf2(req.body.url, req.body.html, res); + htmlToMf2(req.body.url, req.body.html, {}, res); }); app.listen(port, () => { diff --git a/views/index.html.ejs b/views/index.html.ejs index d4e2274..eff0573 100644 --- a/views/index.html.ejs +++ b/views/index.html.ejs @@ -43,6 +43,69 @@ />
  • +
    + + Experimental options + +
    + + +
    + Include the lang attribute on microformats and + e-* properties. +
    +
    +
    + + +
    + Collapse consecutive whitespace and treat + <br>/<p> as line breaks. +
    +
    +
    + + +
    + Fall back to <meta> tags to infer content, + following the separate + metaformats + spec. +
    +
    +
    + From 529f8ec344f6173603da055b74941176b8339ace Mon Sep 17 00:00:00 2001 From: Martijn van der Ven Date: Thu, 23 Jul 2026 11:38:41 +0200 Subject: [PATCH 4/4] Format template with Prettier --- package.json | 2 +- views/index.html.ejs | 2 +- yarn.lock | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index bee8087..a6dbdc7 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,6 @@ "microformats-parser": "^2.0.6" }, "devDependencies": { - "prettier": "^3.9.5" + "prettier": "^3.9.6" } } diff --git a/views/index.html.ejs b/views/index.html.ejs index eff0573..59e468b 100644 --- a/views/index.html.ejs +++ b/views/index.html.ejs @@ -1,4 +1,4 @@ - + diff --git a/yarn.lock b/yarn.lock index a0a98d6..f5bd096 100644 --- a/yarn.lock +++ b/yarn.lock @@ -359,10 +359,10 @@ path-to-regexp@^8.0.0: resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-8.4.2.tgz#795c420c4f7ca45c5b887366f622ee0c9852cccd" integrity sha512-qRcuIdP69NPm4qbACK+aDogI5CBDMi1jKe0ry5rSQJz8JVLsC7jV8XpiJjGRLLol3N+R5ihGYcrPLTno6pAdBA== -prettier@^3.9.5: - version "3.9.5" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.9.5.tgz#4fec97736e33b9d0b620b48914fe93b530e835ad" - integrity sha512-/FVl766LpUfB5vXgCYOYa0MeV/441Ia99AeICQIQFTY/Nw0roZwULcXpku5i1/m5kt/baz+s4Zogspd839HSMg== +prettier@^3.9.6: + version "3.9.6" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.9.6.tgz#b3ea5146515d40fc53f18aa63f74dfab1e10dbf6" + integrity sha512-OpN0zzVdiaiAhxpuuj5efpIS4sY9j7bY6uR5mnj5yPzGkdkjNKSJeUThPb60Jw29QuAZgA4o+/iB49kFiaBX6g== proxy-addr@^2.0.7: version "2.0.7"