From 471fe9cce6e12b517e0e8193a09b7c65c9c7e8bc Mon Sep 17 00:00:00 2001 From: Elliott Slaughter Date: Thu, 16 Apr 2020 11:06:03 -0700 Subject: [PATCH 1/2] Support for pretty="none". --- ldoc.lua | 1 - ldoc/markup.lua | 4 ++-- ldoc/prettify.lua | 8 ++++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ldoc.lua b/ldoc.lua index 4cb99663..ff4c3a92 100644 --- a/ldoc.lua +++ b/ldoc.lua @@ -171,7 +171,6 @@ doc.ldoc = ldoc -- if the corresponding argument was the default, then any ldoc field overrides local function override (field,defval) - defval = defval or false if args[field] == defval and ldoc[field] ~= nil then args[field] = ldoc[field] end end diff --git a/ldoc/markup.lua b/ldoc/markup.lua index e34286d5..db01a6b2 100644 --- a/ldoc/markup.lua +++ b/ldoc/markup.lua @@ -157,7 +157,7 @@ local function process_multiline_markdown(ldoc, txt, F, filename, deflang) line = getline() end local fence = line:match '^```(.*)' - if fence then + if prettify.prettifier ~= 'none' and fence then local plain = fence=='' line = getline() local code = {} @@ -174,7 +174,7 @@ local function process_multiline_markdown(ldoc, txt, F, filename, deflang) if not line then break end end indent, line = indent_line(line) - if indent >= 4 then -- indented code block + if prettify.prettifier ~= 'none' and indent >= 4 then -- indented code block local code = {} local plain while indent >= 4 or blank(line) do diff --git a/ldoc/prettify.lua b/ldoc/prettify.lua index a57eddcb..f11d62b5 100644 --- a/ldoc/prettify.lua +++ b/ldoc/prettify.lua @@ -88,14 +88,16 @@ function prettify.lua (lang, fname, code, initial_lineno, pre, linenos) return res:join () end +prettify.prettifier = nil + local lxsh local lxsh_highlighers = {bib=true,c=true,lua=true,sh=true} function prettify.code (lang,fname,code,initial_lineno,pre) - if not lxsh then + if prettify.prettifier == 'lua' then return prettify.lua (lang,fname, code, initial_lineno, pre) - else + elseif prettify.prettifier == 'lxsh' then if not lxsh_highlighers[lang] then lang = 'lua' end @@ -111,12 +113,14 @@ function prettify.code (lang,fname,code,initial_lineno,pre) end function prettify.set_prettifier (pretty) + prettify.prettifier = pretty local ok if pretty == 'lxsh' then ok,lxsh = pcall(require,'lxsh') if not ok then print('pretty: '..pretty..' not found, using built-in Lua') lxsh = nil + prettify.prettifier = 'lua' end end end From f76ce3b44f02880fe443747726ac20e597d82a83 Mon Sep 17 00:00:00 2001 From: Elliott Slaughter Date: Thu, 16 Apr 2020 11:58:10 -0700 Subject: [PATCH 2/2] Update documentation for pretty="none". --- doc/doc.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/doc.md b/doc/doc.md index 683d93c2..e98363d0 100644 --- a/doc/doc.md +++ b/doc/doc.md @@ -1203,7 +1203,7 @@ _These only appear in the configuration file:_ - `full_description` when you _really_ need a longer project description - `examples` a directory or file: can be a table - `readme` or `topics` readme files (to be processed with Markdown) - - `pretty` code prettify 'lua' (default) or 'lxsh' + - `pretty` code prettify 'lua' (default), 'lxsh' or 'none' - `prettify_files` prettify the source as well and make links to it; if its value is "show" then also index the source files. - `charset` use if you want to override the UTF-8 default (also **@charset** in files)