John Gardner <gardnerjo...@gmail.com> wrote: > Recent discussion on this list about PDF and HTML links galvanised an > earlier attempt of mine to implement hyperlinks in Troff in a device- and > package-agnostic manner: It's still very much a W.I.P., but > > .[ "here's what I've done so far" ]( > https://github.com/Alhadis/Mono/commit/f363ed40d ) ,
This looks pretty cool and useful, albeit a bit mind warping to see Markdown and Troff mixed. I am hopeful that the pdfmark upgrade I made to www.tmac will be included in groff and am still making tweaks to perfect it. Does your package interpret the URL that's passed in? One thing I'm still figuring out for www.tmac is whether the location provided to the .URL macro should be used verbatim or interpreted. Not many documents have been written using www.tmac, but it looks like early on the URL had to be interpreted to avoid URLs running off the right margin. Each user needed to specify all potential line breaks by hand. For example, this was necessary, .URL "http://\:ftp.gnu.org/\:gnu/\:groff/" "GNU host" At some point, www.tmac gained the ability to automatically break long URLs after slashes, so this awkward syntax isn't necessary, nor is interpreting the URL. I believe www.tmac should act similarly to Heirloom Troff's \W: the URL should not be interpreted. But, there may be hidden downsides I don't know of. How does your Mono handle wrapping URLs? Do authors have to add "\:"? What happens if an author tries to add a possible break point that way? Do you have (or intend to have) automatic line breaking for URLs? It would be nice if there was a single macro that could be the Groff default for proper URL wrapping which encapsulated all the clever tips people have posted to this list. Here's the algorithm currently used by www.tmac, which only works on slashes. . .\" -------------------------------------------------------------------- .\" www:url_breaks (<string_name>) .\" .\" Add '\:' (possible break point) within URL strings after '/'. .\" .\" Smart about multiple '/', existing '\:', and space characters; .\" does not set a break point if less than 5 characters would go to .\" the next line. .\" .de www:url_breaks . if !(\\n[.$] == 1) \ . www:error .\\$0 expects 1 argument. . if !\n[www:substring_ok] \ . return . ds \\$0:s "\\*[\\$1]\" . www:splitstr \\$0:s . www:url_breaks_split \\$0:s \\*[\\$0:s] . ds \\$1 "\\*[\\$0:s]\" . rm \\$0:s .. . .\" -------------------------------------------------------------------- .\" www:url_breaks_split (<result> <char> [<char>...]) .\" .\" Add '\:' within URL strings, but arguments are a split string. .\" .\" Arguments: >=2: <result> <char> [<char>...] .\" .de www:url_breaks_split . nr \\$0:min 5 \" minimal number of characters for next line . if (\\n[.$] < 2) \ . www:error .\\$0 expects at least 2 arguments. . ds \\$0:res \\$1\" . shift . ds \\$0:s . nr \\$0:done 0 . while !\\n[\\$0:done] \{\ . if (\\n[.$] <= 0) \ . break . if '\\$1'space' \{\ . as \\$0:s " \" . shift . continue . \} . if (\\n[.$] < \\n[\\$0:min]) \{\ . as \\$0:s "\\$1\" . shift . continue . \} . if !'\\$1'/' \{\ . as \\$0:s "\\$1\" . shift . continue . \} . \" we are at a '/' character . while '\\$1'/' \{\ . as \\$0:s /\" . if (\\n[.$] == 0) \{\ . nr \\$0:done 1 . break . \} . shift . \} . if \\n[\\$0:done] \ . break . if (\\n[.$] < \\n[\\$0:min]) \ . continue . if '\\$1'\:' \ . shift . as \\$0:s \:\" . \} . ds \\*[\\$0:res] \\*[\\$0:s]\" . rm \\$0:res . rm \\$0:s .. Ideally, the www:url_breaks macro would add in optional breaks after every symbol, except period, percent, and hyphen. Period and percent would have breaks added before the symbol. (Hyphens wouldn't be added at line breaks and breaks wouldn't happen after hyphens, to avoid confusion.) --b9