|
From: Eric A. <gi...@gm...> - 2008-10-01 09:05:09
|
Hi there,
I've made a custom inline pattern to wrap Chinese characters in <span
class="char"></span> tags, using a regex (Chinese characters generally
fall between \u4e00 and \u9fff).
The below works, but wraps each individual character in its own span
tags, rather than wrapping consecutive runs of characters in a single
set of tags:
class SpanPattern(markdown.Pattern):
def handleMatch(self, m, doc):
el = doc.createElement('span')
el.appendChild(doc.createTextNode(m.group(2)))
el.setAttribute('class','char')
return el
md.inlinePatterns.insert(-1,SpanPattern(ur'([\u4e00-\u9fff]+)'))
The result is the same whether the + is included in the regex or not;
is there some other trick I can use to make sure that five characters
in row, for instance, will get wrapped together in one pair of spans?
TIA,
Eric
|