[Zope-dev] STX and underline symbology
Alastair Burt
burt@dfki.de
19 Oct 2001 13:37:39 +0200
"Andreas Jung" <andreas@andreas-jung.com> writes:
> I checked in some fixes to underline handling into the trunk
> and the 2.4 branch. Please check this out. If the problems
> persist, please send me a small testcase.
I don't really know my way around CVS. The version I checked out has the
following in DocumentClass.py:
def doc_underline(self,
s,
#expr=re.compile(r"\_([a-zA-Z0-9\s\.,\?]+)\_").search, # old expr, inconsistent punc, failed to cross newlines
expr=re.compile(r'_([%s%s%s\s]+)_' % (letters, digits, under_punc)).search):
result = expr(s)
if result:
if result.group(1)[:1] == '_':
return None # no double unders
start,end = result.span(1)
st,e = result.span()
return (StructuredTextUnderline(s[start:end]),st,e)
else:
return None
And this does what I said in my message:
python_function1 does this, and python_function2 does that
becomes:
<p>python<u>function1 does this, and python</u>function2 does that</p>
--- Alastair
P.S. The following would support alternative 2 in my original message:
def doc_underline(self,
s,
#expr=re.compile(r"\_([a-zA-Z0-9\s\.,\?]+)\_").search, # old expr, inconsistent punc, failed to cross newlines
expr=re.compile(r'_([%s%s%s\s]+)_[\s%s]' % (letters, digits, under_punc, phrase_delimiters)).search):
result = expr(s)
if result:
if result.group(1)[:1] == '_':
return None # no double unders
start,end = result.span(1)
return (StructuredTextUnderline(s[start:end]), start-1, end+1)
else:
return None