Skip to content

Commit

Permalink
Update markdown2tags to v0.1.1.
Browse files Browse the repository at this point in the history
This fixes some escaping issues in the search field.
  • Loading branch information
jszakmeister committed Feb 22, 2014
1 parent a0a5bca commit f88420a
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions tool/markdown2ctags/markdown2ctags.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,25 @@
import re


__version__ = '0.1.0'
__version__ = '0.1.1'


class ScriptError(Exception):
pass


def ctagNameEscape(str):
return re.sub('[\t\r\n]+', ' ', str)


def ctagSearchEscape(str):
str = str.replace('\t', r'\t')
str = str.replace('\r', r'\r')
str = str.replace('\n', r'\n')
str = str.replace('\\', r'\\')
return str


class Tag(object):
def __init__(self, tagName, tagFile, tagAddress):
self.tagName = tagName
Expand Down Expand Up @@ -49,15 +61,16 @@ def __cmp__(self, other):

@staticmethod
def section(section):
tagAddress = '/^%s$/' % section.line
t = Tag(section.name, section.filename, tagAddress)
tagName = ctagNameEscape(section.name)
tagAddress = '/^%s$/' % ctagSearchEscape(section.line)
t = Tag(tagName, section.filename, tagAddress)
t.addField('kind', 's')
t.addField('line', section.lineNumber)

parents = []
p = section.parent
while p is not None:
parents.append(p.name)
parents.append(ctagNameEscape(p.name))
p = p.parent
parents.reverse()

Expand Down

0 comments on commit f88420a

Please sign in to comment.