diff options
-rw-r--r-- | head.html.in | 5 | ||||
-rw-r--r-- | huh.conf | 1 | ||||
-rwxr-xr-x | huh.lua | 21 | ||||
-rw-r--r-- | sample.html | 11 |
4 files changed, 38 insertions, 0 deletions
diff --git a/head.html.in b/head.html.in new file mode 100644 index 0000000..bc713fc --- /dev/null +++ b/head.html.in @@ -0,0 +1,5 @@ +<meta charset="utf-8"> +<meta name="viewport" content="width=device-width,initial-scale=1"> +<meta name="author" content="aki"> +<link rel="icon" type="image/png" href="favicon.png"> +<link rel="stylesheet" href="style.css"> diff --git a/huh.conf b/huh.conf new file mode 100644 index 0000000..c9ed62e --- /dev/null +++ b/huh.conf @@ -0,0 +1 @@ +head = head.html.in @@ -0,0 +1,21 @@ +#!/usr/bin/env lua +local gumbo = require "gumbo" +local config = require "pl.config" +local args = require "pl.lapp" [[ +Generates an HTML document from another HTML document (huh?). + +Options: + -c, --config (default huh.conf) Configuration file + -h, --help Prints this help message to standard output + +Arguments: + <input> (optional string) HTML file to process +]] +local conf = assert(config.read(args.config)) +local document = assert(gumbo.parseFile(args.input or io.stdin)) +local head = assert(gumbo.parseFile(conf.head, {contextElement="head"})) +for _, node in pairs(head.documentElement.childNodes) do + document:adoptNode(node) + document.head:insertBefore(node, document.head.firstChild) +end +document:serialize(io.stdout) diff --git a/sample.html b/sample.html new file mode 100644 index 0000000..016c528 --- /dev/null +++ b/sample.html @@ -0,0 +1,11 @@ +<!doctype html> +<html> +<meta name="tags" content="example"> +<title>Sample Article</title> +<article> +<p>With just this, you can start typing the article content. The header will be prepended according to the rules +specified in the template. Anything after <code><title></code> is treated as the article content, meaning the +<code><article></code> element is not mandatory at all. Additionally, anything before the +<code><title></code> element is added to the head of the output HTML document. +<p>I don't think I quite like how this looks like at the moment. +</article> |