diff --git a/ldoc/doc.lua b/ldoc/doc.lua index ecdb268..c79ca9b 100644 --- a/ldoc/doc.lua +++ b/ldoc/doc.lua @@ -1100,6 +1100,11 @@ function Module:process_see_reference (s,modules,istype) else lua_manual_ref = global.lua_manual_ref end + -- pure C projects use global lookup (no namespaces) + if ldoc.global_lookup == nil then + local using_c = ldoc.parse_extra and ldoc.parse_extra.C + ldoc.global_lookup = using_c or false + end -- is this a fully qualified module name? local mod_ref = modules.by_name[s] diff --git a/ldoc/markup.lua b/ldoc/markup.lua index c7a75e3..fe2446b 100644 --- a/ldoc/markup.lua +++ b/ldoc/markup.lua @@ -243,16 +243,19 @@ local formatters = local function get_formatter(format) + local used_format = format local formatter = (formatters[format] or generic_formatter)(format) - if formatter then return formatter end - - for name, f in pairs(formatters) do - formatter = f(name) - if formatter then - print('format: '..format..' not found, using '..name) - return formatter - end - end + if not formatter then -- try another equivalent processor + for name, f in pairs(formatters) do + formatter = f(name) + if formatter then + print('format: '..format..' not found, using '..name) + used_format = name + break + end + end + end + return formatter, used_format end local function text_processor(ldoc) @@ -299,9 +302,13 @@ end local function get_processor(ldoc, format) if format == 'plain' then return text_processor(ldoc) end - local formatter = get_formatter(format) + local formatter,actual_format = get_formatter(format) if formatter then markup.plain = false + -- AFAIK only markdown.lua has underscore-in-identifier problem... + if ldoc.dont_escape_underscore ~= nil then + ldoc.dont_escape_underscore = actual_format ~= 'markdown' + end return markdown_processor(ldoc, formatter) end