Skip to content

Commit de2e9a6

Browse files
committed
Better short reference escaping.
Fixes LuaDevelopmentTools#3
1 parent ffe7f6a commit de2e9a6

2 files changed

Lines changed: 13 additions & 10 deletions

File tree

template/utils.lua

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,15 @@ function M.isinvokable(item)
333333
end
334334
end
335335

336+
---
337+
-- Disable Markdown processing on a specific string
338+
-- @param #string s Content to browse
339+
-- @param #string escaped What Markdown should not process
340+
-- @return #string Original `s` #string with `escaped` #string backslashed
341+
function M.escape(s, escaped)
342+
return string.gsub(s, escaped, '\\'..escaped)
343+
end
344+
336345
---
337346
-- Provide human readable overview from an API model element
338347
--
@@ -346,7 +355,8 @@ end
346355
function M.prettyname( apiobject, ... )
347356
local tag = apiobject.tag
348357
if M.prettynametypes[tag] then
349-
return M.prettynametypes[tag](apiobject,...)
358+
local prettyname = M.prettynametypes[tag](apiobject,...)
359+
return M.escape(prettyname,'_')
350360
elseif not tag then
351361
return nil, 'No pretty name available as no tag has been provided.'
352362
end

templateengine.lua

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,7 @@ local function format(string)
8484
string = string:gsub('@{%s*(.-)%s*}', replace)
8585
return M.env.markdown( string )
8686
end
87-
---
88-
-- Disable Markdown processing on a specific string
89-
-- @param #string s Content to browse
90-
-- @param #string escaped What Markdown should not process
91-
-- @return #string Original `s` #string with `escaped` #string backslashed
92-
local function escape(s, escaped)
93-
return string.gsub(s, escaped, '\\'..escaped)
94-
end
87+
9588
---
9689
-- Provide a full link to an element using `prettyname` and `linkto`.
9790
-- Default implementation is for HTML.
@@ -101,7 +94,7 @@ local function fulllinkto(o,...)
10194
if not ref then
10295
return name
10396
end
104-
return string.format('<a href="%s">%s</a>', ref, escape(name, '_'))
97+
return string.format('<a href="%s">%s</a>', ref, name)
10598
end
10699
--
107100
-- Define default template environnement

0 commit comments

Comments
 (0)