Edgewall Software

Ticket #2172: oneliner_fixes_and_tests.patch

File oneliner_fixes_and_tests.patch, 21.5 kB (added by cboos, 3 years ago)

In addition to the previous fix, I integrated the suggestion made in #1153, as well as a complete set of unit-tests for the Wiki one-liner formatter (checked the results, not all unit-tests need to be repeated for the one-liner case, though)

  • trac/wiki/tests/wiki-tests.txt

     
    1313</li></ul></li></ul><p> 
    1414Another paragraph 
    1515</p> 
     16------------------------------ 
     17= Heading 1 = 
     18Paragraph 
     19 * Item 1 
     20   * Item 2 
     21Another paragraph 
    1622============================== 
    1723Paragraph 
    1824---- 
     
    3541<p> 
    3642<a class="ext-link" href="http://www.edgewall.com/"><span class="icon"></span>http://www.edgewall.com/</a> 
    3743</p> 
     44------------------------------ 
     45Paragraph 
     46---- 
     47 1. Item 1 
     48   2. Item 2 
     49||Table||cell|| 
     50||Foo||Bar||Baz|| 
     51<a class="ext-link" href="http://www.edgewall.com/"><span class="icon"></span>http://www.edgewall.com/</a> 
    3852============================== 
    3953#1, [1], r1, {1} 
    4054------------------------------ 
    4155<p> 
    4256<a class="missing ticket" href="/ticket/1" rel="nofollow">#1</a>, <a class="missing changeset" href="/changeset/1" rel="nofollow">[1]</a>, <a class="missing changeset" href="/changeset/1" rel="nofollow">r1</a>, <a class="report" href="/report/1">{1}</a> 
    4357</p> 
     58------------------------------ 
    4459============================== 
    4560!#1, ![1], !r1, !{1} 
    4661------------------------------ 
    4762<p> 
    4863#1, [1], r1, {1} 
    4964</p> 
     65------------------------------ 
     66#1, [1], r1, {1} 
    5067============================== 
    5168[1:2], r1:2, [12:23], r12:23 
    5269------------------------------ 
    5370<p> 
    5471<a class="source" href="/log/?rev=2&stop_rev=1">[1:2]</a>, <a class="source" href="/log/?rev=2&stop_rev=1">r1:2</a>, <a class="source" href="/log/?rev=23&stop_rev=12">[12:23]</a>, <a class="source" href="/log/?rev=23&stop_rev=12">r12:23</a> 
    5572</p> 
     73------------------------------ 
    5674============================== 
    5775![1:2], !r1:2, ![12:23], !r12:23 
    5876------------------------------ 
    5977<p> 
    6078[1:2], r1:2, [12:23], r12:23 
    6179</p> 
     80------------------------------ 
     81[1:2], r1:2, [12:23], r12:23 
    6282============================== 
    6383ticket:1, changeset:1, report:1, source:foo/bar 
    6484 
     
    7090<p> 
    7191Issue <a class="missing ticket" href="/ticket/1" rel="nofollow">1</a>, CS<a class="missing changeset" href="/changeset/1" rel="nofollow">1</a>, Listing <a class="report" href="/report/1">1</a>, File <a class="source" href="/browser/foo/bar">foo/bar</a> 
    7292</p> 
     93------------------------------ 
    7394============================== 
     95Add-on to changeset:123: 
     96Some change. 
     97 
     98ticket:1 
     99This ticket is the first one 
     100------------------------------ 
     101<p> 
     102Add-on to <a class="missing changeset" href="/changeset/123" rel="nofollow">changeset:123</a>: 
     103Some change. 
     104</p> 
     105<p> 
     106<a class="missing ticket" href="/ticket/1" rel="nofollow">ticket:1</a> 
     107This ticket is the first one 
     108</p> 
     109------------------------------ 
     110Add-on to <a class="missing changeset" href="/changeset/123" rel="nofollow">changeset:123</a>: 
     111Some change. 
     112 
     113<a class="missing ticket" href="/ticket/1" rel="nofollow">ticket:1</a> 
     114This ticket is the first one 
     115============================== 
    74116[ticket:1 ticket 1], [changeset:1 changeset 1], [report:1 report 1],  
    75117[source:foo/bar source foo/bar], [http://www.edgewall.com/ edgewall] 
    76118------------------------------ 
     
    78120<a class="missing ticket" href="/ticket/1" rel="nofollow">ticket 1</a>, <a class="missing changeset" href="/changeset/1" rel="nofollow">changeset 1</a>, <a class="report" href="/report/1">report 1</a>,  
    79121<a class="source" href="/browser/foo/bar">source foo/bar</a>, <a class="ext-link" href="http://www.edgewall.com/"><span class="icon"></span>edgewall</a> 
    80122</p> 
     123------------------------------ 
    81124============================== 
    82125CamelCase AlabamA ABc AlaBamA FooBar 
    83126------------------------------ 
    84127<p> 
    85128<a class="missing wiki" href="/wiki/CamelCase" rel="nofollow">CamelCase?</a> AlabamA ABc AlaBamA <a class="missing wiki" href="/wiki/FooBar" rel="nofollow">FooBar?</a> 
    86129</p> 
     130------------------------------ 
    87131============================== 
    88132CamelCase,CamelCase.CamelCase:CamelCase 
    89133------------------------------ 
    90134<p> 
    91135<a class="missing wiki" href="/wiki/CamelCase" rel="nofollow">CamelCase?</a>,<a class="missing wiki" href="/wiki/CamelCase" rel="nofollow">CamelCase?</a>.CamelCase:CamelCase 
    92136</p> 
     137------------------------------ 
    93138============================== 
    94139!CamelCase 
    95140------------------------------ 
    96141<p> 
    97142CamelCase 
    98143</p> 
     144------------------------------ 
    99145============================== 
    100146<bug>http://localhost/bugzilla/show_bug.cgi?id=1284</bug> 804 
    101147------------------------------ 
    102148<p> 
    103149&lt;bug&gt;<a class="ext-link" href="http://localhost/bugzilla/show_bug.cgi?id=1284"><span class="icon"></span>http://localhost/bugzilla/show_bug.cgi?id=1284</a>&lt;/bug&gt; 804 
    104150</p> 
     151------------------------------ 
    105152============================== 
    106153||http://example.com/img.png||text|| 
    107154------------------------------ 
    108155<table class="wiki"> 
    109156<tr><td><img src="http://example.com/img.png" alt="http://example.com/img.png" /></td><td>text 
    110157</td></tr></table> 
     158------------------------------ 
     159||<a class="ext-link" href="http://example.com/img.png"><span class="icon"></span>http://example.com/img.png</a>||text|| 
    111160============================== 
    112161http://example.com/img.png?foo=bar 
    113162------------------------------ 
    114163<p> 
    115164<img src="http://example.com/img.png?foo=bar" alt="http://example.com/img.png?foo=bar" /> 
    116165</p> 
     166------------------------------ 
     167<a class="ext-link" href="http://example.com/img.png?foo=bar"><span class="icon"></span>http://example.com/img.png?foo=bar</a> 
    117168============================== 
    118169in: 
    119170|| RPC# || parameter len || ..... parameter ..... || 
     
    134185<tr><td> RPC# </td><td> parameter len </td><td> ..... parameter .....  
    135186</td></tr></table> 
    136187<hr /> 
     188------------------------------ 
     189in: 
     190|| RPC# || parameter len || ..... parameter ..... || 
     191out: 
     192|| RPC# || parameter len || ..... parameter ..... || 
     193---- 
    137194============================== 
    138195''RFCs von ftp://ftp.rfc-editor.org/in-notes/rfcXXXX.txt'' 
    139196------------------------------ 
    140197<p> 
    141198<i>RFCs von <a class="ext-link" href="ftp://ftp.rfc-editor.org/in-notes/rfcXXXX.txt"><span class="icon"></span>ftp://ftp.rfc-editor.org/in-notes/rfcXXXX.txt</a></i> 
    142199</p> 
     200------------------------------ 
    143201============================== 
    144202[wiki:WikiStart Foo] [http://www.edgewall.com/ Edgewall] 
    145203 
     
    161219<p> 
    162220<a class="missing wiki" href="/wiki/Argv" rel="nofollow">*argv[] versus **argv?</a> 
    163221</p> 
     222------------------------------ 
    164223============================== 
    165224foo (FooBar) 
    166225 
     
    172231<p> 
    173232foo (<a class="missing wiki" href="/wiki/FooBar" rel="nofollow">FooBar?</a> ) 
    174233</p> 
     234------------------------------ 
    175235============================== 
    176236== Heading with trailing white-space ==  
    177237------------------------------ 
    178238<h2 id="Headingwithtrailingwhitespace">Heading with trailing white-space</h2> 
     239------------------------------ 
     240== Heading with trailing white-space == 
    179241============================== 
    180242== ''Formatted'' ~~Heading~~ == 
    181243------------------------------ 
    182244<h2 id="FormattedHeading"><i>Formatted</i> <del>Heading</del></h2> 
     245------------------------------ 
     246== ''Formatted'' ~~Heading~~ == 
    183247============================== 
    184248== [wiki:SandBox Linked Heading] == 
    185249------------------------------ 
    186250<h2 id="LinkedHeading"><a class="missing wiki" href="/wiki/SandBox" rel="nofollow">Linked Heading?</a></h2> 
     251------------------------------ 
     252== [wiki:SandBox Linked Heading] == 
    187253============================== 
    188254A0B1, ST62T53C6, IR32V1H000 
    189255------------------------------ 
    190256<p> 
    191257A0B1, ST62T53C6, IR32V1H000 
    192258</p> 
     259------------------------------ 
    193260============================== 
    194261Paragraph 
    195262 * foo bar 
     
    212279</li></ul><p> 
    213280Paragraph 
    214281</p> 
     282------------------------------ 
     283Paragraph 
     284 * foo bar 
     285   boo baz 
     286   * Subitem 
     287     Subitem line 2 
     288 * item 2 
     289   item 2 line 2 
     290Paragraph 
    215291============================== 
    216292'''ticket:1''', ''ticket:1'', ~~ticket:1~~, __ticket:1__ 
    217293------------------------------ 
    218294<p> 
    219295<strong><a class="missing ticket" href="/ticket/1" rel="nofollow">ticket:1</a></strong>, <i><a class="missing ticket" href="/ticket/1" rel="nofollow">ticket:1</a></i>, <del><a class="missing ticket" href="/ticket/1" rel="nofollow">ticket:1</a></del>, <span class="underline"><a class="missing ticket" href="/ticket/1" rel="nofollow">ticket:1</a></span> 
    220296</p> 
     297------------------------------ 
    221298============================== 
    222299SandBox SandBox, SandBox; SandBox: SandBox. SandBox? SandBox! (SandBox) {SandBox} [SandBox] 
    223300------------------------------ 
    224301<p> 
    225302<a class="missing wiki" href="/wiki/SandBox" rel="nofollow">SandBox?</a> <a class="missing wiki" href="/wiki/SandBox" rel="nofollow">SandBox?</a>, <a class="missing wiki" href="/wiki/SandBox" rel="nofollow">SandBox?</a>; <a class="missing wiki" href="/wiki/SandBox" rel="nofollow">SandBox?</a>: <a class="missing wiki" href="/wiki/SandBox" rel="nofollow">SandBox?</a>. <a class="missing wiki" href="/wiki/SandBox" rel="nofollow">SandBox?</a>? <a class="missing wiki" href="/wiki/SandBox" rel="nofollow">SandBox?</a>! (<a class="missing wiki" href="/wiki/SandBox" rel="nofollow">SandBox?</a>) {<a class="missing wiki" href="/wiki/SandBox" rel="nofollow">SandBox?</a>} [<a class="missing wiki" href="/wiki/SandBox" rel="nofollow">SandBox?</a>] 
    226303</p> 
     304------------------------------ 
    227305============================== 
    228306source:/foo/bar 
    229307source:/foo/bar#42 
     
    250328<a class="source" href="/browser/foo/bar?rev=42#L20">source:/foo/bar@42#L20</a> 
    251329<a class="source" href="/browser/foo/bar?rev=head#L20">source:/foo/bar@head#L20</a> 
    252330</p> 
     331------------------------------ 
    253332============================== 
    254333query:?order=priority 
    255334 
     
    276355<p> 
    277356<a class="query" href="/query?milestone=1.0&amp;milestone=2.0&amp;owner=me&amp;order=priority">query:milestone=1.0|2.0&amp;owner=me</a> 
    278357</p> 
     358------------------------------ 
    279359============================== 
    280360{{{ 
    281361Preformatted text. 
     
    283363------------------------------ 
    284364<pre class="wiki">Preformatted text. 
    285365</pre> 
     366------------------------------ 
     367{{{ 
     368Preformatted text. 
     369}}} 
    286370============================== 
    287371{{{ 
    288372#!default 
     
    291375------------------------------ 
    292376<pre class="wiki">Preformatted text. 
    293377</pre> 
     378------------------------------ 
     379{{{ 
     380#!default 
     381Preformatted text. 
     382}}} 
    294383============================== 
    295384{{{ 
    296385#!/bin/sh 
     
    300389<pre class="wiki">#!/bin/sh 
    301390echo &#34;foo&#34; 
    302391</pre> 
     392------------------------------ 
     393{{{ 
     394#!/bin/sh 
     395echo "foo" 
     396}}} 
    303397============================== 
    304398{{{ 
    305399#!html 
     
    307401}}} 
    308402------------------------------ 
    309403<p>Hello World</p> 
     404------------------------------ 
     405{{{ 
     406#!html 
     407&lt;p&gt;Hello World&lt;/p&gt; 
     408}}} 
    310409============================== 
    311410{{{ 
    312411#!html 
     
    318417 <pre>&lt;script&gt;alert(&#34;&#34;);&lt;/script&gt; 
    319418</pre> 
    320419</div> 
     420------------------------------ 
     421{{{ 
     422#!html 
     423&lt;script&gt;alert("");&lt;/script&gt; 
     424}}} 
    321425============================== 
    322426{{{ 
    323427#!html 
     
    329433 <pre>&lt;div onclick=&#34;alert('')&#34;&gt;Click me&lt;/div&gt; 
    330434</pre> 
    331435</div> 
     436------------------------------ 
     437{{{ 
     438#!html 
     439&lt;div onclick="alert(<i>)"&gt;Click me&lt;/div&gt; 
     440}}}</i> 
    332441============================== 
    333442^superscript^, ,,subscript,,, normal. 
    334443------------------------------ 
    335444<p> 
    336445<sup>superscript</sup>, <sub>subscript</sub>, normal. 
    337446</p> 
     447------------------------------ 
     448<sup>superscript</sup>, <sub>subscript</sub>, normal. 
    338449============================== 
    339450[[HelloWorld(hej hopp)]] 
    340451------------------------------ 
    341452<p> 
    342453Hello World, args = hej hopp 
    343454</p> 
     455------------------------------ 
     456[[HelloWorld(hej hopp)]] 
    344457============================== 
    345458[[HelloWorld(hej hopp) ]] # This shouldnt executed as macro since it contain whitespace between ) and ] 
    346459------------------------------ 
    347460<p> 
    348461[[HelloWorld(hej hopp) ]] # This shouldnt executed as macro since it contain whitespace between ) and ] 
    349462</p> 
     463------------------------------ 
     464[[HelloWorld(hej hopp) ]] # This shouldnt executed as macro since it contain whitespace between ) and ] 
    350465============================== 
    351466[[HelloWorld(hej hopp))]] # Extra right brace and still executed 
    352467------------------------------ 
    353468<p> 
    354469Hello World, args = hej hopp) # Extra right brace and still executed 
    355470</p> 
     471------------------------------ 
     472[[HelloWorld(hej hopp))]] # Extra right brace and still executed 
    356473============================== 
    357474[[HelloWorld(hej hopp)]] [[HelloWorld(hej hopp2)]] # Test non greedy match 
    358475------------------------------ 
    359476<p> 
    360477Hello World, args = hej hopp Hello World, args = hej hopp2 # Test non greedy match 
    361478</p> 
     479------------------------------ 
     480[[HelloWorld(hej hopp)]] [[HelloWorld(hej hopp2)]] # Test non greedy match 
    362481============================== 
    363482Inline [[html(<B> Test </B>)]] text 
    364483------------------------------ 
    365484<p> 
    366485Inline <B> Test </B> text 
    367486</p> 
     487------------------------------ 
     488Inline [[html(&lt;B&gt; Test &lt;/B&gt;)]] text 
    368489============================== 
    369490Test comment blocks 
    370491{{{ 
     
    375496<p> 
    376497Test comment blocks 
    377498</p> 
     499------------------------------ 
     500Test comment blocks 
     501{{{ 
     502#!comment 
     503This is simply removed from the output 
     504}}} 
    378505============================== 
    379506Inline [[comment(This should not be seen)]] comment 
    380507------------------------------ 
    381508<p> 
    382509Inline  comment 
    383510</p> 
     511------------------------------ 
     512Inline [[comment(This should not be seen)]] comment 
    384513============================== 
    385514This should be '''''bold and italic''''' 
    386515------------------------------ 
    387516<p> 
    388517This should be <strong><i>bold and italic</i></strong> 
    389518</p> 
     519------------------------------ 
    390520============================== 
    391521'''''one''''', '''''two''''', '''''three''''', '''''four''''' 
    392522------------------------------ 
    393523<p> 
    394524<strong><i>one</i></strong>, <strong><i>two</i></strong>, <strong><i>three</i></strong>, <strong><i>four</i></strong> 
    395525</p> 
     526------------------------------ 
    396527============================== 
    397528__~~underlineoversrike~~__ 
    398529------------------------------ 
    399530<p> 
    400531<span class="underline"><del>underlineoversrike</del></span> 
    401532</p> 
     533------------------------------ 
    402534============================== 
    403535__~~overlapping__tags~~ 
    404536------------------------------ 
    405537<p> 
    406538<span class="underline"><del>overlapping</del></span><del>tags</del> 
    407539</p> 
     540------------------------------ 
    408541============================== 
    409542__~~outoforderclosetags__~~ 
    410543------------------------------ 
    411544<p> 
    412545<span class="underline"><del>outoforderclosetags</del></span><del></del> 
    413546</p> 
     547------------------------------ 
    414548============================== 
    415549'''''bolditalic''' # Open italic should be closed before paragraph end 
    416550------------------------------ 
    417551<p> 
    418552<strong><i>bolditalic</i></strong><i> # Open italic should be closed before paragraph end 
    419553</i></p> 
     554------------------------------ 
    420555============================== 
    421556''italic'''''bold''' 
    422557------------------------------ 
    423558<p> 
    424559<i>italic</i><strong>bold</strong> 
    425560</p> 
     561------------------------------ 
    426562============================== 
    427563'''bold'''''italic'' 
    428564------------------------------ 
    429565<p> 
    430566<strong>bold</strong><i>italic</i> 
    431567</p> 
     568------------------------------ 
    432569============================== 
    433570'''''bold 
    434571italic 
     
    439576italic 
    440577multiline</i></strong> 
    441578</p> 
     579------------------------------ 
    442580============================== 
    443581'''''bold 
    444582italic 
     
    451589multiline 
    452590without endtags 
    453591</i></strong></p> 
     592------------------------------ 
    454593============================== 
    455594 term:: definition 
    456595------------------------------ 
    457596<dl><dt>term</dt><dd>definition 
    458597</dd></dl> 
     598------------------------------ 
     599term:: definition 
    459600============================== 
    460601 complex topic:: multiline 
    461602                 ''formatted'' 
     
    465606<i>formatted</i> 
    466607definition 
    467608</dd></dl> 
     609------------------------------ 
     610complex topic:: multiline 
     611                 <i>formatted</i> 
     612                 definition 
    468613============================== 
    469614milestone:foo 
    470615[milestone:boo Milestone Boo] 
     
    473618<a class="milestone" href="/milestone/foo">milestone:foo</a> 
    474619<a class="milestone" href="/milestone/boo">Milestone Boo</a> 
    475620</p> 
     621------------------------------ 
    476622============================== 
    477623search:foo 
    478624search:"foo bar" 
     
    487633<a class="search" href="/search?q=bar">bar</a> 
    488634<a class="search" href="/search?q=">search</a> 
    489635</p> 
     636------------------------------ 
    490637============================== 
    491638search:?q=foo&wiki=on 
    492639search:"?q=foo bar&wiki=on" 
     
    497644<a class="search" href="/search?q=foo+bar&amp;wiki=on">search:"?q=foo bar&amp;wiki=on"</a> 
    498645<a class="search" href="/search?q=bar&amp;ticket=on">Bar in Tickets</a> 
    499646</p> 
     647------------------------------ 
    500648============================== 
    501649'''Note:''' 
    502650------------------------------ 
    503651<p> 
    504652<strong>Note:</strong> 
    505653</p> 
     654------------------------------ 
     655<strong>Note:</strong> 
    506656============================== 
    507657ticket:1 
    508658ticket:12 
     
    525675<a class="missing ticket" href="/ticket/12" rel="nofollow">ticket:"12"</a> 
    526676<a class="missing ticket" href="/ticket/123" rel="nofollow">ticket:"123"</a> 
    527677</p> 
     678------------------------------ 
    528679============================== 
    529680Relative links are supported: 
    530681[../parent See above] 
     
    539690<img src="/images/logo.png" alt="Our logo" /> 
    540691<a href="/">/</a> 
    541692</p> 
     693------------------------------ 
    542694============================== 
    543695source:'even with whitespaces' 
    544696source:"even with whitespaces" 
     
    551703<a class="source" href="/browser/even%20with%20whitespaces">Path with spaces</a> 
    552704<a class="source" href="/browser/even%20with%20whitespaces">Path with spaces</a> 
    553705</p> 
     706------------------------------ 
    554707============================== 
    555708svn+ssh://secureserver.org 
    556709[svn+ssh://secureserver.org SVN link] 
     
    563716<a class="ext-link" href="rfc-2396.compatible://link"><span class="icon"></span>rfc-2396.compatible://link</a> 
    564717<a class="ext-link" href="rfc-2396.compatible://link"><span class="icon"></span>RFC 2396</a> 
    565718</p> 
     719------------------------------ 
    566720============================== 
    567721= ça marche! = 
    568722------------------------------ 
    569723<h1 id="çamarche">ça marche!</h1> 
     724------------------------------ 
     725= ça marche! = 
    570726============================== 
    571727= "Test" = 
    572728------------------------------ 
    573729<h1 id="Test">"Test"</h1> 
     730------------------------------ 
     731= "Test" = 
    574732============================== 
    575733= Foo <Bar> Baz = 
    576734------------------------------ 
    577735<h1 id="FooltBargtBaz">Foo &lt;Bar&gt; Baz</h1> 
     736------------------------------ 
     737= Foo &lt;Bar&gt; Baz = 
    578738============================== 
    579739!__foo!__ 
    580740!~~bar!~~ 
     
    587747,,boo,, 
    588748^baz^ 
    589749</p> 
     750------------------------------ 
    590751============================== 
    591752/absolute/path/is/NotWiki and relative/path/is/NotWiki 
    592753/ThisIsNotWikiEither and /ThisIs/NotWikiEither but ThisIs/SubWiki 
     
    595756/absolute/path/is/NotWiki and relative/path/is/NotWiki 
    596757/ThisIsNotWikiEither and /ThisIs/NotWikiEither but <a class="missing wiki" href="/wiki/ThisIs/SubWiki" rel="nofollow">ThisIs/SubWiki?</a> 
    597758</p> 
     759------------------------------ 
    598760============================== 
    5997618FjBpOmy 
    600762anotherWikiPageName 
     
    6037658FjBpOmy 
    604766anotherWikiPageName 
    605767</p> 
     768------------------------------ 
     7698FjBpOmy 
     770anotherWikiPageName 
    606771============================== 
    607772|| a ||  
    608773|| b || 
     
    611776<tr><td> a  
    612777</td></tr><tr><td> b  
    613778</td></tr></table> 
     779------------------------------ 
     780|| a ||  
     781|| b || 
  • trac/wiki/tests/formatter.py

     
    55import unittest 
    66 
    77from trac.core import * 
    8 from trac.wiki.formatter import Formatter 
     8from trac.wiki.formatter import Formatter, OneLinerFormatter 
    99from trac.wiki.api import IWikiMacroProvider 
    1010 
    1111 
     
    7373        import trac.Search 
    7474 
    7575        env = DummyEnvironment() 
     76 
    7677        out = StringIO.StringIO() 
    77         Formatter(env).format(self.input, out) 
     78        self.format(env, out) 
    7879        v = out.getvalue().replace('\r','') 
    7980        self.assertEquals(self.correct, v) 
    8081 
     82    def format(self, env, out): 
     83        Formatter(env).format(self.input, out) 
     84 
     85 
     86class OneLinerTestCase(WikiTestCase): 
     87    def format(self, env, out): 
     88        OneLinerFormatter(env).format(self.input, out) 
     89 
     90 
    8191def suite(): 
    8292    suite = unittest.TestSuite() 
    8393    data = open(os.path.join(os.path.split(__file__)[0], 
    8494                             'wiki-tests.txt'), 'r').read() 
    8595    tests = data.split('=' * 30 + '\n') 
    8696    for test in tests: 
    87         input, correct = test.split('-' * 30 + '\n') 
    88         suite.addTest(WikiTestCase(input, correct)) 
     97        input, page, oneliner = test.split('-' * 30 + '\n') 
     98        suite.addTest(WikiTestCase(input, page)) 
     99        if oneliner: 
     100            suite.addTest(OneLinerTestCase(input, oneliner[:-1])) 
    89101    return suite 
    90102 
    91103if __name__ == '__main__': 
  • trac/wiki/formatter.py

     
    149149                  r"(?P<htmlescapeentity>!?&#\d+;)"] 
    150150    _post_rules = [(r"(?P<shref>!?((?P<sns>%s):" % LINK_SCHEME + 
    151151                    r"(?P<stgt>'[^']+'|\"[^\"]+\"|" 
    152                     r"(?:\|(?=[^| ])|&(?!lt;)|[^|& ])*[^|'~_\.,& \)])))"), 
     152                    r"(?:\|(?=[^|\s])|&(?!lt;)|" 
     153                    r"[^|&\s])*[^|'~_\.,&\s\)\]:])))"), 
    153154                   (r"(?P<lhref>!?\[(?:(?P<lns>%s):" % LINK_SCHEME + 
    154                     r"(?P<ltgt>'[^']+'|\"[^\"]+\"|[^\] ]*)" 
    155                     r"|(?P<rel>[/.][^ [\]]*))" 
    156                     r"(?: (?P<label>'[^']+'|\"[^\"]+\"|[^\]]+))?\])"), 
     155                    r"(?P<ltgt>'[^']+'|\"[^\"]+\"|[^\]\s]*)" 
     156                    r"|(?P<rel>[/.][^\s[\]]*))" 
     157                    r"(?:\s+(?P<label>'[^']+'|\"[^\"]+\"|[^\]]+))?\])"), 
    157158                   (r"(?P<macro>!?\[\[(?P<macroname>[\w/+-]+)" 
    158159                    r"(\]\]|\((?P<macroargs>.*?)\)\]\]))"), 
    159160                   r"(?P<heading>^\s*(?P<hdepth>=+)\s.*\s(?P=hdepth)\s*$)",