Skip to content

Commit ffe7f6a

Browse files
committed
Escaping short reference link text.
Fixes LuaDevelopmentTools#3.
1 parent 5bce09d commit ffe7f6a

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
*.luac
2+
docs

templateengine.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ local function format(string)
8585
return M.env.markdown( string )
8686
end
8787
---
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
95+
---
8896
-- Provide a full link to an element using `prettyname` and `linkto`.
8997
-- Default implementation is for HTML.
9098
local function fulllinkto(o,...)
@@ -93,7 +101,7 @@ local function fulllinkto(o,...)
93101
if not ref then
94102
return name
95103
end
96-
return string.format('<a href="%s">%s</a>', ref, name)
104+
return string.format('<a href="%s">%s</a>', ref, escape(name, '_'))
97105
end
98106
--
99107
-- Define default template environnement

0 commit comments

Comments
 (0)