Hello...
> Reading the python regex documentation page, I came across the
> re.MULTILINE directive, which address exactly our problem I think. So a
> patch could also be this one-liner
> - try: rgx = re.compile(patt)
> + try: rgx = re.compile(patt,re.MULTILINE)
>
Great, I didn't know about this.
...test...
Hmm, it doesn't work.
=== input file ==========================
%!preproc: '<<<' "'''\n{{{my environment"
%!preproc: '>>>' "}}}\n'''"
before
<<<
| not a table
>>>
after
=========================================
The "<<<" should insert a named block, but this is not taken into
account:
=== output ==========================
<p>
before
{{{my environment
'''
</p>
<table align="center" cellpadding="4">
<tr>
<td>not a table</td>
</tr>
</table>
<p>
'''
}}}
after
</p>
=====================================
Adding "re.MULTILINE" in the regexp for ''' (blockTaggedOpen and
blockTaggedClose) is slightly better as it takes the tagged block into
account, but it doesn't insert the "{{{my environment":
=== output ==========================
<p>
before
| not a table
after
</p>
=====================================
The expected result (given by my original patch) is:
=== output ==========================
<p>
before
{{{my environment
| not a table
}}}
after
</p>
=====================================
One can probably try to add "re.MULTILINE" to all the regexp
expressions, but we also need to do something in function "convert" to
insert back what comes before / after the tags.
(This would be around line 4788 for the tagged blocks).
I am not quite sure what the best way to do it is since even with the
re.MULTILINE option, one cannot "group" matches on several lines...
(Try the following piece of code:
==========================
import re
r1 = re.compile("(.*)\n(''')\n(.*)", re.MULTILINE)
r2 = re.compile("(.*)^(''')$(.*)", re.MULTILINE)
s = "Hello\n'''\nworld!"
g1 = r1.search(s)
if g1:
print "before: '%s' and after: '%s'" % (g1.group(1), g1.group(3))
g2 = r2.search(s)
if g2:
print "before: '%s' and after: '%s'" % (g2.group(1), g2.group(3))
==========================
)
In the end, I am not sure this is a smaller patch that the initial one;
and I feel that trying to do some matching on multilines for some (and
not all) tags will be a nightmare.
Much better to split the lines when they are introduced by filters...
However, I'd be happy if anyone can prove me wrong.
> > 38 tests from the test suite fail, but this is exactly like the
> > official svn version of txt2tags. I haven't looked more into it...
> You were lucky, I got quite the reverse
> Totals: 160 tests (38 ok / 122 failed)
>
Strange, I do get 122 OK and 38 failed...
Pierre
--
God exists since mathematics is consistent, and the
devil exists since its consistency cannot be proved.
-- Hermann Weyl
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
txt2tags-list mailing list
https://lists.sourceforge.net/lists/listinfo/txt2tags-list