Skip to content

Commit

Permalink
roffit: fix special characters and broken links (#9)
Browse files Browse the repository at this point in the history
* fix special characters and broken links: testpage.1

Changed testpage.1 back to source.

* fix special characters and broken links: testpage.output

Reverted testpage.output back to source.

* fix special characters and broken links: roffit

Fixed one tabbed indent, and tried to implement corrections in "text2name()" and "do_encode()" again. Results - this is the best I'm going to do. Was not able to get working in "do_encode()" at all. In "text2name()" had very minor unexpected results in one file "brew.1", and was not able to resolve. It reproduced multiple links of the same link on several lines in that file.
  • Loading branch information
jhauga committed Sep 4, 2023
1 parent 9ec7ad9 commit a2afb03
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 48 deletions.
2 changes: 1 addition & 1 deletion roffit
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ sub linkfile {
$field =~ /(^|\W)((https|http|ftp):\/\/[a-z0-9\-._~%:\/?\#\[\]\@!\$&'()*+,;=]+)/ ||
$field =~ /(^|\W)RFC ?(\d+)/
) {
convert_html_links(); # Run link conversion in subroutine to save time.
convert_html_links(); # Run link conversion in subroutine to save time.
}
if ( # Fix special characters in subroutine to save time.
$field =~ /(<a name=)\"-\"(><\/a>)(<span class=\"nroffip\">-)([$specialcharacters]|[\[\]])((,)|(<\/span>))/ ||
Expand Down
35 changes: 2 additions & 33 deletions testpage.1
Original file line number Diff line number Diff line change
Expand Up @@ -19,47 +19,18 @@ but ARFC 959 is a fake

RFC3986 is URI syntax

Full inline urls with http, https, or ftp protocols are converted to
html links. For example:

https://curl.se/, ("https://curl.se/docs"), (https://daniel.haxx.se/projects/roffit/).

But when the url is in an example it is not converted into an html link..

.nf
cmd -opt https://example.com
.fi

When the protocols are declared within punctuations, but have no domain they remain
as an <a> element with the href attribute removed. For example:

("http://"), (https://), and "ftp://"; are <a> elements, while unpunctuated
http:// or https:// or ftp:// are inline text within <p> element.

Additionally special character options will have anchor links.
So if an option similar to the one below is documented;
it will have an anchor and anchor link:

.IP "-?, --special-char"
Options with special characters will be included in anchors.
Such as this option with special character \fI\-?, \-\-special\-char\fP.

Also, we must support \fIstyle staring on one line
and ending on another
that may\fP be multiple lines off.

.SH OPTIONS
.IP "--bare"
The output HTML will not include any HTML, HEAD or BODY tags. Also note that
The output HTML will not include any HTML, HEAD or BODY tags. Also not that
when this is selected, there will be no inlined CSS but you will have to
define the necessary classes yourself.

.IP "--mumbo"
Display version number and exit. Also see \fB--jumbo\fP. Word in bold.

.IP "--jumbo"
Cool option. See \fI--mumbo\fP. Word in italic.

.IP \-\-mandir=<dir>
Set a directory in which \fIroffit\fP will check for other man pages (in nroff
[name].[num] format) that this one refers to. If found, a <a href> link will
Expand All @@ -70,11 +41,9 @@ name in the generated link will be prefixed by the dir given with
This works for references specified as \fImanpage(3)\fP (within the emhpasis
foformatting) and in a plain \.BR section (often used in the SEE ALSO
section).

.IP \-\-hrefdir=<dir>
Specify a directory to prefix generated href links created with the \-\-mandir
option. This defaults to ".".

.SH "CSS CLASSES"
.IP h2.nroffsh
The nroff ".SH" section. These are normally the "headlines" before each sub
Expand All @@ -96,6 +65,6 @@ Text marked as a reference to another man page.
.IP span.emphasis
Text marked to be emphasized.
.IP p.roffit
Used for advertising final paragraph.
Used for the advertising final paragraph.
.SH WWW
http://daniel.haxx.se/projects/roffit
17 changes: 3 additions & 14 deletions testpage.output
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,9 @@
<p class="level0">(<a href="http://www.ietf.org/rfc/rfc959.txt">RFC 959</a>) is FTP </p>
<p class="level0">but ARFC 959 is a fake </p>
<p class="level0"><a href="http://www.ietf.org/rfc/rfc3986.txt">RFC 3986</a> is URI syntax </p>
<p class="level0">Full inline urls with http, https, or ftp protocols are converted to html links. For example: </p>
<p class="level0"><a href="https://curl.se/">https://curl.se/</a>, (&quot;<a href="https://curl.se/docs">https://curl.se/docs</a>&quot;), (<a href="https://daniel.haxx.se/projects/roffit/">https://daniel.haxx.se/projects/roffit/</a>). </p>
<p class="level0">But when the url is in an example it is not converted into an html link.. </p><pre class="level0">
&nbsp; cmd -opt https://example.com
</pre>

<p class="level0">When the protocols are declared within punctuations, but have no domain they remain as an &lt;a&gt; element with the href attribute removed. For example: </p>
<p class="level0">(&quot;<a>http://</a>&quot;), (<a>https://</a>), and &quot;<a>ftp://</a>&quot;; are &lt;a&gt; elements, while unpunctuated http:// or https:// or ftp:// are inline text within &lt;p&gt; element. </p>
<p class="level0">Additionally special character options will have anchor links. So if an option similar to the one below is documented; it will have an anchor and anchor link: </p>
<p class="level0"><a name="-?"></a><span class="nroffip">-?, --special-char</span> </p>
<p class="level1">Options with special characters will be included in anchors. Such as this option with special character <a class="emphasis" href="#-?">-?, --special-char</a>. </p>
<p class="level1">Also, we must support <span class="emphasis">style staring on one line and ending on another that may</span> be multiple lines off. </p><a name="OPTIONS"></a><h2 class="nroffsh">Options</h2>
<p class="level0">Also, we must support <span class="emphasis">style staring on one line and ending on another that may</span> be multiple lines off. </p><a name="OPTIONS"></a><h2 class="nroffsh">Options</h2>
<p class="level0"><a name="--bare"></a><span class="nroffip">--bare</span> </p>
<p class="level1">The output HTML will not include any HTML, HEAD or BODY tags. Also note that when this is selected, there will be no inlined CSS but you will have to define the necessary classes yourself. </p>
<p class="level1">The output HTML will not include any HTML, HEAD or BODY tags. Also not that when this is selected, there will be no inlined CSS but you will have to define the necessary classes yourself. </p>
<p class="level0"><a name="--mumbo"></a><span class="nroffip">--mumbo</span> </p>
<p class="level1">Display version number and exit. Also see <a class="bold" href="#--jumbo">--jumbo</a>. Word in bold. </p>
<p class="level0"><a name="--jumbo"></a><span class="nroffip">--jumbo</span> </p>
Expand All @@ -46,6 +35,6 @@
<p class="level0"><a name="spanemphasis"></a><span class="nroffip">span.emphasis</span> </p>
<p class="level1">Text marked to be emphasized. </p>
<p class="level0"><a name="proffit"></a><span class="nroffip">p.roffit</span> </p>
<p class="level1">Used for advertising final paragraph. </p><a name="WWW"></a><h2 class="nroffsh">Www</h2>
<p class="level1">Used for the advertising final paragraph. </p><a name="WWW"></a><h2 class="nroffsh">Www</h2>
<p class="level0"><a href="http://daniel.haxx.se/projects/roffit">http://daniel.haxx.se/projects/roffit</a> </p><p class="roffit">
This HTML page was made with <a href="http://daniel.haxx.se/projects/roffit/">roffit</a>.

0 comments on commit a2afb03

Please sign in to comment.