[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [groff_www] Macro for codeblocks?
From: |
Meg McRoberts |
Subject: |
Re: [groff_www] Macro for codeblocks? |
Date: |
Sun, 5 Sep 2021 08:56:15 +0000 (UTC) |
Which macro set are you using? For mm, I think .DS/.DE used to do thisbut
it's been a while and things may have changed.
Try the following:
.DS<pre><code>
fun() {
echo "hello" > /dev/null 2>&1;
}
</code></pre>.DE
I added some additional spaces in front of the echo line -- I think the normis
to use 8 spaces or a tab for indented lines but maybe that's just me.
You could use .DS I to indent the entire display if you like.
On Saturday, September 4, 2021, 6:10:37 PM PDT, NRK <nrk@disroot.org>
wrote:
Hi,
Recently I've thought about using groff for writing static website. One
problem I've ran into is doing codeblocks. What I'm trying to do is
this:
.HTML <pre><code>
fun() {
echo "hello" > /dev/null 2>&1;
}
.HTML </code></pre>
However this doesn't preserve the indendation and newlines are not
properly preserved either. The output I'm trying to achieve is _exactly_
the following:
<pre><code>
fun() {
echo "hello" > /dev/null 2>&1;
}
</code></pre>
It should escape anything that needs escaping but preserve indendation
and newlines properly.
- NRK