Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix issue #2: encode anchor names in links

  • Loading branch information...
commit 580be7840a4534e501a62b9b2196dff55d085e78 1 parent 343ecdf
@cbonte authored
View
8 haproxy-dconv.py
@@ -38,6 +38,8 @@
from parser import remove_indent
from parser import *
+from urllib import quote
+
VERSION = ""
HAPROXY_GIT_VERSION = False
@@ -139,7 +141,7 @@ def createLinks():
if keyword in keyword_conflicts:
chapter_list = ""
for chapter in keyword_conflicts[keyword]:
- chapter_list += '<li><a href="#%s (%s)">%s</a></li>' % (keyword, chapters[chapter]['title'], chapters[chapter]['title'])
+ chapter_list += '<li><a href="#%s">%s</a></li>' % (quote("%s (%s)" % (keyword, chapters[chapter]['title'])), chapters[chapter]['title'])
document = document.replace('&quot;' + keyword + '&quot;',
'&quot;<span class="dropdown">' +
'<a class="dropdown-toggle" data-toggle="dropdown" href="#">' +
@@ -152,14 +154,14 @@ def createLinks():
'</ul>' +
'</span>&quot;')
else:
- document = document.replace('&quot;' + keyword + '&quot;', '&quot;<a href="#' + keyword + '">' + keyword + '</a>&quot;')
+ document = document.replace('&quot;' + keyword + '&quot;', '&quot;<a href="#' + quote(keyword) + '">' + keyword + '</a>&quot;')
if keyword.startswith("option "):
shortKeyword = keyword[len("option "):]
keywordsCount[shortKeyword] = document.count('&quot;' + shortKeyword + '&quot;')
if (shortKeyword in keyword_conflicts) and (not keywordsCount[shortKeyword]):
# The keyword is never used, we can remove it from the conflicts list
del keyword_conflicts[shortKeyword]
- document = document.replace('&quot;' + shortKeyword + '&quot;', '&quot;<a href="#' + keyword + '">' + shortKeyword + '</a>&quot;')
+ document = document.replace('&quot;' + shortKeyword + '&quot;', '&quot;<a href="#' + quote(keyword) + '">' + shortKeyword + '</a>&quot;')
def documentAppend(text, retline = True):
global document
View
3  parser/keyword.py
@@ -1,5 +1,6 @@
import re
import parser
+from urllib import quote
class Parser(parser.Parser):
def __init__(self, pctxt):
@@ -70,7 +71,7 @@ def parse(self, line):
parameters = self.colorize(parameters)
- res += '<div class="keyword">%s<b><a name="%s"></a><a href="#%s-%s">%s</a></b>%s%s</div>' % (prefix, keyword, toplevel, keyword, keyword, parameters, suffix)
+ res += '<div class="keyword">%s<b><a name="%s"></a><a href="#%s">%s</a></b>%s%s</div>' % (prefix, keyword, quote("%s-%s" % (toplevel, keyword)), keyword, parameters, suffix)
pctxt.next()
pctxt.stop = True
elif line.startswith("/*"):
View
3  templates/parser/table/row.tpl
@@ -1,3 +1,4 @@
+<% from urllib import quote %>
<tr>\
% for col in columns:
<% data = col['data'] %>\
@@ -21,7 +22,7 @@
%>\
<td ${style}>\
% if "keyword" in col:
-<a href="#${col['toplevel']}-${col['keyword']}">\
+<a href="#${quote("%s-%s" % (col['toplevel'], col['keyword']))}">\
% for extra in col['extra']:
<span class="pull-right">${extra}</span>\
% endfor
Please sign in to comment.
Something went wrong with that request. Please try again.