Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for pretty="none" #326

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
alerque marked this conversation as resolved.
Show resolved Hide resolved
- `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)
Expand Down
1 change: 0 additions & 1 deletion ldoc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line was to cast possible nil values to a boolean false. I think it was probably correct.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See also #118.

if args[field] == defval and ldoc[field] ~= nil then args[field] = ldoc[field] end
end

Expand Down
4 changes: 2 additions & 2 deletions ldoc/markup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand All @@ -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
Expand Down
8 changes: 6 additions & 2 deletions ldoc/prettify.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down