Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to suppress hyphenation / inline URL #88

Open
mcclure opened this issue Jan 16, 2015 · 6 comments
Open

No way to suppress hyphenation / inline URL #88

mcclure opened this issue Jan 16, 2015 · 6 comments

Comments

@mcclure
Copy link

mcclure commented Jan 16, 2015

I am attempting to use ronn for a manpage. It is doing everything I need EXCEPT: I need to include a URL in the manpage. The convention in manpages for this is to enter the URL in angle brackets, like http://example.com

In my current ronn file, it says:

Documentation of the Emily programming language can be found at <<http://emilylang.org>> or <<http://bitbucket.org/runhello/emily>>.

The inner <> gets me an underline, and the outer <> gets me enclosing angle brackets. But unfortunately, when I look at my generated .1 file in man, I get:

Documentation  of  the  Emily  programming  language can be found at <http://emily-
lang.org> or <http://bitbucket.org/runhello/emily>.

This is catastrophic, it makes it appear the URL is http://emily-lang.org , which is incorrect.

The documentation for roff notes that there is a syntax for suppressing hyphenation on something (prefix with %). But it does not appear ronn exposes a way to access this.

Including URLs is a common thing for manpages. I would like to suggest ronn do one of the following to support this:

  • Auto-detect URLs within the document and automatically suppress hyphenation for them.
  • Support the standard Markdown URL syntax, when generating HTML turn this into a link, when generating roff turn it into the link text (if different from the URL) followed by the URL itself, underlined and surrounded by angle brackets and suppressing hyphenation.
  • Add a syntax to suppress hyphenation.

It appears that the man format also has some kind of standard "extension" for URLs. I cannot comment on whether it would make sense to leverage that.

@apjanke
Copy link

apjanke commented Dec 25, 2018

This appears to me to be an issue with the man page formatter used to display the resulting roff files. The hyphenation does not appear in the raw roff output from ronn:

$ cat test/urls-and-long-lines.ronn
URLs, hyphenation, and long lines
=================================

Documentation of the Emily programming language can be found at [http://emilylang.org](http://emilylang.org) or [http://bitbucket.org/runhello/emily](http://bitbucket.org/runhello/emily).

Here's a normal paragraph.
[~/local/repos/ronn-ng]
$ bin/ronn test/urls-and-long-lines.ronn --roff --pipe
.\" generated with Ronn-NG/v0.8.0
.\" http://github.com/apjanke/ronn-ng/tree/0.8.0-SNAPSHOT
.
.TH "URLS\-AND\-LONG\-LINES" "" "December 2018" "" ""
Documentation of the Emily programming language can be found at \fIhttp://emilylang\.org\fR or \fIhttp://bitbucket\.org/runhello/emily\fR\.
.
.P
Here\'s a normal paragraph\.

In #89, you suggest using raw inlined ROFF as a workaround. But I don't see a way in ROFF itself to suppress hyphenation like this. Is there a particular mechanism you're thinking of?

I also tried using the GNU groff URL extensions, using .UR/.UE to set the URLs (I think that's what you were referring to), like this:

.\" generated with Ronn-NG/v0.8.0
.\" http://github.com/apjanke/ronn-ng/tree/0.8.0-SNAPSHOT
.
.TH "URLS\-AND\-LONG\-LINES" "" "December 2018" "" ""
Documentation of the Emily programming language can be found at
.
.UR http://emilylang\.org
http://emilylang\.org
.
.UE
 or
.
.UR http://bitbucket\.org/runhello/emily
http://bitbucket\.org/runhello/emily
.
.UE
\&\.
.
.P
Here\'s a normal paragraph\.

but they still end up wrapped and hyphenated when viewed in man.

screen shot 2018-12-24 at 9 02 14 pm

@mcclure
Copy link
Author

mcclure commented Dec 27, 2018

Hi,
As my original post was from three years ago I'm not quite sure what I was thinking…
However, I do notice

  1. The GNU groff manual https://www.gnu.org/software/groff/manual/html_node/Manipulating-Hyphenation.html references a character sequence

     \%
    

    which it says "Preceding a word with this character prevents it from being hyphenated". That is a backslash followed by a percent sign. Maybe either in my previous post I made a mistake or Github ate the backslash in my 2015 post.

    If I put this in my .1 file and run it through man:

     .P
     Documentation of the Emily programming language can be found at <\fIhttp://emilylang\.org\fR> or <\fIhttp://bitbucket\.org/runhello/emily\fR>\.
    

    and view in Mac OS X 10.13.2 man at 96 columns, I find it hyphenates after emily, but if I insert the \% characters as such:

     .P
     Documentation of the Emily programming language can be found at \%<\fIhttp://emilylang\.org\fR> or \%<\fIhttp://bitbucket\.org/runhello/emily\fR>\.
    

    the hyphen does not appear. I see the same behavior in Ubuntu 14.04.5 LTS man (although there I must use 90 columns to see the hyphen).

    I do not know how to tell if \% is part of standard roff or a GNU extension which OS X has somehow adopted.

  2. That GNU manual also references a .nh which can be used to disable hyphenation completely. It appears one could insert this before a URL and then .hy 1 afterward to restore the default behavior. I do not know if this is more or less standard than \%.

  3. "This appears to me to be an issue with the man page formatter used to display the resulting roff files. The hyphenation does not appear in the raw roff output from ronn:" While this is technically true, to me the goal of producing a roff file is to distribute it to a user so that the user can feed it into their local man executable. Therefore it should be the job of ronn to produce sufficiently standard roff files that we can assume a user's man will present it in the expected way. A standard behavior in man is to hyphenate, so it is desirable if for URLs ronn can suppress hyphenation in a standard way…

@apjanke
Copy link

apjanke commented Dec 27, 2018

Oh, cool. I didn't get that about the \% from my initial read-through. And I didn't know about the .nh/.hy, either - I think they could be used because groff is pretty widespread.

I agree with your point 3.

I'll give this a try. Thanks.

@mcclure
Copy link
Author

mcclure commented Dec 27, 2018

Well my original post doesn't say \%… I do say "%" at one point… but that doesn't do anything :)

Thanks

@apjanke
Copy link

apjanke commented Jan 8, 2019

That \% did the trick; thanks.

screen shot 2019-01-07 at 10 32 23 pm

I've implemented this in my "Ronn-NG" fork over at apjanke/ronn-ng#23 if you're interested in using it.

@mcclure
Copy link
Author

mcclure commented Jan 9, 2019

Thanks; actually Emily is no longer an active project but I will keep your fork in mind when I next need manpages…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants