9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] Any way to insert code verbatim bypassing the rest of parsing in troff?
@ 2024-06-02 18:47 ygrex
  2024-06-02 18:54 ` sl
  2024-06-02 22:53 ` [9front] " Anthony Martin
  0 siblings, 2 replies; 4+ messages in thread
From: ygrex @ 2024-06-02 18:47 UTC (permalink / raw)
  To: 9front

Hello,

Tried my best in troff to insert a block of code varbatim but it does
not work as I would like it to.

First attempt with .DS/.DE ms macros breaks my backslashes, I need to
replace them with '\e'.

Second attempt to leverage .eo/.ec to keep backslashes, it does but
breaks code lines, I need to insert extra empty lines in between to
keep the lines. It looks worse than with .DS/.DE after all.

Unfortunately, mixing .DS/.DE with .eo/.ec does not work, backslashes
get removed as I tried.

As far as I figured it out, .DS/.DE block gives the best results but
can I bypass its backslash interpolation somehow?

-- 
Sincerely yours,

Igor Bogomazov
Saint Petersburg, Russia


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9front] Any way to insert code verbatim bypassing the rest of parsing in troff?
  2024-06-02 18:47 [9front] Any way to insert code verbatim bypassing the rest of parsing in troff? ygrex
@ 2024-06-02 18:54 ` sl
  2024-06-02 22:53 ` [9front] " Anthony Martin
  1 sibling, 0 replies; 4+ messages in thread
From: sl @ 2024-06-02 18:54 UTC (permalink / raw)
  To: 9front

you can insert a program like this:

	.P1
	[program text]
	.P2

but you will still need to escape single quotes, backslashes,
etc., like so:

	.P1
	echo \'key proto=dp9ik dom=9front user=glenda !password=p@ssw0rd\' \e
		>/mnt/factotum/ctl
	aux/listen1 -t \'tcp!*!rcpu\' /rc/bin/service/tcp17019
	.P2

i've never found any way to avoid this.

sl

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [9front] Re: Any way to insert code verbatim bypassing the rest of parsing in troff?
  2024-06-02 18:47 [9front] Any way to insert code verbatim bypassing the rest of parsing in troff? ygrex
  2024-06-02 18:54 ` sl
@ 2024-06-02 22:53 ` Anthony Martin
  2024-06-03  6:21   ` ygrex
  1 sibling, 1 reply; 4+ messages in thread
From: Anthony Martin @ 2024-06-02 22:53 UTC (permalink / raw)
  To: 9front

ygrex <ygrex@ygrex.ru> once said:
> As far as I figured it out, .DS/.DE block gives the best results but
> can I bypass its backslash interpolation somehow?

No. DS switches to a separate environment so you'd have to modify
tmac.s to do this.

> Second attempt to leverage .eo/.ec to keep backslashes, it does but
> breaks code lines, I need to insert extra empty lines in between to
> keep the lines. It looks worse than with .DS/.DE after all.

You can turn off filling and disable the escape mechanism with:

.nf
.eo
some text with backslashes like \ and \foo.

and empty lines like above.
just don't start a line with a control character:
	.this is good
\.as is this
.but not this
'or this.
see?
.ec
.fi

Cheers,
  Anthony

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9front] Re: Any way to insert code verbatim bypassing the rest of parsing in troff?
  2024-06-02 22:53 ` [9front] " Anthony Martin
@ 2024-06-03  6:21   ` ygrex
  0 siblings, 0 replies; 4+ messages in thread
From: ygrex @ 2024-06-03  6:21 UTC (permalink / raw)
  To: 9front

Thank you everyone for the suggestions.

On Sun, 2 Jun 2024 15:53:01 -0700
Anthony Martin <ality@pbrane.org> wrote:

> You can turn off filling and disable the escape mechanism with:
> 
> .nf
> .eo
> some text with backslashes like \ and \foo.
> 
> and empty lines like above.
> just don't start a line with a control character:
> 	.this is good
> \.as is this
> .but not this
> 'or this.
> see?
> .ec
> .fi
> 

This seems exactly what I needed. To make it look more like a
code block I ended up with the following incantation:

.RS
.fw CW
.nf
.eo

code follows here

.ec
.fi
.ft
.RE

It results in being indented and in constant width font.
Some precautions needed if it gets spanned to the next page though, .bp
helps to save formatting.

-- 
Sincerely yours,

Igor Bogomazov
Saint Petersburg, Russia


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-06-03  6:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-02 18:47 [9front] Any way to insert code verbatim bypassing the rest of parsing in troff? ygrex
2024-06-02 18:54 ` sl
2024-06-02 22:53 ` [9front] " Anthony Martin
2024-06-03  6:21   ` ygrex

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 NNTP newsgroup(s).