Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1446,7 +1446,7 @@ impl <'t> ParserState<'t> {

let text: Cow<str> = if text == "$" {
if scheme_in_list {
make_url_readable(&url).into()
make_url_readable(&url).trim_end_matches('/').into()
} else if let Some(rurl) = self.urlrefs.get(url.as_ref()) {
encode_html(make_url_readable(rurl.source()), true, true).into()
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/urlutils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl UrlBits {
impl ToString for UrlBits {
fn to_string(&self) -> String {
match self {
UrlBits::AbsoluteUrl(url) => url.to_string(),
UrlBits::AbsoluteUrl(url) => url.to_string().trim_end_matches('/').to_string(),
UrlBits::RelativeUrl {url, source} => {
let str_url = url.to_string();
match (str_url.find('?'), source.find('?')) {
Expand Down
465 changes: 270 additions & 195 deletions tests/fixtures/basic.yaml

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions tests/fixtures/dividers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ Dividers accept trailing whitespace within the tag:
<br >

Dividers can be self-closing:
setup:
setHtmlType: xhtml
input: |
<hr/>

Expand All @@ -61,8 +59,6 @@ Dividers can be self-closing:
<br />

Dividers can be paired containers:
setup:
setHtmlType: xhtml
input: |
<hr></hr>

Expand Down Expand Up @@ -156,7 +152,7 @@ Textile syntax that generates divider-like tags is not a divider:

Dividers are sanitized in restricted mode:
setup:
setRestricted: true
- setRestricted: true
input: |
<img src="image.jpg">

Expand Down
19 changes: 19 additions & 0 deletions tests/fixtures/fields.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Block tags are disabled:
setup:
- setBlockTags: false
input : |
Hello pw world!

Hello pw *world!*

Hello pw "world!"

Hello %(c)pw% world!
expect : |
Hello pw world!

Hello pw <strong>world!</strong>

Hello pw &#8220;world!&#8221;

Hello <span class="c">pw</span> world!
10 changes: 10 additions & 0 deletions tests/fixtures/fixed-uid.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Don't fail on unknown tokens:
class: \Netcarver\Textile\Test\Parser\FixedUniqueId
input: |
Try looking up textileRef:0000:84712874324.

Try looking up textileRef:0000:84712874324:url.
expect: |
<p>Try looking up textileRef:0000:84712874324.</p>

<p>Try looking up .</p>
4 changes: 1 addition & 3 deletions tests/fixtures/inline-code.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
Inline code can be used to embed code to a paragraph:
setup:
setHtmlType: xhtml
input: |
@This is some code@.

Expand Down Expand Up @@ -53,7 +51,7 @@ Inline code can be used to embed code to a paragraph:

Inline code isn't processed in lite mode:
setup:
setLite: true
- setLite: true
input: |
@This would be *some* code@

Expand Down
17 changes: 7 additions & 10 deletions tests/fixtures/issue-123.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
HTM5 image alignment:
setup:
setHtmlType: html5
doctype : html5
input: |
!>10x10.gif!

Expand All @@ -9,15 +8,13 @@ HTM5 image alignment:
!<10x10.gif!

expect: |
<p><img alt="" class="align-right" src="10x10.gif" /></p>
<p><img alt="" class="align-right" height="10" src="10x10.gif" width="10"></p>

<p><img alt="" class="align-center" src="10x10.gif" /></p>
<p><img alt="" class="align-center" height="10" src="10x10.gif" width="10"></p>

<p><img alt="" class="align-left" src="10x10.gif" /></p>
<p><img alt="" class="align-left" height="10" src="10x10.gif" width="10"></p>

XHTML image alignment:
setup:
setHtmlType: xhtml
input: |
!>10x10.gif!

Expand All @@ -26,8 +23,8 @@ XHTML image alignment:
!<10x10.gif!

expect: |
<p><img align="right" alt="" src="10x10.gif" /></p>
<p><img align="right" alt="" height="10" src="10x10.gif" width="10" /></p>

<p><img align="center" alt="" src="10x10.gif" /></p>
<p><img align="center" alt="" height="10" src="10x10.gif" width="10" /></p>

<p><img align="left" alt="" src="10x10.gif" /></p>
<p><img align="left" alt="" height="10" src="10x10.gif" width="10" /></p>
6 changes: 3 additions & 3 deletions tests/fixtures/issue-128.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ Links wrapped in HTML tags:
"link":http://example.com/</span>linkText

expect: |
<p><span><a href="http://example.com/">link</a></span></p>
<p><span><a href="http://example.com">link</a></span></p>

<p><span><cite><a href="http://example.com/">link</a></cite></span></p>
<p><span><cite><a href="http://example.com">link</a></cite></span></p>

<p><span><a href="http://example.com/">link</a></span>.</p>
<p><span><a href="http://example.com">link</a></span>.</p>

<p><a href="http://example.com/%3C/span%3ElinkText">link</a></p>
30 changes: 15 additions & 15 deletions tests/fixtures/issue-132.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
Alignment is accepted in restricted mode when doctype is set to HTML5 :
setup:
setRestricted: true
setLite: false
setImages: true
setLinkRelationShip: nofollow
- setRestricted: true
- setLite: false
- setImages: true
- setLinkRelationShip: nofollow
doctype: html5
input: |
!=10x10.gif!

Expand All @@ -12,19 +13,18 @@ Alignment is accepted in restricted mode when doctype is set to HTML5 :
!<10x10.gif!

expect: |
<p><img alt="" class="align-center" src="10x10.gif" /></p>
<p><img alt="" class="align-center" height="10" src="10x10.gif" width="10"></p>

<p><img alt="" class="align-right" src="10x10.gif" /></p>
<p><img alt="" class="align-right" height="10" src="10x10.gif" width="10"></p>

<p><img alt="" class="align-left" src="10x10.gif" /></p>
<p><img alt="" class="align-left" height="10" src="10x10.gif" width="10"></p>

In XHTML same generates align attribute:
setup:
setRestricted: true
setLite: false
setImages: true
setLinkRelationShip: nofollow
setHtmlType: xhtml
- setRestricted: true
- setLite: false
- setImages: true
- setLinkRelationShip: nofollow
input: |
!=10x10.gif!

Expand All @@ -33,8 +33,8 @@ In XHTML same generates align attribute:
!<10x10.gif!

expect: |
<p><img align="center" alt="" src="10x10.gif" /></p>
<p><img align="center" alt="" height="10" src="10x10.gif" width="10" /></p>

<p><img align="right" alt="" src="10x10.gif" /></p>
<p><img align="right" alt="" height="10" src="10x10.gif" width="10" /></p>

<p><img align="left" alt="" src="10x10.gif" /></p>
<p><img align="left" alt="" height="10" src="10x10.gif" width="10" /></p>
6 changes: 3 additions & 3 deletions tests/fixtures/issue-135.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ one:
expect: |
<table>
<tr>
<td>A list&#8230;<br>
<td>A list&#8230;<br />
<ul>
<li>one</li>
<li>two</li>
Expand All @@ -26,7 +26,7 @@ two:
<td>Col 2</td>
</tr>
<tr>
<td>A list&#8230;<br>
<td>A list&#8230;<br />
<ul>
<li>one</li>
<li>two</li>
Expand All @@ -47,7 +47,7 @@ three:
<td>Col 2</td>
</tr>
<tr>
<td colspan="2">A list&#8230;<br>
<td colspan="2">A list&#8230;<br />
<ul>
<li>one</li>
<li>two</li>
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/issue-145.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Dimensions on images outside document root directory:

!../../10x10.gif! above root directory, access prevented
expect: |
<p><img alt="" src="10x10.gif" /> in test directory</p>
<p><img alt="" height="10" src="10x10.gif" width="10" /> in test directory</p>

<p><img alt="" src="../textile-wordmark.png" /> exists in php-textile root directory, but dimension read is prevented</p>

Expand Down
36 changes: 36 additions & 0 deletions tests/fixtures/issue-146.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Relative links and images:
setup:
- setImagePrefix: http://example.com/images/
- setLinkPrefix: http://example.com/
input: |
"Text":link

"Text":./link

"Text":/link

"Text":http://example.com/

!10x10.gif!

!./10x10.gif!

!/10x10.gif!

"$":tel:0118-999-881-999-119-725-3
expect: |
<p><a href="http://example.com/link">Text</a></p>

<p><a href="./link">Text</a></p>

<p><a href="/link">Text</a></p>

<p><a href="http://example.com/">Text</a></p>

<p><img alt="" height="10" src="http://example.com/images/10x10.gif" width="10" /></p>

<p><img alt="" height="10" src="./10x10.gif" width="10" /></p>

<p><img alt="" height="10" src="/10x10.gif" width="10" /></p>

<p><a href="tel:0118-999-881-999-119-725-3">0118-999-881-999-119-725-3</a></p>
7 changes: 7 additions & 0 deletions tests/fixtures/issue-158.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,10 @@ Dimensions:
<p>What is .2&#8221;&#215; .5&#8221;?</p>

<p>1 &#215; $10.00 &#215; -£ 1.23 &#215; ¥20,000 &#215; -¤120.00 &#215; ฿1,000,000 &#215; -€110,00</p>

Disabled dimension:
class: \Netcarver\Textile\Test\Parser\DisableSymbols
input: |
1 x 1 = 1
expect: |
<p>1 x 1 = 1</p>
2 changes: 0 additions & 2 deletions tests/fixtures/issue-168.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
Multiline links:
setup:
setHtmlType: xhtml
input: |
"This is a multiline
link text":test
Expand Down
2 changes: 0 additions & 2 deletions tests/fixtures/issue-172.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
List followed by strong:
setup:
setHtmlType: xhtml
input: |
# Red
# Green
Expand Down
66 changes: 66 additions & 0 deletions tests/fixtures/issue-180.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
Text-alignment is stripped in restricted mode, but kept with images and such:
setup:
- setRestricted: true
input: |
p<. Left aligned paragraph.

p>. Right aligned paragraph.

p=. Center aligned paragraph.

p<>. Justified paragraph.

!<1.jpg!

!>1.jpg!

!=1.jpg!

expect: |
<p>Left aligned paragraph.</p>

<p>Right aligned paragraph.</p>

<p>Center aligned paragraph.</p>

<p>Justified paragraph.</p>

<p><img align="left" alt="" src="1.jpg" /></p>

<p><img align="right" alt="" src="1.jpg" /></p>

<p><img align="center" alt="" src="1.jpg" /></p>

Alignment uses classes with HTML5:
setup:
- setRestricted: true
doctype: html5
input: |
p<. Left aligned paragraph.

p>. Right aligned paragraph.

p=. Center aligned paragraph.

p<>. Justified paragraph.

!<1.jpg!

!>1.jpg!

!=1.jpg!

expect: |
<p>Left aligned paragraph.</p>

<p>Right aligned paragraph.</p>

<p>Center aligned paragraph.</p>

<p>Justified paragraph.</p>

<p><img alt="" class="align-left" src="1.jpg"></p>

<p><img alt="" class="align-right" src="1.jpg"></p>

<p><img alt="" class="align-center" src="1.jpg"></p>
24 changes: 24 additions & 0 deletions tests/fixtures/issue-185.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Links followed, or wrapped, by inline syntax:
input: |
["Roses":http://example.com][#red], grass[#green] and sky[#blue].

%["This is a link":test].%

notelist:‡.

note#red. Roses are %(class)["red":https://examle.com].%

note#green. Grass is green.

note#blue. Sky is blue.

expect: |
<p><a href="http://example.com">Roses</a><sup><a><span>1</span></a></sup>, grass<sup><a><span>2</span></a></sup> and sky<sup><a><span>3</span></a></sup>.</p>

<p><span><a href="test">This is a link</a>.</span></p>

<ol>
<li><sup><a>‡</a></sup><span> </span>Roses are <span class="class"><a href="https://examle.com">red</a>.</span></li>
<li><sup><a>‡</a></sup><span> </span>Grass is green.</li>
<li><sup><a>‡</a></sup><span> </span>Sky is blue.</li>
</ol>
Loading