Issue Details (XML | Word | Printable)

Key: XWIKI-1245
Type: Task Task
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Sergiu Dumitriu
Reporter: Sergiu Dumitriu
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
XWiki Core

Italics XWiki syntax

Created: 21/May/07 00:52   Updated: 11/Feb/08 12:08
Component/s: Wiki features
Affects Version/s: None
Fix Version/s: 1.3 M2

Issue Links:
Related
 

Resolution Date: 11/Feb/08 12:08
Tests: Unit


 Description  « Hide
The italics wiki markup is triggered by placing a piece of text inside double-tilde, like: ~~text~~. This filter only works in single line mode.

It generates markup specifying that the delimited text is empahised; in XHTML the <em> tag is used.

Expected behavior:

This is not ~~ italic ~~  => This is not ~~ italic ~~
This is not ~~italic ~~  => This is not ~~italic ~~
This is not ~~ italic~~  => This is not ~~ italic~~
This is ~~italic~~ => This is <em>italic</em>
This is ~~a~~ letter italic => This is <em>a</em> letter italic
This is ~~a~~ short italic~~ => This is <em>a</em> short italic~~
This is ~~all ~~ italic~~ => This is <em>all ~~ italic</em>
This is ~~all ~~italic~~ => This is <em>all ~~italic</em>
This is ~~one~~italic~~ => This is <em>one</em>italic~~
~~a~~ => <em>a</em>
More ~~italics~~ on a ~~line~~ => More <em>italics</em> on a <em>line</em>
The extra tilde are ~~~~inside~~~ => The extra tilde are <em>~~inside~</em>
This~~is~~italic => This<em>is</em>italic
~~Eeny~~meeny~~miny~~moe~~ => <em>Eeny</em>meeny<em>miny</em>moe~~
~~ Eeny~~meeny~~miny~~moe~~ => ~~ Eeny<em>meeny</em>miny<em>moe</em>
This is an italic ~~~~~~ text => This is an italic <em>~~</em> text
Ignore ~~things~~ inside <script> var s = "non ~~italic~~ text"; </script> => Ignore <em>things</em> inside <script> var s = "non ~~italic~~ text"; </script>
Ignore <a href="/some~~page~~with~~tilde">attributes</a> => Ignore <a href="/some~~page~~with~~tilde">attributes</a>

Multiline examples:
This is not ~~not
italic~~
 =>
This is not ~~not
italic~~

<script>
var s = "non ~~italic~~ text";
</script>
var s = "non ~~italic~~ text"; 
 =>
<script>
var s = "non ~~italic~~ text";
</script>
var s = "non <em>italic</em> text";


 All   Comments   Change History   FishEye      Sort Order: Ascending order - Click to sort in descending order
Sergiu Dumitriu added a comment - 21/May/07 00:57
An alternative is to let it work on multiple lines, if the lines are part of the same paragraph.
This ~~is
italic~~
 =>
This <em>is
italic</em>

This ~~is
also
italic~~
 =>
This <em>is
also
italic</em>

But this is ~~not

italic~~
 =>
This is ~~not<p class="paragraph"/>
italic~~

Sergiu Dumitriu added a comment - 11/Feb/08 12:08
The syntax works as proposed, with the following remarks:
  • Filtering out links and scripts is not implemented, as it increases the rendering time a lot in some usage scenarios. This should be fixed when switching to the new rendering engine.
  • Works on a single line only.
  • Regex should run in O(n*m) whatever the text, where n=<text length> and m=<number of ~~ occurrences>