groff
[Top][All Lists]
Advanced

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

Re: [groff] Creating a numbered list without macros


From: Yves Cloutier
Subject: Re: [groff] Creating a numbered list without macros
Date: Sat, 11 Aug 2018 16:10:32 -0400

Hello Ingo, thanks for the tips, comments and questions.

No there is no parsing involved. I'm using the red programming language, a
derivative of rebol. This language doesn't use parentheses for function
calls.

title {...}
p {...}
blockquote {..}

are functions I created that take a string as an argument. In red multiline
strings use curly braces as an alternative to double quotes.

So there is no parsing here. This is program source code. I just didn't
include the function definitions here.

Why do my own thing thing instead of using existing macros? I guess the
question could also have been asked to those who created all the other
macros ;) Why create ms when you have mm? Why create mom when you have mm
and ms?

The short answer is that those macros are too level even for me. As a
writer, I just want to write - I don't want to put on my programmer hat. It
disrupts my train of thought to have to try to remember what;s the command
for this or that. I just want to write.

The other part to this answer is that I like to know how things work. So
lthis is partially me learning how to typeset with groff, without relying
on macros.

I know for most people on the board, this is probably second nature to you
now. But it's a hug learning curve for me and anyone else who's starting
out.  My target audience is not the seasoned groffer. It's the writer who's
looking for high quality typesetting, who doesn't want to go the latex
route. For those people, the generated PDF is the result. It's unlikely
they will want or have to look at the generated groff. The whole idea is to
abstract that away for them.  Just like a user of OpenOffice is never gonna
look at the underlying xml generated by the tool.

That being said this is just a prototype, a minimum viable product. I will
certainly improve on the generated code by adding units etc as well as
styling options etc...So far this is jut the result of 1 day's work ;)
Many more to go.








*From*: Ingo Schwarze
*Subject*: Re: [groff] Creating a numbered list without macros
*Date*: Sat, 11 Aug 2018 18:12:18 +0200
*User-agent*: Mutt/1.8.0 (2017-02-23)
------------------------------

Hi Yves,

Yves Cloutier wrote on Sat, Aug 11, 2018 at 11:32:57AM -0400:

>* .br*
>* .sp*

That is redundant.  The .sp request already implies .br,
see:https://www.gnu.org/software/groff/manual/html_node/Manipulating-Spacing.html#index-sp

>* .ll -5*
>* .in +3*
>* .ti -1*

For .in and .ti, the default scaling indicator is m, but i would
consider in good practice to explicitly specify it for readability.

Why are you reducing the line length?  It doesn't seem required
around a list.  The .in request does not move the line length to
the right, the indentation is part of the line length.  Besides,
for .ll, the manual doesn't even specify the default unit, so
specifying the unit seems even more helpful for clarity.

>* Probably not ideal it did give me the output that I was looking for.*
>*  As I mentionned I'm using a programming language*

What you show below is not a programming language but a markup language.

>* title         {My New Book}*
>* subtitle     {And Other Gems}*
>* h1 {1 Level 1 Heading}*

Just curious - why are you using a syntax that is structurally
different from, but functionally equivalent to roff macro syntax?
It seems to me that you get the downside of having to implement
your own parser (as opposed to trivially being able to just use the
groff parser), but you don't get any additional benefit that i can
see for that additional effort.

Same question asked in a different way, why don't you just implement
a macro set?

Oh, and why don't you just pick one of the existing macro sets?  I
think all of them can do what you are showing here, so you would
save even more effort using one of them, with the additional benefit
that other people could more easily read your document because it
would be written in a well-known markup language rather than in a
newly invented one.

Yours,
  Ingo




On Sat, Aug 11, 2018 at 11:32 AM Yves Cloutier <address@hidden>
wrote:

