From 9bd5dd0ec7d509dcad9834c73b5c76cfedb0aed5 Mon Sep 17 00:00:00 2001 From: steve donovan Date: Sun, 22 Jun 2014 17:14:08 +0200 Subject: [PATCH] dont_escape_underscore defaults to true if markdown.lua is not used; global_lookup defaults to true if parse_extra.C --- ldoc/doc.lua | 5 +++++ ldoc/markup.lua | 27 +++++++++++++++++---------- 2 files changed, 22 insertions(+), 10 deletions(-) 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