groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Nesting macros interpolated as strings


From: onf
Subject: Nesting macros interpolated as strings
Date: Sat, 05 Oct 2024 23:32:33 +0200

Hi all,

I am trying to nest multiple macros which are called using string
syntax with arguments. I intend to use this to build macros which
can be combined, such as a superscript within an italic macro
(which automatically adds italic correction between the italic
text and anything immediately preceding or following it).

Here is a short example of the sort of thing I am trying to get
to work:
  .\" groff -b -ww -Tpdf FILE.tr > FILE.pdf
  .
  .ds 1 "\\$0\s+5<\\$1:\\$2>\s-5\" original inline "macro"
  .als 2 1
  .als 3 1
  .
  .ps 20
  .nr sp 1.5m
  .sp \n[sp]u
  Lorem ipsum \*[1 "\*[2 A B]" C] dolor
  .sp \n[sp]u
  sit \*[1 A "\*[2 "B\*[3 C D]E" F]G" H] amet.
  .
  .de 1  \" converted into an actual macro
  \\$0\\c
  . ps +5
  <\\$1:\\$2>\\c
  . ps -5
  \&\\
  ..
  .
  .sp \n[sp]u
  Lorem ipsum \*[1 "\\*[2 A B]" C] dolor
  .sp \n[sp]u
  sit \*[1 A "\\*[2 "B\\\\*[3 C D]E" F]G" H] amet.

The first portion where an actual string is used works fine.
Once I change it to be an actual macro, though, it reports this:
  troff: backtrace: 'FILE.tr':17: macro '1'
  troff: backtrace: file 'FILE.tr':25
  troff:FILE.tr:25: error: missing ']'

The thing is that this happens even though the opening & closing
braces are balanced and all the parameters which contain nested
string escapes are quoted. The way in which it breaks slightly
changes depending on how many backslashes I put in front of the
escapes, but I haven't found any amount that works correctly.

What am I doing wrong?

Thanks in advance for any suggestions,
~ onf



reply via email to

[Prev in Thread] Current Thread [Next in Thread]