> Ralph, Ted,
>
> Thank you both for your help!  Right after sending in my question I found
> something helpful in the Troff User Manual you mention.
>
> A bit different than your solution but seems to work, at least with my
> test. It goes something like this:
>
> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ut
> fringilla felis. Sed lacus eros, sagittis quis elit at, pretium vehicula
> mi. Praesent augue libero, porttitor bibendum varius pharetra, euismod eget
> nisl. In viverra finibus neque, sit amet venenatis augue elementum nec.
> .br
> .sp
> .ll -5
> .in +3
> .ti -1
> 1. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ut
> fringilla felis. Sed lacus eros, sagittis quis elit at, pretium vehicula
> mi. Praesent augue libero, porttitor bibendum varius pharetra, euismod eget
> nisl. In viverra finibus neque, sit amet venenatis augue elementum nec.
> .br
> .sp 0.3
> .ti -1
> 2. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ut
> fringilla felis. Sed lacus eros, sagittis quis elit at, pretium vehicula
> mi. Praesent augue libero, porttitor bibendum varius pharetra, euismod eget
> nisl. In viverra finibus neque, sit amet venenatis augue elementum nec.
> .br
> .sp 0.3
> .ti -1
> 3. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ut
> fringilla felis. Sed lacus eros, sagittis quis elit at, pretium vehicula
> mi. Praesent augue libero, porttitor bibendum varius pharetra, euismod eget
> nisl. In viverra finibus neque, sit amet venenatis augue elementum nec.
> .br
> .in
> .ll
> .sp
> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ut
> fringilla felis. Sed lacus eros, sagittis quis elit at, pretium vehicula
> mi. Praesent augue libero, porttitor bibendum varius pharetra, euismod eget
> nisl. In viverra finibus neque, sit amet venenatis augue elementum nec.
>
> Probably not ideal it did give me the output that I was looking for.  As I
> mentionned I'm using a programming language to generate groff, my program
> looking something like this, where title, subtitle, h1, p etc are functions
> that take a string.
>
> title         {My New Book}
> subtitle     {And Other Gems}
>
> h1 {1 Level 1 Heading}
> p {Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ut
> fringilla felis. Sed lacus eros, sagittis quis elit at, pretium vehicula
> mi. Praesent augue libero, porttitor bibendum varius pharetra, euismod eget
> nisl. In viverra finibus neque, sit amet venenatis augue elementum nec.}
>
> p {Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ut
> fringilla felis. Sed lacus eros, sagittis quis elit at, pretium vehicula
> mi. Praesent augue libero, porttitor bibendum varius pharetra, euismod eget
> nisl. In viverra finibus neque, sit amet venenatis augue elementum nec.}
>
> blockquote {Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla
> ut fringilla felis. Sed lacus eros, sagittis quis elit at, pretium vehicula
> mi. Praesent augue libero, porttitor bibendum varius pharetra, euismod eget
> nisl. In viverra finibus neque, sit amet venenatis augue elementum nec.}
>
> p {Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ut
> fringilla felis. Sed lacus eros, sagittis quis elit at, pretium vehicula
> mi. Praesent augue libero, porttitor bibendum varius pharetra, euismod eget
> nisl. In viverra finibus neque, sit amet venenatis augue elementum nec.}
>
> h2 {1.1 Level 2 Heading}
> p {Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ut
> fringilla felis. Sed lacus eros, sagittis quis elit at, pretium vehicula
> mi. Praesent augue libero, porttitor bibendum varius pharetra, euismod eget
> nisl. In viverra finibus neque, sit amet venenatis augue elementum nec.}
>
> p {Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ut
> fringilla felis. Sed lacus eros, sagittis quis elit at, pretium vehicula
> mi. Praesent augue libero, porttitor bibendum varius pharetra, euismod eget
> nisl. In viverra finibus neque, sit amet venenatis augue elementum nec.}
>
> list "1" ")" [
>     li {Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ut
> fringilla felis. Sed lacus eros.}
>     li {Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ut
> fringilla felis. Sed lacus eros,}
>     li {Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ut
> fringilla felis. Sed lacus eros.}
> ]
>
> p {Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ut
> fringilla felis. Sed lacus eros, sagittis quis elit at, pretium vehicula
> mi. Praesent augue libero, @href[porttitor http://www.cool.com] bibendum
> @index[varius] pharetra, euismod eget nisl. In viverra finibus neque, sit
> amet venenatis augue elementum nec.}
>
> On Sat, Aug 11, 2018 at 3:46 AM Ralph Corderoy <address@hidden>
> wrote:
>
>> Hi Yves,
>>
>> > What approach would I take? Is this something that can be done with
>> > tabs?
>>
>> The tutorial in CSTR 54, logical page `- 32 -', defines the `lp'
>> labelled paragraph macro that uses tabs.  https://troff.org/54.pdf
>> If you're starting troff, that slim document is well worthy of repeated
>> careful study.
>>
>> > a combination of indents?
>>
>> Ted's pointed out the combination of indents.  Another way that's
>> sometimes seen is to move left with `\h' to out-dent the item's
>> `bullet'.
>>
>>     $ cat list.tr
>>     .na
>>     .nh
>>     .pl 10
>>     .ll 32
>>     .nr i 0 1
>>     .af i i
>>     Before.
>>     .sp
>>     .in 8
>>     .ds l "\n+i. \"
>>     \h'-\w'\*l'u'\*lFirst.
>>     .br
>>     .ds l "\n+i. \"
>>     \h'-\w'\*l'u'\*lSecond.
>>     A lot longer list item this time.
>>     .br
>>     .ds l "\n+i. \"
>>     \h'-\w'\*l'u'\*lThird.
>>     .in
>>     .sp
>>     After.
>>     $
>>     $ nroff list.tr
>>     Before.
>>
>>          i. First.
>>         ii. Second.  A lot longer
>>             list item this time.
>>        iii. Third.
>>
>>     After.
>>
>>
>>     $
>>
>> The tedious repetition is well suited to being your own macro definition
>> you have in your prologue.
>>
>> --
>> Cheers, Ralph.
>> https://plus.google.com/+RalphCorderoy
>>
>


reply via email to

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