From 297511b1cdec4759ea45328dd886eec358a9bf68 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 2 Mar 2021 17:42:20 +0100 Subject: [PATCH] xep2md: Warn if lua-yaml is missing Since this does not carry the full metadata needed to roundtrip the document, which can be fine if you're using the markdown for something else. --- tools/xep2md.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/xep2md.lua b/tools/xep2md.lua index 908fb514..0ba8cd5e 100644 --- a/tools/xep2md.lua +++ b/tools/xep2md.lua @@ -172,6 +172,7 @@ end); local lxp = require "lxp"; local lom = require "lxp.lom"; local events = require"util.events".new(); +local have_yaml, yaml = pcall(require, "lyaml"); local handler = {}; local stack = {}; @@ -350,7 +351,6 @@ events.add_handler("header/", function (event) if meta.title and meta.number then meta.title = "XEP-"..meta.number..": "..meta.title; end - local have_yaml, yaml = pcall(require, "lyaml"); if have_yaml and yaml.dump then output(yaml.dump({meta})); else @@ -612,6 +612,9 @@ local function chunks(file, size) end end +if not have_yaml then + io.stderr:write("lua-yaml missing, header metadata will be incomplete\n"); +end for chunk in chunks(io.stdin, 4096) do local ok, err, line, col = parser:parse(chunk); if not ok then