[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: opposite of \c?
From: |
Tadziu Hoffmann |
Subject: |
Re: opposite of \c? |
Date: |
Mon, 9 Sep 2024 20:47:59 +0200 |
User-agent: |
Mutt/1.11.4 (2019-03-13) |
> but i can't figure out how to inhibit the space for
> the end quote inside the macro, so it ends up like
>
> 'wow wow the text is quoted '
>
> is there an escape or a request that allows for this?
Many times have I wished for such a feature to exist,
but there is no equivalent to "\c" that can be applied
after the fact.
However: groff has the ".chop" request, which removes the last
character of a string/macro/diversion, and which we can try
to use to remove the last whitespace newline from the end of
the quoted text, before attaching the ending quote character.
But since chop only works on strings/macros/diversions, and
not on the running text, we first have to save the material
in a macro or diversion before we can do the chopping.
The attached code is an example of how this might be done.
For illustration purposes, it also shows the nesting level
alongside the quote characters.
But why does it work at all? The first call of .q( begins
at level 0 before "She said," but only scans forward until
the first .q) (after "nesting"), at a nesting level unknown
to the macro. (It just collects text, and can't count the
number of .q( and .q) encountered.)
The reason it works is that upon the first replay of the
collected qq the second .q( is invoked, which causes it to
redefine qq with the remainder of what had been read the first
time, plus additional material until the next .q), and so on.
Note that adding the ending quotes is delegated to a separate
macro .qe, which only gets expanded when the text is finally
processed for output and the correct nesting level is known,
and not when the line ".qe" is just copied from macro to macro.
We cannot add the ending quotes directly in .q), because the
numeric register ql will not necessarily contain the correct
quote level for the ending quote at the time .q) is called,
and since it is also invoked at different nesting levels,
we can't just add an appropriate number of backslashes.
nestedquotes.ro
Description: Text document
nestedquotes.pdf
Description: Adobe PDF document