Some cleaning/linting
This commit is contained in:
parent
016f57ef1c
commit
7dc8d75b6c
|
@ -6577,41 +6577,45 @@ lit.status = true
|
||||||
-- Grammars
|
-- Grammars
|
||||||
function lit.g(name)
|
function lit.g(name)
|
||||||
|
|
||||||
-- Variable for grammars collection
|
-- Variable for grammars collection
|
||||||
local grammars = {}
|
local grammars = {}
|
||||||
|
|
||||||
|
local P, S, R, Cf, Cc, Ct, V, Cs, Cg, Cb, B, C, Cmt =
|
||||||
|
lpeg.P, lpeg.S, lpeg.R, lpeg.Cf, lpeg.Cc, lpeg.Ct, lpeg.V,
|
||||||
|
lpeg.Cs, lpeg.Cg, lpeg.Cb, lpeg.B, lpeg.C, lpeg.Cmt
|
||||||
|
|
||||||
-- Lexical elements
|
-- Lexical elements
|
||||||
local newline = lpeg.P"\r"^-1 * lpeg.P"\n"
|
local newline = P"\r"^-1 * P"\n"
|
||||||
local space = lpeg.S" \t"
|
local space = S" \t"
|
||||||
local anyspace = lpeg.S" \t\r\n"
|
local anyspace = S" \t\r\n"
|
||||||
local spot = (1 - anyspace)
|
local spot = (1 - anyspace)
|
||||||
local any = (spot + space)
|
local any = (spot + space)
|
||||||
local yamlheader = space^0 * lpeg.P"---" * space^0 * newline
|
local yamlheader = space^0 * P"---" * space^0 * newline
|
||||||
local yamlfooter = space^0 * lpeg.P"..." * space^0 * newline^-1
|
local yamlfooter = space^0 * P"..." * space^0 * newline^-1
|
||||||
local yamlbody = -yamlfooter * any^0 * newline
|
local yamlbody = -yamlfooter * any^0 * newline
|
||||||
local id = lpeg.R("az", "AZ") * lpeg.R("az", "AZ", "09")^0
|
local id = R("az", "AZ") * R("az", "AZ", "09")^0
|
||||||
local ref = -lpeg.B"\\" * lpeg.P"#" * lpeg.C(id)
|
local ref = -B"\\" * P"#" * C(id)
|
||||||
local notref = (1 - ref)^0
|
local notref = (1 - ref)^0
|
||||||
|
|
||||||
-- Declaration grammar
|
-- Declaration grammar
|
||||||
grammars["declaration"] = lpeg.P {
|
grammars["declaration"] = P {
|
||||||
"Declaration";
|
"Declaration";
|
||||||
Declaration = lpeg.Ct(lpeg.V"YAML" * lpeg.V"Code", "name");
|
Declaration = Ct(V"YAML" * V"Code", "name");
|
||||||
YAML = lpeg.C(yamlheader * yamlbody^0 * yamlfooter);
|
YAML = C(yamlheader * yamlbody^0 * yamlfooter);
|
||||||
Code = lpeg.C((any + newline)^0);
|
Code = C((any + newline)^0);
|
||||||
}
|
}
|
||||||
|
|
||||||
-- References grammar
|
-- References grammar
|
||||||
grammars["references"] = notref * lpeg.P {
|
grammars["references"] = notref * P {
|
||||||
"References";
|
"References";
|
||||||
References = lpeg.Ct((ref * notref)^0);
|
References = Ct((ref * notref)^0);
|
||||||
} * -1
|
} * -1
|
||||||
|
|
||||||
return grammars[name]
|
return grammars[name]
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Prints located messages
|
-- Prints located messages
|
||||||
function lit.puts(key, ...)
|
function lit.puts(yaml_key, ...)
|
||||||
|
|
||||||
-- Returns debug level as number
|
-- Returns debug level as number
|
||||||
local function debuglevel(str)
|
local function debuglevel(str)
|
||||||
|
@ -6673,16 +6677,18 @@ ERROR:
|
||||||
for mtype, msgs in pairs(msg) do
|
for mtype, msgs in pairs(msg) do
|
||||||
if msgs[key] ~= nil then
|
if msgs[key] ~= nil then
|
||||||
key = (msgs[key][lang] ~= nil and msgs[key][lang] or msgs[key]["en"])
|
key = (msgs[key][lang] ~= nil and msgs[key][lang] or msgs[key]["en"])
|
||||||
for i, str in ipairs({...}) do key = key:gsub("#" .. i, str) end
|
for i, str in ipairs({...}) do
|
||||||
|
key = key:gsub("#" .. i, str)
|
||||||
|
end
|
||||||
levelname, level = mtype, debuglevel(mtype)
|
levelname, level = mtype, debuglevel(mtype)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return key, levelname, level
|
return key, levelname, level
|
||||||
end
|
end
|
||||||
|
|
||||||
local verbosity = debuglevel(PANDOC_STATE.verbosity)
|
local verbosity = debuglevel(PANDOC_STATE.verbosity)
|
||||||
local msg, levelname, level = getmsg(key, ...)
|
local msg, levelname, level = getmsg(yaml_key, ...)
|
||||||
if level >= verbosity then
|
if level >= verbosity then
|
||||||
print("[" .. levelname .. "] [LIT] " .. msg)
|
print("[" .. levelname .. "] [LIT] " .. msg)
|
||||||
end
|
end
|
||||||
|
@ -6710,10 +6716,10 @@ function lit.exam(doc)
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
-- Parses code declaration
|
-- Parses code declaration
|
||||||
local function parse(codeblock)
|
local function parse(codeblock)
|
||||||
|
|
||||||
-- Checks code declarations
|
-- Checks code declarations
|
||||||
local function check(parsed)
|
local function check(parsed)
|
||||||
|
|
||||||
-- Indicates if checks passes
|
-- Indicates if checks passes
|
||||||
local ispass = true
|
local ispass = true
|
||||||
|
@ -6722,12 +6728,12 @@ function lit.exam(doc)
|
||||||
local metastruct = {
|
local metastruct = {
|
||||||
["mandatory"] = {
|
["mandatory"] = {
|
||||||
-- Value as table == whole patterns to match
|
-- Value as table == whole patterns to match
|
||||||
["id"] = {"%a[_%w]*"},
|
["id"] = {"%a[_%w]*"},
|
||||||
},
|
},
|
||||||
["optional"] = {
|
["optional"] = {
|
||||||
["lang"] = {
|
["lang"] = {
|
||||||
"lua", "fennel", "python", "js", "ruby", "lisp", "graphviz",
|
"lua", "fennel", "python", "js", "ruby", "lisp", "graphviz",
|
||||||
},
|
},
|
||||||
["cmd"] = {".+"},
|
["cmd"] = {".+"},
|
||||||
-- Value as string == type to match
|
-- Value as string == type to match
|
||||||
["args"] = "table",
|
["args"] = "table",
|
||||||
|
@ -6752,7 +6758,7 @@ function lit.exam(doc)
|
||||||
["lisp"] = {["ext_eval"] = { "CMD1", "CMD2", } },
|
["lisp"] = {["ext_eval"] = { "CMD1", "CMD2", } },
|
||||||
["graphviz"] = {["ext_eval"] = { "CMD1", "CMD2", } },
|
["graphviz"] = {["ext_eval"] = { "CMD1", "CMD2", } },
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Prints error and does not pass the check
|
-- Prints error and does not pass the check
|
||||||
local function putserr(...)
|
local function putserr(...)
|
||||||
lit.puts(...)
|
lit.puts(...)
|
||||||
|
@ -6778,15 +6784,15 @@ function lit.exam(doc)
|
||||||
end
|
end
|
||||||
return meta
|
return meta
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Checks for valid command
|
-- Checks for valid command
|
||||||
local function checkcmd(meta)
|
local function checkcmd(meta)
|
||||||
if meta["cmd"] then
|
if meta["cmd"] then
|
||||||
cmd = meta["cmd"]:split()[1]
|
local cmd = meta["cmd"]:split()[1]
|
||||||
if os.isunix() then
|
if os.isunix() then
|
||||||
status = io.try("type", cmd)
|
local status = io.try("type", cmd)
|
||||||
if not(status) then
|
if not(status) then
|
||||||
putserr("invalid_cmd", cmd)
|
putserr("invalid_cmd", cmd)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
lit.puts("skip_check", "checkcmd")
|
lit.puts("skip_check", "checkcmd")
|
||||||
|
@ -6795,82 +6801,82 @@ function lit.exam(doc)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Checks for extra and unwanted metadata
|
-- Checks for extra and unwanted metadata
|
||||||
local function checkextra(meta)
|
local function checkextra(meta)
|
||||||
for key, val in pairs(meta) do
|
for key, _ in pairs(meta) do
|
||||||
local missing1 = metastruct["mandatory"][key] == nil
|
local missing1 = metastruct["mandatory"][key] == nil
|
||||||
local missing2 = metastruct["optional"][key] == nil
|
local missing2 = metastruct["optional"][key] == nil
|
||||||
if missing1 and missing2 then
|
if missing1 and missing2 then
|
||||||
putserr("invalid_key", key)
|
putserr("invalid_key", key)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Checks for valid metadata
|
-- Checks for valid metadata
|
||||||
local function checkmeta(meta, kind)
|
local function checkmeta(metadata, kind)
|
||||||
|
|
||||||
-- Checks for valid metadata type
|
-- Checks for valid metadata type
|
||||||
local function checktype(type1, meta, key)
|
local function checktype(type1, meta, key)
|
||||||
local val = meta[key]
|
local val = meta[key]
|
||||||
local type2 = type(val)
|
local type2 = type(val)
|
||||||
if type1 ~= type2 then
|
if type1 ~= type2 then
|
||||||
if type1 == "path" then
|
if type1 == "path" then
|
||||||
if not(pandoc.path.directory(val):isdir()) then
|
if not(pandoc.path.directory(val):isdir()) then
|
||||||
putserr("invalid_path", val, key)
|
putserr("invalid_path", val, key)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
putserr("invalid_type", type2, key)
|
putserr("invalid_type", type2, key)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Checks for valid metadata pattern
|
-- Checks for valid metadata pattern
|
||||||
local function checkpattern(table, meta, key)
|
local function checkpattern(table, meta, key)
|
||||||
local val = tostring(meta[key])
|
local val = tostring(meta[key])
|
||||||
local err = key
|
local err = key
|
||||||
for _, pattern in pairs(table) do
|
for _, pattern in pairs(table) do
|
||||||
if val:match("^" .. pattern .. "$") then
|
if val:match("^" .. pattern .. "$") then
|
||||||
err = ""
|
err = ""
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not(err:isempty()) then
|
if not(err:isempty()) then
|
||||||
putserr("invalid_value", val, err)
|
putserr("invalid_value", val, err)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for key, val in pairs(metastruct[kind]) do
|
for key, val in pairs(metastruct[kind]) do
|
||||||
if meta[key] == nil and kind == "mandatory" then
|
if metadata[key] == nil and kind == "mandatory" then
|
||||||
putserr("no_key", key)
|
putserr("no_key", key)
|
||||||
elseif meta[key] and type(val) == "table" then
|
elseif metadata[key] and type(val) == "table" then
|
||||||
checkpattern(val, meta, key)
|
checkpattern(val, metadata, key)
|
||||||
elseif meta[key] then
|
elseif metadata[key] then
|
||||||
checktype(val, meta, key)
|
checktype(val, metadata, key)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Parses metadata
|
-- Parses metadata
|
||||||
local function parsemeta(yaml)
|
local function parsemeta(yaml)
|
||||||
local isok, res = pcall(pandoc.read, yaml)
|
local isok, res = pcall(pandoc.read, yaml)
|
||||||
local meta = {}
|
local meta = {}
|
||||||
if isok and not(pandoc.utils.stringify(res.meta):isempty()) then
|
if isok and not(pandoc.utils.stringify(res.meta):isempty()) then
|
||||||
meta = pandoc.metatotable(res.meta)
|
meta = pandoc.metatotable(res.meta)
|
||||||
checkmeta(meta, "mandatory")
|
checkmeta(meta, "mandatory")
|
||||||
checkmeta(meta, "optional")
|
checkmeta(meta, "optional")
|
||||||
checkextra(meta)
|
checkextra(meta)
|
||||||
checkcmd(meta)
|
checkcmd(meta)
|
||||||
elseif isok and pandoc.utils.stringify(res.meta):isempty() then
|
elseif isok and pandoc.utils.stringify(res.meta):isempty() then
|
||||||
putserr("meta_empty")
|
putserr("meta_empty")
|
||||||
else
|
else
|
||||||
putserr("meta_invalid")
|
putserr("meta_invalid")
|
||||||
end
|
end
|
||||||
return addeval(meta)
|
return addeval(meta)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TODO
|
-- TODO
|
||||||
-- NOTE: if not valid code, return meta["eval"] = {}
|
-- NOTE: if not valid code, return meta["eval"] = {}
|
||||||
local function checkcode(code, meta)
|
local function checkcode(code, meta)
|
||||||
references = lpeg.match(lit.g("references"), code)
|
local references = lpeg.match(lit.g("references"), code)
|
||||||
if references then
|
if references then
|
||||||
for _, ref in ipairs(references) do
|
for _, ref in ipairs(references) do
|
||||||
print("reference:", ref)
|
print("reference:", ref)
|
||||||
|
@ -6879,23 +6885,23 @@ function lit.exam(doc)
|
||||||
return "TODO"
|
return "TODO"
|
||||||
end
|
end
|
||||||
|
|
||||||
lit.puts("checking", table.concat(parsed, ""):indent())
|
lit.puts("checking", table.concat(parsed, ""):indent())
|
||||||
local meta = parsemeta(parsed[1])
|
local meta = parsemeta(parsed[1])
|
||||||
-- TODO
|
-- TODO
|
||||||
-- Add each meta to a variable
|
-- Add each meta to a variable
|
||||||
-- Remove meta if doesn't pass checkcode
|
-- Remove meta if doesn't pass checkcode
|
||||||
meta["code"] = checkcode(parsed[2], meta)
|
meta["code"] = checkcode(parsed[2], meta)
|
||||||
return meta
|
return meta
|
||||||
end
|
end
|
||||||
|
|
||||||
local parsed = lpeg.match(lit.g("declaration"), codeblock.text)
|
local parsed = lpeg.match(lit.g("declaration"), codeblock.text)
|
||||||
local checked = (parsed ~= nil and check(parsed) or parsed)
|
local checked = (parsed ~= nil and check(parsed) or parsed)
|
||||||
-- TODO:
|
-- TODO:
|
||||||
-- evaluated = eval(checked)
|
-- evaluated = eval(checked)
|
||||||
-- TODO: write evaluated and do overrides with warns
|
-- TODO: write evaluated and do overrides with warns
|
||||||
-- return evaluated
|
-- return evaluated
|
||||||
return codeblock
|
return codeblock
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TODO
|
-- TODO
|
||||||
-- Evals and inserts inline code
|
-- Evals and inserts inline code
|
||||||
|
@ -6920,14 +6926,7 @@ end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
-- Parses and evals literate programming
|
-- Parses and evals literate programming
|
||||||
{ Pandoc = function(doc) return lit.exam(doc) end },
|
{ Pandoc = function(e) return lit.exam(e) end },
|
||||||
{
|
-- TODO Parses and evals natural programming
|
||||||
-- Parses and evals natural programming
|
-- { Inlines = function(e) return nat.get(pandoc.utils.stringify(e)) end },
|
||||||
-- TODO
|
|
||||||
Inlines = function(inlines)
|
|
||||||
md = pandoc.utils.stringify(inlines)
|
|
||||||
md = nat.get(md)
|
|
||||||
return inlines
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,41 +20,45 @@ lit.status = true
|
||||||
-- Grammars
|
-- Grammars
|
||||||
function lit.g(name)
|
function lit.g(name)
|
||||||
|
|
||||||
-- Variable for grammars collection
|
-- Variable for grammars collection
|
||||||
local grammars = {}
|
local grammars = {}
|
||||||
|
|
||||||
|
local P, S, R, Cf, Cc, Ct, V, Cs, Cg, Cb, B, C, Cmt =
|
||||||
|
lpeg.P, lpeg.S, lpeg.R, lpeg.Cf, lpeg.Cc, lpeg.Ct, lpeg.V,
|
||||||
|
lpeg.Cs, lpeg.Cg, lpeg.Cb, lpeg.B, lpeg.C, lpeg.Cmt
|
||||||
|
|
||||||
-- Lexical elements
|
-- Lexical elements
|
||||||
local newline = lpeg.P"\r"^-1 * lpeg.P"\n"
|
local newline = P"\r"^-1 * P"\n"
|
||||||
local space = lpeg.S" \t"
|
local space = S" \t"
|
||||||
local anyspace = lpeg.S" \t\r\n"
|
local anyspace = S" \t\r\n"
|
||||||
local spot = (1 - anyspace)
|
local spot = (1 - anyspace)
|
||||||
local any = (spot + space)
|
local any = (spot + space)
|
||||||
local yamlheader = space^0 * lpeg.P"---" * space^0 * newline
|
local yamlheader = space^0 * P"---" * space^0 * newline
|
||||||
local yamlfooter = space^0 * lpeg.P"..." * space^0 * newline^-1
|
local yamlfooter = space^0 * P"..." * space^0 * newline^-1
|
||||||
local yamlbody = -yamlfooter * any^0 * newline
|
local yamlbody = -yamlfooter * any^0 * newline
|
||||||
local id = lpeg.R("az", "AZ") * lpeg.R("az", "AZ", "09")^0
|
local id = R("az", "AZ") * R("az", "AZ", "09")^0
|
||||||
local ref = -lpeg.B"\\" * lpeg.P"#" * lpeg.C(id)
|
local ref = -B"\\" * P"#" * C(id)
|
||||||
local notref = (1 - ref)^0
|
local notref = (1 - ref)^0
|
||||||
|
|
||||||
-- Declaration grammar
|
-- Declaration grammar
|
||||||
grammars["declaration"] = lpeg.P {
|
grammars["declaration"] = P {
|
||||||
"Declaration";
|
"Declaration";
|
||||||
Declaration = lpeg.Ct(lpeg.V"YAML" * lpeg.V"Code", "name");
|
Declaration = Ct(V"YAML" * V"Code", "name");
|
||||||
YAML = lpeg.C(yamlheader * yamlbody^0 * yamlfooter);
|
YAML = C(yamlheader * yamlbody^0 * yamlfooter);
|
||||||
Code = lpeg.C((any + newline)^0);
|
Code = C((any + newline)^0);
|
||||||
}
|
}
|
||||||
|
|
||||||
-- References grammar
|
-- References grammar
|
||||||
grammars["references"] = notref * lpeg.P {
|
grammars["references"] = notref * P {
|
||||||
"References";
|
"References";
|
||||||
References = lpeg.Ct((ref * notref)^0);
|
References = Ct((ref * notref)^0);
|
||||||
} * -1
|
} * -1
|
||||||
|
|
||||||
return grammars[name]
|
return grammars[name]
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Prints located messages
|
-- Prints located messages
|
||||||
function lit.puts(key, ...)
|
function lit.puts(yaml_key, ...)
|
||||||
|
|
||||||
-- Returns debug level as number
|
-- Returns debug level as number
|
||||||
local function debuglevel(str)
|
local function debuglevel(str)
|
||||||
|
@ -116,16 +120,18 @@ ERROR:
|
||||||
for mtype, msgs in pairs(msg) do
|
for mtype, msgs in pairs(msg) do
|
||||||
if msgs[key] ~= nil then
|
if msgs[key] ~= nil then
|
||||||
key = (msgs[key][lang] ~= nil and msgs[key][lang] or msgs[key]["en"])
|
key = (msgs[key][lang] ~= nil and msgs[key][lang] or msgs[key]["en"])
|
||||||
for i, str in ipairs({...}) do key = key:gsub("#" .. i, str) end
|
for i, str in ipairs({...}) do
|
||||||
|
key = key:gsub("#" .. i, str)
|
||||||
|
end
|
||||||
levelname, level = mtype, debuglevel(mtype)
|
levelname, level = mtype, debuglevel(mtype)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return key, levelname, level
|
return key, levelname, level
|
||||||
end
|
end
|
||||||
|
|
||||||
local verbosity = debuglevel(PANDOC_STATE.verbosity)
|
local verbosity = debuglevel(PANDOC_STATE.verbosity)
|
||||||
local msg, levelname, level = getmsg(key, ...)
|
local msg, levelname, level = getmsg(yaml_key, ...)
|
||||||
if level >= verbosity then
|
if level >= verbosity then
|
||||||
print("[" .. levelname .. "] [LIT] " .. msg)
|
print("[" .. levelname .. "] [LIT] " .. msg)
|
||||||
end
|
end
|
||||||
|
@ -153,10 +159,10 @@ function lit.exam(doc)
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
-- Parses code declaration
|
-- Parses code declaration
|
||||||
local function parse(codeblock)
|
local function parse(codeblock)
|
||||||
|
|
||||||
-- Checks code declarations
|
-- Checks code declarations
|
||||||
local function check(parsed)
|
local function check(parsed)
|
||||||
|
|
||||||
-- Indicates if checks passes
|
-- Indicates if checks passes
|
||||||
local ispass = true
|
local ispass = true
|
||||||
|
@ -165,12 +171,12 @@ function lit.exam(doc)
|
||||||
local metastruct = {
|
local metastruct = {
|
||||||
["mandatory"] = {
|
["mandatory"] = {
|
||||||
-- Value as table == whole patterns to match
|
-- Value as table == whole patterns to match
|
||||||
["id"] = {"%a[_%w]*"},
|
["id"] = {"%a[_%w]*"},
|
||||||
},
|
},
|
||||||
["optional"] = {
|
["optional"] = {
|
||||||
["lang"] = {
|
["lang"] = {
|
||||||
"lua", "fennel", "python", "js", "ruby", "lisp", "graphviz",
|
"lua", "fennel", "python", "js", "ruby", "lisp", "graphviz",
|
||||||
},
|
},
|
||||||
["cmd"] = {".+"},
|
["cmd"] = {".+"},
|
||||||
-- Value as string == type to match
|
-- Value as string == type to match
|
||||||
["args"] = "table",
|
["args"] = "table",
|
||||||
|
@ -195,7 +201,7 @@ function lit.exam(doc)
|
||||||
["lisp"] = {["ext_eval"] = { "CMD1", "CMD2", } },
|
["lisp"] = {["ext_eval"] = { "CMD1", "CMD2", } },
|
||||||
["graphviz"] = {["ext_eval"] = { "CMD1", "CMD2", } },
|
["graphviz"] = {["ext_eval"] = { "CMD1", "CMD2", } },
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Prints error and does not pass the check
|
-- Prints error and does not pass the check
|
||||||
local function putserr(...)
|
local function putserr(...)
|
||||||
lit.puts(...)
|
lit.puts(...)
|
||||||
|
@ -221,15 +227,15 @@ function lit.exam(doc)
|
||||||
end
|
end
|
||||||
return meta
|
return meta
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Checks for valid command
|
-- Checks for valid command
|
||||||
local function checkcmd(meta)
|
local function checkcmd(meta)
|
||||||
if meta["cmd"] then
|
if meta["cmd"] then
|
||||||
cmd = meta["cmd"]:split()[1]
|
local cmd = meta["cmd"]:split()[1]
|
||||||
if os.isunix() then
|
if os.isunix() then
|
||||||
status = io.try("type", cmd)
|
local status = io.try("type", cmd)
|
||||||
if not(status) then
|
if not(status) then
|
||||||
putserr("invalid_cmd", cmd)
|
putserr("invalid_cmd", cmd)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
lit.puts("skip_check", "checkcmd")
|
lit.puts("skip_check", "checkcmd")
|
||||||
|
@ -238,82 +244,82 @@ function lit.exam(doc)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Checks for extra and unwanted metadata
|
-- Checks for extra and unwanted metadata
|
||||||
local function checkextra(meta)
|
local function checkextra(meta)
|
||||||
for key, val in pairs(meta) do
|
for key, _ in pairs(meta) do
|
||||||
local missing1 = metastruct["mandatory"][key] == nil
|
local missing1 = metastruct["mandatory"][key] == nil
|
||||||
local missing2 = metastruct["optional"][key] == nil
|
local missing2 = metastruct["optional"][key] == nil
|
||||||
if missing1 and missing2 then
|
if missing1 and missing2 then
|
||||||
putserr("invalid_key", key)
|
putserr("invalid_key", key)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Checks for valid metadata
|
-- Checks for valid metadata
|
||||||
local function checkmeta(meta, kind)
|
local function checkmeta(metadata, kind)
|
||||||
|
|
||||||
-- Checks for valid metadata type
|
-- Checks for valid metadata type
|
||||||
local function checktype(type1, meta, key)
|
local function checktype(type1, meta, key)
|
||||||
local val = meta[key]
|
local val = meta[key]
|
||||||
local type2 = type(val)
|
local type2 = type(val)
|
||||||
if type1 ~= type2 then
|
if type1 ~= type2 then
|
||||||
if type1 == "path" then
|
if type1 == "path" then
|
||||||
if not(pandoc.path.directory(val):isdir()) then
|
if not(pandoc.path.directory(val):isdir()) then
|
||||||
putserr("invalid_path", val, key)
|
putserr("invalid_path", val, key)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
putserr("invalid_type", type2, key)
|
putserr("invalid_type", type2, key)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Checks for valid metadata pattern
|
-- Checks for valid metadata pattern
|
||||||
local function checkpattern(table, meta, key)
|
local function checkpattern(table, meta, key)
|
||||||
local val = tostring(meta[key])
|
local val = tostring(meta[key])
|
||||||
local err = key
|
local err = key
|
||||||
for _, pattern in pairs(table) do
|
for _, pattern in pairs(table) do
|
||||||
if val:match("^" .. pattern .. "$") then
|
if val:match("^" .. pattern .. "$") then
|
||||||
err = ""
|
err = ""
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not(err:isempty()) then
|
if not(err:isempty()) then
|
||||||
putserr("invalid_value", val, err)
|
putserr("invalid_value", val, err)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for key, val in pairs(metastruct[kind]) do
|
for key, val in pairs(metastruct[kind]) do
|
||||||
if meta[key] == nil and kind == "mandatory" then
|
if metadata[key] == nil and kind == "mandatory" then
|
||||||
putserr("no_key", key)
|
putserr("no_key", key)
|
||||||
elseif meta[key] and type(val) == "table" then
|
elseif metadata[key] and type(val) == "table" then
|
||||||
checkpattern(val, meta, key)
|
checkpattern(val, metadata, key)
|
||||||
elseif meta[key] then
|
elseif metadata[key] then
|
||||||
checktype(val, meta, key)
|
checktype(val, metadata, key)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Parses metadata
|
-- Parses metadata
|
||||||
local function parsemeta(yaml)
|
local function parsemeta(yaml)
|
||||||
local isok, res = pcall(pandoc.read, yaml)
|
local isok, res = pcall(pandoc.read, yaml)
|
||||||
local meta = {}
|
local meta = {}
|
||||||
if isok and not(pandoc.utils.stringify(res.meta):isempty()) then
|
if isok and not(pandoc.utils.stringify(res.meta):isempty()) then
|
||||||
meta = pandoc.metatotable(res.meta)
|
meta = pandoc.metatotable(res.meta)
|
||||||
checkmeta(meta, "mandatory")
|
checkmeta(meta, "mandatory")
|
||||||
checkmeta(meta, "optional")
|
checkmeta(meta, "optional")
|
||||||
checkextra(meta)
|
checkextra(meta)
|
||||||
checkcmd(meta)
|
checkcmd(meta)
|
||||||
elseif isok and pandoc.utils.stringify(res.meta):isempty() then
|
elseif isok and pandoc.utils.stringify(res.meta):isempty() then
|
||||||
putserr("meta_empty")
|
putserr("meta_empty")
|
||||||
else
|
else
|
||||||
putserr("meta_invalid")
|
putserr("meta_invalid")
|
||||||
end
|
end
|
||||||
return addeval(meta)
|
return addeval(meta)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TODO
|
-- TODO
|
||||||
-- NOTE: if not valid code, return meta["eval"] = {}
|
-- NOTE: if not valid code, return meta["eval"] = {}
|
||||||
local function checkcode(code, meta)
|
local function checkcode(code, meta)
|
||||||
references = lpeg.match(lit.g("references"), code)
|
local references = lpeg.match(lit.g("references"), code)
|
||||||
if references then
|
if references then
|
||||||
for _, ref in ipairs(references) do
|
for _, ref in ipairs(references) do
|
||||||
print("reference:", ref)
|
print("reference:", ref)
|
||||||
|
@ -322,23 +328,23 @@ function lit.exam(doc)
|
||||||
return "TODO"
|
return "TODO"
|
||||||
end
|
end
|
||||||
|
|
||||||
lit.puts("checking", table.concat(parsed, ""):indent())
|
lit.puts("checking", table.concat(parsed, ""):indent())
|
||||||
local meta = parsemeta(parsed[1])
|
local meta = parsemeta(parsed[1])
|
||||||
-- TODO
|
-- TODO
|
||||||
-- Add each meta to a variable
|
-- Add each meta to a variable
|
||||||
-- Remove meta if doesn't pass checkcode
|
-- Remove meta if doesn't pass checkcode
|
||||||
meta["code"] = checkcode(parsed[2], meta)
|
meta["code"] = checkcode(parsed[2], meta)
|
||||||
return meta
|
return meta
|
||||||
end
|
end
|
||||||
|
|
||||||
local parsed = lpeg.match(lit.g("declaration"), codeblock.text)
|
local parsed = lpeg.match(lit.g("declaration"), codeblock.text)
|
||||||
local checked = (parsed ~= nil and check(parsed) or parsed)
|
local checked = (parsed ~= nil and check(parsed) or parsed)
|
||||||
-- TODO:
|
-- TODO:
|
||||||
-- evaluated = eval(checked)
|
-- evaluated = eval(checked)
|
||||||
-- TODO: write evaluated and do overrides with warns
|
-- TODO: write evaluated and do overrides with warns
|
||||||
-- return evaluated
|
-- return evaluated
|
||||||
return codeblock
|
return codeblock
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TODO
|
-- TODO
|
||||||
-- Evals and inserts inline code
|
-- Evals and inserts inline code
|
||||||
|
@ -363,14 +369,7 @@ end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
-- Parses and evals literate programming
|
-- Parses and evals literate programming
|
||||||
{ Pandoc = function(doc) return lit.exam(doc) end },
|
{ Pandoc = function(e) return lit.exam(e) end },
|
||||||
{
|
-- TODO Parses and evals natural programming
|
||||||
-- Parses and evals natural programming
|
-- { Inlines = function(e) return nat.get(pandoc.utils.stringify(e)) end },
|
||||||
-- TODO
|
|
||||||
Inlines = function(inlines)
|
|
||||||
md = pandoc.utils.stringify(inlines)
|
|
||||||
md = nat.get(md)
|
|
||||||
return inlines
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
188
src/literate.lua
188
src/literate.lua
|
@ -9,41 +9,45 @@ lit.status = true
|
||||||
-- Grammars
|
-- Grammars
|
||||||
function lit.g(name)
|
function lit.g(name)
|
||||||
|
|
||||||
-- Variable for grammars collection
|
-- Variable for grammars collection
|
||||||
local grammars = {}
|
local grammars = {}
|
||||||
|
|
||||||
|
local P, S, R, Cf, Cc, Ct, V, Cs, Cg, Cb, B, C, Cmt =
|
||||||
|
lpeg.P, lpeg.S, lpeg.R, lpeg.Cf, lpeg.Cc, lpeg.Ct, lpeg.V,
|
||||||
|
lpeg.Cs, lpeg.Cg, lpeg.Cb, lpeg.B, lpeg.C, lpeg.Cmt
|
||||||
|
|
||||||
-- Lexical elements
|
-- Lexical elements
|
||||||
local newline = lpeg.P"\r"^-1 * lpeg.P"\n"
|
local newline = P"\r"^-1 * P"\n"
|
||||||
local space = lpeg.S" \t"
|
local space = S" \t"
|
||||||
local anyspace = lpeg.S" \t\r\n"
|
local anyspace = S" \t\r\n"
|
||||||
local spot = (1 - anyspace)
|
local spot = (1 - anyspace)
|
||||||
local any = (spot + space)
|
local any = (spot + space)
|
||||||
local yamlheader = space^0 * lpeg.P"---" * space^0 * newline
|
local yamlheader = space^0 * P"---" * space^0 * newline
|
||||||
local yamlfooter = space^0 * lpeg.P"..." * space^0 * newline^-1
|
local yamlfooter = space^0 * P"..." * space^0 * newline^-1
|
||||||
local yamlbody = -yamlfooter * any^0 * newline
|
local yamlbody = -yamlfooter * any^0 * newline
|
||||||
local id = lpeg.R("az", "AZ") * lpeg.R("az", "AZ", "09")^0
|
local id = R("az", "AZ") * R("az", "AZ", "09")^0
|
||||||
local ref = -lpeg.B"\\" * lpeg.P"#" * lpeg.C(id)
|
local ref = -B"\\" * P"#" * C(id)
|
||||||
local notref = (1 - ref)^0
|
local notref = (1 - ref)^0
|
||||||
|
|
||||||
-- Declaration grammar
|
-- Declaration grammar
|
||||||
grammars["declaration"] = lpeg.P {
|
grammars["declaration"] = P {
|
||||||
"Declaration";
|
"Declaration";
|
||||||
Declaration = lpeg.Ct(lpeg.V"YAML" * lpeg.V"Code", "name");
|
Declaration = Ct(V"YAML" * V"Code", "name");
|
||||||
YAML = lpeg.C(yamlheader * yamlbody^0 * yamlfooter);
|
YAML = C(yamlheader * yamlbody^0 * yamlfooter);
|
||||||
Code = lpeg.C((any + newline)^0);
|
Code = C((any + newline)^0);
|
||||||
}
|
}
|
||||||
|
|
||||||
-- References grammar
|
-- References grammar
|
||||||
grammars["references"] = notref * lpeg.P {
|
grammars["references"] = notref * P {
|
||||||
"References";
|
"References";
|
||||||
References = lpeg.Ct((ref * notref)^0);
|
References = Ct((ref * notref)^0);
|
||||||
} * -1
|
} * -1
|
||||||
|
|
||||||
return grammars[name]
|
return grammars[name]
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Prints located messages
|
-- Prints located messages
|
||||||
function lit.puts(key, ...)
|
function lit.puts(yaml_key, ...)
|
||||||
|
|
||||||
-- Returns debug level as number
|
-- Returns debug level as number
|
||||||
local function debuglevel(str)
|
local function debuglevel(str)
|
||||||
|
@ -64,16 +68,18 @@ function lit.puts(key, ...)
|
||||||
for mtype, msgs in pairs(msg) do
|
for mtype, msgs in pairs(msg) do
|
||||||
if msgs[key] ~= nil then
|
if msgs[key] ~= nil then
|
||||||
key = (msgs[key][lang] ~= nil and msgs[key][lang] or msgs[key]["en"])
|
key = (msgs[key][lang] ~= nil and msgs[key][lang] or msgs[key]["en"])
|
||||||
for i, str in ipairs({...}) do key = key:gsub("#" .. i, str) end
|
for i, str in ipairs({...}) do
|
||||||
|
key = key:gsub("#" .. i, str)
|
||||||
|
end
|
||||||
levelname, level = mtype, debuglevel(mtype)
|
levelname, level = mtype, debuglevel(mtype)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return key, levelname, level
|
return key, levelname, level
|
||||||
end
|
end
|
||||||
|
|
||||||
local verbosity = debuglevel(PANDOC_STATE.verbosity)
|
local verbosity = debuglevel(PANDOC_STATE.verbosity)
|
||||||
local msg, levelname, level = getmsg(key, ...)
|
local msg, levelname, level = getmsg(yaml_key, ...)
|
||||||
if level >= verbosity then
|
if level >= verbosity then
|
||||||
print("[" .. levelname .. "] [LIT] " .. msg)
|
print("[" .. levelname .. "] [LIT] " .. msg)
|
||||||
end
|
end
|
||||||
|
@ -101,10 +107,10 @@ function lit.exam(doc)
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
-- Parses code declaration
|
-- Parses code declaration
|
||||||
local function parse(codeblock)
|
local function parse(codeblock)
|
||||||
|
|
||||||
-- Checks code declarations
|
-- Checks code declarations
|
||||||
local function check(parsed)
|
local function check(parsed)
|
||||||
|
|
||||||
-- Indicates if checks passes
|
-- Indicates if checks passes
|
||||||
local ispass = true
|
local ispass = true
|
||||||
|
@ -113,12 +119,12 @@ function lit.exam(doc)
|
||||||
local metastruct = {
|
local metastruct = {
|
||||||
["mandatory"] = {
|
["mandatory"] = {
|
||||||
-- Value as table == whole patterns to match
|
-- Value as table == whole patterns to match
|
||||||
["id"] = {"%a[_%w]*"},
|
["id"] = {"%a[_%w]*"},
|
||||||
},
|
},
|
||||||
["optional"] = {
|
["optional"] = {
|
||||||
["lang"] = {
|
["lang"] = {
|
||||||
"lua", "fennel", "python", "js", "ruby", "lisp", "graphviz",
|
"lua", "fennel", "python", "js", "ruby", "lisp", "graphviz",
|
||||||
},
|
},
|
||||||
["cmd"] = {".+"},
|
["cmd"] = {".+"},
|
||||||
-- Value as string == type to match
|
-- Value as string == type to match
|
||||||
["args"] = "table",
|
["args"] = "table",
|
||||||
|
@ -143,7 +149,7 @@ function lit.exam(doc)
|
||||||
["lisp"] = {["ext_eval"] = { "CMD1", "CMD2", } },
|
["lisp"] = {["ext_eval"] = { "CMD1", "CMD2", } },
|
||||||
["graphviz"] = {["ext_eval"] = { "CMD1", "CMD2", } },
|
["graphviz"] = {["ext_eval"] = { "CMD1", "CMD2", } },
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Prints error and does not pass the check
|
-- Prints error and does not pass the check
|
||||||
local function putserr(...)
|
local function putserr(...)
|
||||||
lit.puts(...)
|
lit.puts(...)
|
||||||
|
@ -169,15 +175,15 @@ function lit.exam(doc)
|
||||||
end
|
end
|
||||||
return meta
|
return meta
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Checks for valid command
|
-- Checks for valid command
|
||||||
local function checkcmd(meta)
|
local function checkcmd(meta)
|
||||||
if meta["cmd"] then
|
if meta["cmd"] then
|
||||||
cmd = meta["cmd"]:split()[1]
|
local cmd = meta["cmd"]:split()[1]
|
||||||
if os.isunix() then
|
if os.isunix() then
|
||||||
status = io.try("type", cmd)
|
local status = io.try("type", cmd)
|
||||||
if not(status) then
|
if not(status) then
|
||||||
putserr("invalid_cmd", cmd)
|
putserr("invalid_cmd", cmd)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
lit.puts("skip_check", "checkcmd")
|
lit.puts("skip_check", "checkcmd")
|
||||||
|
@ -186,82 +192,82 @@ function lit.exam(doc)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Checks for extra and unwanted metadata
|
-- Checks for extra and unwanted metadata
|
||||||
local function checkextra(meta)
|
local function checkextra(meta)
|
||||||
for key, val in pairs(meta) do
|
for key, _ in pairs(meta) do
|
||||||
local missing1 = metastruct["mandatory"][key] == nil
|
local missing1 = metastruct["mandatory"][key] == nil
|
||||||
local missing2 = metastruct["optional"][key] == nil
|
local missing2 = metastruct["optional"][key] == nil
|
||||||
if missing1 and missing2 then
|
if missing1 and missing2 then
|
||||||
putserr("invalid_key", key)
|
putserr("invalid_key", key)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Checks for valid metadata
|
-- Checks for valid metadata
|
||||||
local function checkmeta(meta, kind)
|
local function checkmeta(metadata, kind)
|
||||||
|
|
||||||
-- Checks for valid metadata type
|
-- Checks for valid metadata type
|
||||||
local function checktype(type1, meta, key)
|
local function checktype(type1, meta, key)
|
||||||
local val = meta[key]
|
local val = meta[key]
|
||||||
local type2 = type(val)
|
local type2 = type(val)
|
||||||
if type1 ~= type2 then
|
if type1 ~= type2 then
|
||||||
if type1 == "path" then
|
if type1 == "path" then
|
||||||
if not(pandoc.path.directory(val):isdir()) then
|
if not(pandoc.path.directory(val):isdir()) then
|
||||||
putserr("invalid_path", val, key)
|
putserr("invalid_path", val, key)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
putserr("invalid_type", type2, key)
|
putserr("invalid_type", type2, key)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Checks for valid metadata pattern
|
-- Checks for valid metadata pattern
|
||||||
local function checkpattern(table, meta, key)
|
local function checkpattern(table, meta, key)
|
||||||
local val = tostring(meta[key])
|
local val = tostring(meta[key])
|
||||||
local err = key
|
local err = key
|
||||||
for _, pattern in pairs(table) do
|
for _, pattern in pairs(table) do
|
||||||
if val:match("^" .. pattern .. "$") then
|
if val:match("^" .. pattern .. "$") then
|
||||||
err = ""
|
err = ""
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not(err:isempty()) then
|
if not(err:isempty()) then
|
||||||
putserr("invalid_value", val, err)
|
putserr("invalid_value", val, err)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for key, val in pairs(metastruct[kind]) do
|
for key, val in pairs(metastruct[kind]) do
|
||||||
if meta[key] == nil and kind == "mandatory" then
|
if metadata[key] == nil and kind == "mandatory" then
|
||||||
putserr("no_key", key)
|
putserr("no_key", key)
|
||||||
elseif meta[key] and type(val) == "table" then
|
elseif metadata[key] and type(val) == "table" then
|
||||||
checkpattern(val, meta, key)
|
checkpattern(val, metadata, key)
|
||||||
elseif meta[key] then
|
elseif metadata[key] then
|
||||||
checktype(val, meta, key)
|
checktype(val, metadata, key)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Parses metadata
|
-- Parses metadata
|
||||||
local function parsemeta(yaml)
|
local function parsemeta(yaml)
|
||||||
local isok, res = pcall(pandoc.read, yaml)
|
local isok, res = pcall(pandoc.read, yaml)
|
||||||
local meta = {}
|
local meta = {}
|
||||||
if isok and not(pandoc.utils.stringify(res.meta):isempty()) then
|
if isok and not(pandoc.utils.stringify(res.meta):isempty()) then
|
||||||
meta = pandoc.metatotable(res.meta)
|
meta = pandoc.metatotable(res.meta)
|
||||||
checkmeta(meta, "mandatory")
|
checkmeta(meta, "mandatory")
|
||||||
checkmeta(meta, "optional")
|
checkmeta(meta, "optional")
|
||||||
checkextra(meta)
|
checkextra(meta)
|
||||||
checkcmd(meta)
|
checkcmd(meta)
|
||||||
elseif isok and pandoc.utils.stringify(res.meta):isempty() then
|
elseif isok and pandoc.utils.stringify(res.meta):isempty() then
|
||||||
putserr("meta_empty")
|
putserr("meta_empty")
|
||||||
else
|
else
|
||||||
putserr("meta_invalid")
|
putserr("meta_invalid")
|
||||||
end
|
end
|
||||||
return addeval(meta)
|
return addeval(meta)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TODO
|
-- TODO
|
||||||
-- NOTE: if not valid code, return meta["eval"] = {}
|
-- NOTE: if not valid code, return meta["eval"] = {}
|
||||||
local function checkcode(code, meta)
|
local function checkcode(code, meta)
|
||||||
references = lpeg.match(lit.g("references"), code)
|
local references = lpeg.match(lit.g("references"), code)
|
||||||
if references then
|
if references then
|
||||||
for _, ref in ipairs(references) do
|
for _, ref in ipairs(references) do
|
||||||
print("reference:", ref)
|
print("reference:", ref)
|
||||||
|
@ -270,23 +276,23 @@ function lit.exam(doc)
|
||||||
return "TODO"
|
return "TODO"
|
||||||
end
|
end
|
||||||
|
|
||||||
lit.puts("checking", table.concat(parsed, ""):indent())
|
lit.puts("checking", table.concat(parsed, ""):indent())
|
||||||
local meta = parsemeta(parsed[1])
|
local meta = parsemeta(parsed[1])
|
||||||
-- TODO
|
-- TODO
|
||||||
-- Add each meta to a variable
|
-- Add each meta to a variable
|
||||||
-- Remove meta if doesn't pass checkcode
|
-- Remove meta if doesn't pass checkcode
|
||||||
meta["code"] = checkcode(parsed[2], meta)
|
meta["code"] = checkcode(parsed[2], meta)
|
||||||
return meta
|
return meta
|
||||||
end
|
end
|
||||||
|
|
||||||
local parsed = lpeg.match(lit.g("declaration"), codeblock.text)
|
local parsed = lpeg.match(lit.g("declaration"), codeblock.text)
|
||||||
local checked = (parsed ~= nil and check(parsed) or parsed)
|
local checked = (parsed ~= nil and check(parsed) or parsed)
|
||||||
-- TODO:
|
-- TODO:
|
||||||
-- evaluated = eval(checked)
|
-- evaluated = eval(checked)
|
||||||
-- TODO: write evaluated and do overrides with warns
|
-- TODO: write evaluated and do overrides with warns
|
||||||
-- return evaluated
|
-- return evaluated
|
||||||
return codeblock
|
return codeblock
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TODO
|
-- TODO
|
||||||
-- Evals and inserts inline code
|
-- Evals and inserts inline code
|
||||||
|
|
|
@ -2,14 +2,7 @@
|
||||||
|
|
||||||
return {
|
return {
|
||||||
-- Parses and evals literate programming
|
-- Parses and evals literate programming
|
||||||
{ Pandoc = function(doc) return lit.exam(doc) end },
|
{ Pandoc = function(e) return lit.exam(e) end },
|
||||||
{
|
-- TODO Parses and evals natural programming
|
||||||
-- Parses and evals natural programming
|
-- { Inlines = function(e) return nat.get(pandoc.utils.stringify(e)) end },
|
||||||
-- TODO
|
|
||||||
Inlines = function(inlines)
|
|
||||||
md = pandoc.utils.stringify(inlines)
|
|
||||||
md = nat.get(md)
|
|
||||||
return inlines
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue