Commit cc62edd3 authored by Wendell Piez's avatar Wendell Piez

More refinements to hyperlinking

parent 814d8ae7
......@@ -36,14 +36,17 @@
<xsl:template match="text()">
<!-- tokenize by splitting around spaces, plus leading punctuation characters except slashes
(Gitlab HTMLevator Issue #8 -->
<xsl:variable name="tighter" as="xs:string" expand-text="true">(\p{{P}})({$country-codes}|{$tlds})(\p{{P}}|$)</xsl:variable>
<xsl:analyze-string select="." regex="([\p{{P}}-[/]]$)|([\p{{P}}-[/]]?\s+)">
<xsl:matching-substring>
<xsl:value-of select="."/>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:choose>
<!-- skip file URIs -->
<xsl:when test="matches(.,'file:/')">
<!-- skip file URIs and false hits on TLDs like 'catpic.jpg' -->
<xsl:when test="matches(.,'file:/') or not(matches(.,$tighter))">
<xsl:value-of select="."/>
</xsl:when>
<xsl:when test="matches(.,$uri-match) and (. castable as xs:anyURI)">
......
......@@ -3,30 +3,11 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="file:/C:/Users/Wendell/AppData/Roaming/com.oxygenxml/extensions/v20.1/frameworks/https___raw.githubusercontent.com_xspec_oXygen_XML_editor_xspec_support_master_build_update_site.xml/xspec.support-1.0.1/oxygen-results-view/test-report.css"><script type="text/javascript" src="file:/C:/Users/Wendell/AppData/Roaming/com.oxygenxml/extensions/v20.1/frameworks/https___raw.githubusercontent.com_xspec_oXygen_XML_editor_xspec_support_master_build_update_site.xml/xspec.support-1.0.1/oxygen-results-view/test-report.js"></script></head>
<body>
<div class="testsuite" data-name="Raw file name" template-id="x1b1d2e7a-863e-3901-8c0d-54fc270871bf" data-source="file:/C:/Users/Wendell/Documents/Gitlab/HTMLevator/applications/hyperlink-inferencer/hyperlinker.xspec" data-tests="1" data-failures="1">
<p style="margin:0px;"><span>Raw file name</span><span>&nbsp;</span><a class="button" onclick="runScenario(this)">Run</a></p>
<div class="testcase" data-name="Linked">
<p class="failed"><span class="test-failed" onclick="toggleResult(this)">Linked</span><span>&nbsp;</span><a class="button" onclick="showTest(this)">Show</a><span>&nbsp;</span><a class="button" onclick="toggleResult(this)">Q-Diff</a><span>&nbsp;</span><a class="button" onclick="showDiff(this)">Diff</a></p>
<div class="failure" id="d3e24" style="display:none;">
<table class="xspecResult">
<thead>
<tr>
<th style="font-size:14px;">Result</th>
<th style="font-size:14px;">Expected</th>
</tr>
</thead>
<tbody>
<tr>
<td><pre>&lt;<span xmlns="http://www.w3.org/1999/xhtml" class="diff">p</span> xmlns="http://www.w3.org/1999/xhtml"&gt;<span xmlns="http://www.w3.org/1999/xhtml" class="diff">This: </span>&lt;<span xmlns="http://www.w3.org/1999/xhtml" class="diff">a</span> <span xmlns="http://www.w3.org/1999/xhtml" class="diff">href</span>="http://mycatpic.jpg"&gt;<span xmlns="http://www.w3.org/1999/xhtml" class="diff">mycatpic.jpg</span>&lt;/a&gt;<span xmlns="http://www.w3.org/1999/xhtml" class="diff">.</span>&lt;/p&gt;</pre></td>
<td><pre>&lt;<span xmlns="http://www.w3.org/1999/xhtml" class="diff">p</span> xmlns="http://www.w3.org/1999/xhtml"&gt;<span xmlns="http://www.w3.org/1999/xhtml" class="diff">This: mycatpic.jpg.</span>&lt;/p&gt;</pre></td>
</tr>
</tbody>
</table>
</div><pre class="embeded.diff.data" style="display:none;"><div class="embeded.diff.result" style="white-space:pre;">
&lt;p xmlns="http://www.w3.org/1999/xhtml"&gt;This: &lt;a href="http://mycatpic.jpg"&gt;mycatpic.jpg&lt;/a&gt;.&lt;/p&gt;
</div><div class="embeded.diff.expected" style="white-space:pre;">
&lt;p xmlns="http://www.w3.org/1999/xhtml"&gt;This: mycatpic.jpg.&lt;/p&gt;
</div></pre></div>
<div class="testsuite" data-name="Raw file names" template-id="x5201cd6c-7961-39fd-81f7-287b9f88129b" data-source="file:/C:/Users/Wendell/Documents/Gitlab/HTMLevator/applications/hyperlink-inferencer/hyperlinker.xspec" data-tests="1" data-failures="0">
<p style="margin:0px;"><span>Raw file names</span><span>&nbsp;</span><a class="button" onclick="runScenario(this)">Run</a></p>
<div class="testcase" data-name="Not linked">
<p class="passed"><span class="test-passed" onclick="toggleResult(this)">Not linked</span><span>&nbsp;</span><a class="button" onclick="showTest(this)">Show</a></p>
</div>
</div>
<div class="testsuite" data-name="With trailing slash" template-id="x446462f6-af94-39d1-9dd5-e0249d9320d2" data-source="file:/C:/Users/Wendell/Documents/Gitlab/HTMLevator/applications/hyperlink-inferencer/hyperlinker.xspec" data-tests="1" data-failures="0">
<p style="margin:0px;"><span>With trailing slash</span><span>&nbsp;</span><a class="button" onclick="runScenario(this)">Run</a></p>
......
<?xml version="1.0" encoding="UTF-8"?><html xmlns:test="http://www.jenitennison.com/xslt/unit-test" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Test Report for C:/Users/Wendell/Documents/Gitlab/HTMLevator/applications/hyperlink-inferencer/hyperlink-inferencer.xsl (passed: 2 / pending: 0 / failed: 1 / total: 3)</title>
<title>Test Report for C:/Users/Wendell/Documents/Gitlab/HTMLevator/applications/hyperlink-inferencer/hyperlink-inferencer.xsl (passed: 3 / pending: 0 / failed: 0 / total: 3)</title>
<link rel="stylesheet" type="text/css" href="file:/C:/Users/Wendell/AppData/Roaming/com.oxygenxml/extensions/v20.1/frameworks/https___raw.githubusercontent.com_xspec_oXygen_XML_editor_xspec_support_master_build_update_site.xml/xspec.support-1.0.1/src/reporter/test-report.css" />
</head>
<body>
<h1>Test Report</h1>
<p>Stylesheet: <a href="file:/C:/Users/Wendell/Documents/Gitlab/HTMLevator/applications/hyperlink-inferencer/hyperlink-inferencer.xsl">C:/Users/Wendell/Documents/Gitlab/HTMLevator/applications/hyperlink-inferencer/hyperlink-inferencer.xsl</a></p>
<p>Tested: 12 October 2018 at 15:06</p>
<p>Tested: 12 October 2018 at 15:46</p>
<h2>Contents</h2>
<table class="xspec">
<col width="75%" />
......@@ -18,29 +18,29 @@
<thead>
<tr>
<th></th>
<th class="totals">passed: 2</th>
<th class="totals">passed: 3</th>
<th class="totals">pending: 0</th>
<th class="totals">failed: 1</th>
<th class="totals">failed: 0</th>
<th class="totals">total: 3</th>
</tr>
</thead>
<tbody>
<tr class="failed">
<th><a href="#d3e4">Raw file name</a></th>
<tr class="successful">
<th><a href="#d3e4">Raw file names</a></th>
<th class="totals">1</th>
<th class="totals">0</th>
<th class="totals">0</th>
<th class="totals">1</th>
<th class="totals">1</th>
</tr>
<tr class="successful">
<th><a href="#d3e37">With trailing slash</a></th>
<th><a href="#d3e34">With trailing slash</a></th>
<th class="totals">1</th>
<th class="totals">0</th>
<th class="totals">0</th>
<th class="totals">1</th>
</tr>
<tr class="successful">
<th><a href="#d3e73">Big Grab Bag</a></th>
<th><a href="#d3e70">Big Grab Bag</a></th>
<th class="totals">1</th>
<th class="totals">0</th>
<th class="totals">0</th>
......@@ -49,41 +49,25 @@
</tbody>
</table>
<div id="d3e4">
<h2 class="failed">Raw file name<span class="scenario-totals">passed: 0 / pending: 0 / failed: 1 / total: 1</span></h2>
<h2 class="successful">Raw file names<span class="scenario-totals">passed: 1 / pending: 0 / failed: 0 / total: 1</span></h2>
<table class="xspec" id="t-d3e4">
<col width="75%" />
<col width="25%" />
<tbody>
<tr class="failed">
<th>Raw file name</th>
<th>passed: 0 / pending: 0 / failed: 1 / total: 1</th>
</tr>
<tr class="failed">
<td><a href="#d3e24">Linked</a></td>
<td>Failure</td>
</tr>
</tbody>
</table>
<h3 id="d3e4">Raw file name</h3>
<h4 id="d3e24">Linked</h4>
<table class="xspecResult">
<thead>
<tr>
<th>Result</th>
<th>Expected Result</th>
<tr class="successful">
<th>Raw file names</th>
<th>passed: 1 / pending: 0 / failed: 0 / total: 1</th>
</tr>
</thead>
<tbody>
<tr>
<td><pre>&lt;<span class="diff">p</span> xmlns="http://www.w3.org/1999/xhtml"&gt;<span class="diff">This: </span>&lt;<span class="diff">a</span> <span class="diff">href</span>="http://mycatpic.jpg"&gt;<span class="diff">mycatpic.jpg</span>&lt;/a&gt;<span class="diff">.</span>&lt;/p&gt;</pre></td>
<td><pre>&lt;<span class="diff">p</span> xmlns="http://www.w3.org/1999/xhtml"&gt;<span class="diff">This: mycatpic.jpg.</span>&lt;/p&gt;</pre></td>
<tr class="successful">
<td>Not linked</td>
<td>Success</td>
</tr>
</tbody>
</table>
</div>
<div id="d3e37">
<div id="d3e34">
<h2 class="successful">With trailing slash<span class="scenario-totals">passed: 1 / pending: 0 / failed: 0 / total: 1</span></h2>
<table class="xspec" id="t-d3e37">
<table class="xspec" id="t-d3e34">
<col width="75%" />
<col width="25%" />
<tbody>
......@@ -98,9 +82,9 @@
</tbody>
</table>
</div>
<div id="d3e73">
<div id="d3e70">
<h2 class="successful">Big Grab Bag<span class="scenario-totals">passed: 1 / pending: 0 / failed: 0 / total: 1</span></h2>
<table class="xspec" id="t-d3e73">
<table class="xspec" id="t-d3e70">
<col width="75%" />
<col width="25%" />
<tbody>
......
......@@ -2,12 +2,12 @@
<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec"
stylesheet="hyperlink-inferencer.xsl" xmlns="http://www.w3.org/1999/xhtml">
<x:scenario label="Raw file name">
<x:scenario label="Raw file names">
<x:context>
<p>This: mycatpic.jpg.</p>
<p>This: mycatpic.jpg, and this: whatnot.txt.</p>
</x:context>
<x:expect label="Linked">
<p>This: mycatpic.jpg.</p>
<x:expect label="Not linked">
<p>This: mycatpic.jpg, and this: whatnot.txt.</p>
</x:expect>
</x:scenario>
<x:scenario label="With trailing slash">
......
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="file:/C:/Users/Wendell/AppData/Roaming/com.oxygenxml/extensions/v20.1/frameworks/https___raw.githubusercontent.com_xspec_oXygen_XML_editor_xspec_support_master_build_update_site.xml/xspec.support-1.0.1/src/compiler/format-xspec-report.xsl"?>
<x:report xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:test="http://www.jenitennison.com/xslt/unit-test"
xmlns:x="http://www.jenitennison.com/xslt/xspec"
xmlns="http://www.w3.org/1999/xhtml"
stylesheet="file:/C:/Users/Wendell/Documents/Gitlab/HTMLevator/applications/hyperlink-inferencer/hyperlink-inferencer.xsl"
date="2018-10-12T15:06:04.815-04:00">
<x:scenario>
<x:label>Raw file name</x:label>
<x:context>
<p>This: mycatpic.jpg.</p>
</x:context>
<x:result>
<p>This: <a href="http://mycatpic.jpg">mycatpic.jpg</a>.</p>
</x:result>
<x:test successful="false">
<x:label>Linked</x:label>
<x:expect>
<p>This: mycatpic.jpg.</p>
</x:expect>
</x:test>
</x:scenario>
<x:scenario>
<x:label>With trailing slash</x:label>
<x:context>
<p>This: http://www.arsdisputandi.org/</p>
</x:context>
<x:result>
<p>This: <a href="http://www.arsdisputandi.org/">http://www.arsdisputandi.org/</a>
</p>
</x:result>
<x:test successful="true">
<x:label>Linked</x:label>
<x:expect>
<p>This: <a href="http://www.arsdisputandi.org/">http://www.arsdisputandi.org/</a>
</p>
</x:expect>
</x:test>
</x:scenario>
<x:scenario>
<x:label>Big Grab Bag</x:label>
<x:context>
<html>
<head>
<meta charset="UTF-8"/>
</head>
<body>
<div>
<p>
<b>Here's some</b>
<b> bold for</b>
<b>you</b>.</p>
<h1>Substitution macros</h1>
<p>...the lion sleeps tonight...</p>
<p>www.wendellpiez.com</p>
<p>there's a file at ... file:/D:/Work/Projects/Customers/Coko/Data/url-reading-testing.html</p>
<p>Hyperlink inferencing might work on any domain and many file formats</p>
<p>http:where.are.we.now.com</p>
<p>Here's a pretty insane one: http://www5.iadb.org/mif/ProgramsandProjects/AccesstoFinance/Remittances/tabid/215/language/en-US/Default.aspx okay?</p>
<p>http://www.nmta.us/site/page.php?347</p>
<p>http://www.profeco.gob.mx/envio/cuadros.asp</p>
<p>ftp://ftp.my.site.org is also a link!</p>
<p>http://www.ime.gob.mx/ime2/images/educacion_financiera/acuerdo_bancos_consulados.pdf</p>
<p>and finally we have ... http://sccounty01.co.santa-cruz.ca.us/bds/Govstream/ASP/Display/PdfFinder.asp?Type=Agenda&amp;MeetingDate=20020618&amp;Filename=051.pdf</p>
<p>Here's my home page: http://www.piez.org/wendell</p> also pellucidliterature.org.
</div>
</body>
</html>
</x:context>
<x:result>
<html>
<head>
<meta charset="UTF-8"/>
</head>
<body>
<div>
<p>
<b>Here's some</b>
<b> bold for</b>
<b>you</b>.</p>
<h1>Substitution macros</h1>
<p>...the lion sleeps tonight...</p>
<p>
<a href="http://www.wendellpiez.com">www.wendellpiez.com</a>
</p>
<p>there's a file at ... file:/D:/Work/Projects/Customers/Coko/Data/url-reading-testing.html</p>
<p>Hyperlink inferencing might work on any domain and many file formats</p>
<p>
<a href="http://http:where.are.we.now.com">http:where.are.we.now.com</a>
</p>
<p>Here's a pretty insane one: <a href="http://www5.iadb.org/mif/ProgramsandProjects/AccesstoFinance/Remittances/tabid/215/language/en-US/Default.aspx">http://www5.iadb.org/mif/ProgramsandProjects/AccesstoFinance/Remittances/tabid/215/language/en-US/Default.aspx</a> okay?</p>
<p>
<a href="http://www.nmta.us/site/page.php?347">http://www.nmta.us/site/page.php?347</a>
</p>
<p>
<a href="http://www.profeco.gob.mx/envio/cuadros.asp">http://www.profeco.gob.mx/envio/cuadros.asp</a>
</p>
<p>
<a href="ftp://ftp.my.site.org">ftp://ftp.my.site.org</a> is also a link!</p>
<p>
<a href="http://www.ime.gob.mx/ime2/images/educacion_financiera/acuerdo_bancos_consulados.pdf">http://www.ime.gob.mx/ime2/images/educacion_financiera/acuerdo_bancos_consulados.pdf</a>
</p>
<p>and finally we have ... <a href="http://sccounty01.co.santa-cruz.ca.us/bds/Govstream/ASP/Display/PdfFinder.asp?Type=Agenda&amp;MeetingDate=20020618&amp;Filename=051.pdf">http://sccounty01.co.santa-cruz.ca.us/bds/Govstream/ASP/Display/PdfFinder.asp?Type=Agenda&amp;MeetingDate=20020618&amp;Filename=051.pdf</a>
</p>
<p>Here's my home page: <a href="http://www.piez.org/wendell">http://www.piez.org/wendell</a>
</p> also <a href="http://pellucidliterature.org">pellucidliterature.org</a>.
</div>
</body>
</html>
</x:result>
<x:test successful="true">
<x:label>With links marked up in line</x:label>
<x:expect>
<html>
<head>
<meta charset="UTF-8"/>
</head>
<body>
<div>
<p>
<b>Here's some</b>
<b> bold for</b>
<b>you</b>.</p>
<h1>Substitution macros</h1>
<p>...the lion sleeps tonight...</p>
<p>
<a href="http://www.wendellpiez.com">www.wendellpiez.com</a>
</p>
<p>there's a file at ... file:/D:/Work/Projects/Customers/Coko/Data/url-reading-testing.html</p>
<p>Hyperlink inferencing might work on any domain and many file formats</p>
<p>
<a href="http://http:where.are.we.now.com">http:where.are.we.now.com</a>
</p>
<p>Here's a pretty insane one: <a href="http://www5.iadb.org/mif/ProgramsandProjects/AccesstoFinance/Remittances/tabid/215/language/en-US/Default.aspx">http://www5.iadb.org/mif/ProgramsandProjects/AccesstoFinance/Remittances/tabid/215/language/en-US/Default.aspx</a> okay?</p>
<p>
<a href="http://www.nmta.us/site/page.php?347">http://www.nmta.us/site/page.php?347</a>
</p>
<p>
<a href="http://www.profeco.gob.mx/envio/cuadros.asp">http://www.profeco.gob.mx/envio/cuadros.asp</a>
</p>
<p>
<a href="ftp://ftp.my.site.org">ftp://ftp.my.site.org</a> is also a link!</p>
<p>
<a href="http://www.ime.gob.mx/ime2/images/educacion_financiera/acuerdo_bancos_consulados.pdf">http://www.ime.gob.mx/ime2/images/educacion_financiera/acuerdo_bancos_consulados.pdf</a>
</p>
<p>and finally we have ... <a href="http://sccounty01.co.santa-cruz.ca.us/bds/Govstream/ASP/Display/PdfFinder.asp?Type=Agenda&amp;MeetingDate=20020618&amp;Filename=051.pdf">http://sccounty01.co.santa-cruz.ca.us/bds/Govstream/ASP/Display/PdfFinder.asp?Type=Agenda&amp;MeetingDate=20020618&amp;Filename=051.pdf</a>
</p>
<p>Here's my home page: <a href="http://www.piez.org/wendell">http://www.piez.org/wendell</a>
</p> also <a href="http://pellucidliterature.org">pellucidliterature.org</a>.
</div>
</body>
</html>
</x:expect>
</x:test>
</x:scenario>
</x:report>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment