emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "onf" <onf@disroot.org>
To: "Ihor Radchenko" <yantar92@posteo.net>
Cc: "G. Branden Robinson" <g.branden.robinson@gmail.com>,
	<emacs-orgmode@gnu.org>, <groff@gnu.org>,
	"Ingo Schwarze" <schwarze@usta.de>
Subject: Re: [BUG] ox-man: Nested markup is broken (was: [BUG] "\fC" macro in ox-man.el [9.6.15 (release_9.6.15 @ /usr/share/emacs/29.2/lisp/org/)])
Date: Thu, 02 Jan 2025 22:51:47 +0100	[thread overview]
Message-ID: <D6RX4ZLXLQ59.VMDXN7G22NP3@disroot.org> (raw)
In-Reply-To: <87seq1qfa1.fsf@localhost>

On Thu Jan 2, 2025 at 6:47 PM CET, Ihor Radchenko wrote:
> "onf" <onf@disroot.org> writes:
> [...]
> > It's important to understand that troff commands don't really use
> > nesting or a stack as one might be used to from HTML and similar
> > markup languages. That's why it's also not possible to e.g. nest
> > bold and italic like this:
> >   Normal \fBbold \fIbold-italic\fP bold\fP normal
> >
> > ...which actually gives you:
> >   Normal bold italic bold italic
>
> Yikes!
>
> We currently implicitly rely on the assumption that things are working
> differently:
>
>     normal *bold /italic/ bold* normal
>
> is exported as
>
>     .TH "" "1" 
>     .PP
>     normal \fBbold \fIitalic\fP bold\fP normal
>
> and the last "normal" is indeed rendered as italic.
>
> > One has to do one of these instead:
> >   Normal \fBbold \f[BI]bold-italic\fP bold\fR normal
> >   Normal \fBbold \f[BI]bold-italic\fB bold\fR normal
> >   Normal \fBbold\fP \f[BI]bold-italic\fP \fBbold\fP normal
>
> I'm afraid that I'll need to rethink that export algo for ox-man to
> account for this nuance.
>
> Probably, the simplest way implementation-wise will be applying faces to
> each "plain text" segment individually:
>
>    \fRnormal \fR\fBbold \fR\f[BI]italic\fR\fB bold\fR\fR normal\fR

I assume you meant:
  \fRnormal \fP\fBbold \fP\f[BI]italic\fP\fB bold\fP\fR normal\fP

You might find it easier to omit the \fP escapes, since they have
little effect here anyway. Situation might be different if you're
targetting non-troff man processors too, though; no idea how
robust their handling of font changes is.

But I agree; I would track each style change (bold -> not bold,
italic -> not italic) and emit an appropriate \f sequence that
would match the currently active styles after each such change,
like so:
  code & bold & italic  \f[CBI]
  code & bold           \fC\f(CB
  code & italic         \fC\f(CI
  code                  \fC\f(CR
  bold & italic         \f(BI
  bold                  \fB
  italic                \fI
  none                  \fR

Note that \f[CBI] will break in old troffs due to the "new" \f[]
syntax, so a warning should probably be emitted. And I have no
idea how good support for {bold,italic} Courier is in older troffs
either. (That is assuming Org-mode markup allows code to be styled
like that.)

Also note that if a change involving italic happens between two
non-whitespace characters, like so:
  groff(/7/)

...an italic correction should be emitted to prevent the two glyphs
colliding into each other:
  groff(\,\fI7\fR\/)
where:
  \,  is left italic correction
  \/  is right italic correction

~ onf


  reply	other threads:[~2025-01-02 21:52 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-01  7:51 [BUG] "\fC" macro in ox-man.el [9.6.15 (release_9.6.15 @ /usr/share/emacs/29.2/lisp/org/)] Xiyue Deng
2024-03-03 13:30 ` Ihor Radchenko
2024-03-12  0:06   ` Xiyue Deng
2024-03-13 11:25     ` Ihor Radchenko
2024-03-14 21:46       ` Jeremy Sowden
2024-05-22  9:54         ` Ihor Radchenko
2024-12-18 17:20         ` G. Branden Robinson
2024-12-22 15:41           ` Ihor Radchenko
2024-12-31 17:00             ` G. Branden Robinson
2024-12-31 18:15               ` Ihor Radchenko
2024-12-31 18:42                 ` onf
2024-12-31 18:54                   ` onf
2025-01-01  9:38                   ` Ihor Radchenko
2025-01-01 12:30                     ` onf
2025-01-02 14:29                       ` onf
2025-01-02 17:47                       ` [BUG] ox-man: Nested markup is broken (was: [BUG] "\fC" macro in ox-man.el [9.6.15 (release_9.6.15 @ /usr/share/emacs/29.2/lisp/org/)]) Ihor Radchenko
2025-01-02 21:51                         ` onf [this message]
2025-01-03  8:38                           ` [BUG] "\fC" macro in ox-man.el [9.6.15 (release_9.6.15 @ /usr/share/emacs/29.2/lisp/org/)] G. Branden Robinson
2025-01-04  0:23                             ` onf
2025-01-04  6:37                               ` G. Branden Robinson
2025-01-04 20:10                                 ` onf
2025-01-05 15:24                                   ` Lennart Jablonka
2025-01-04 13:26                             ` Ihor Radchenko
2025-01-04 16:22                               ` Dave Kemper
2025-01-04 17:37                                 ` Ihor Radchenko
2025-01-02 12:14                     ` G. Branden Robinson
2025-01-04 12:21                       ` Ihor Radchenko
2025-01-02 12:38                 ` G. Branden Robinson
2025-01-02 14:21                   ` onf
2025-01-04 12:36                   ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D6RX4ZLXLQ59.VMDXN7G22NP3@disroot.org \
    --to=onf@disroot.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=g.branden.robinson@gmail.com \
    --cc=groff@gnu.org \
    --cc=schwarze@usta.de \
    --cc=yantar92@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).