lots of changes

ended up making this a lot more complex:

- moved the document itself to `src/guide.xml`
- added dependency: `xq` converts xml to json
- added dependency: mustache converts json to groff
- moved helper groff macros to `src/guide.tmac`

learned some groff after reading *Unix Text Processing*

https://www.oreilly.com/openbook/utp/

- made the `ul` macro a conditional toggle
- fixed the formatting issues i had with the section headers and also
  moved the section numbering to a global number register, and just
  formatted it as an Alpha character
- the numbering issue with the item list was simply that i wasn't
  escaping the register name enough times
main
Dozens B. McCuzzins 2024-01-22 10:28:25 -07:00
parent 470ca0f735
commit 4bf0b21b2e
8 changed files with 130 additions and 147 deletions

View File

@ -1,8 +1,36 @@
# Practice Guide
# PRACTICE GUIDE
A generic version of the Practice Guide for Computer
without the dependency on LaTeX.
You will instead need just groff and m4.
View original here:
https://codeberg.org/oneirophage/practice-guide-for-computer
View original here: <https://codeberg.org/oneirophage/practice-guide-for-computer>
## YOU WILL NEED
- m4: change MUSIC to COMPUTER. (Note to self: Why not just use sed?) https://www.gnu.org/software/m4/manual/m4.html
- groff: pdf output. https://www.gnu.org/software/groff/manual/groff.html
- mustache: for templating. https://mustache.github.io/
- xq: a wrapper for jq that adds support for xml. https://kislyuk.github.io/yq/#xml-support
## YOU WILL FIND HERE
```
.
├── README.md
├── guide.pdf
├── justfile
└── src
├── guide.tmac
├── guide.tmpl
└── guide.xml
2 directories, 6 files
```
1. README.md: you're reading it!
2. guide.pdf: the output
3. justfile: build command
4. guide.tmac: some groff helper macros
5. guide.tmpl: the mustache template that creates the groff
6. guide.xml: the actual document source

View File

@ -1,80 +0,0 @@
define(`MUSIC',`COMPUTER')dnl
.
.
.
.de Heading
.sp
.SH
.LG
.B "\\$*"
.sp
..
.
.
.
.ce 2
.ps 21
.B "Practice Guide for MUSIC"
.ps
.sp
Adapted from oneirophage's practice-guide-for-computer\**
.FS
https://codeberg.org/oneirophage/practice-guide-for-computer
.FE
.sp
.LP
.ps 16
Before starting your daily practice routine, read and seriously consider the following:
.
.
.Heading "A.\h'1m'DAILY AFFIRMATIONS"
.RS
.nr i 0 1
.IP \n+[i] 2m
How fortunate I am that in this life I am one who has been allowed to create beauty with MUSIC.
.IP \n+[i] 2m
It is my responsibility to create peace, beauty, and love with MUSIC.
.RE
.
.
.
.Heading "B.\h'1m'I WILL BE KIND TO MYSELF"
.RS
.nr i 0 1
.IP \n+[i] 2m
IT IS ONLY MUSIC
.IP \n+[i] 2m
No matter my level of development in MUSIC, how good or bad I think I am, it is only MUSIC and I am a beautiful person.
.IP \n+[i] 2m
I will not compare myself with my colleagues. If they do MUSIC beautifully, I will enjoy it and be thankful and proud that I live in fellowship with them.
.IP \n+[i] 2m
There will always be someone with more abilities in MUSIC than my own as there will be those with less.
.RE
.
.
.
.Heading "C.\h'1m'REASONS TO DO MUSIC"
.RS
.nr i 0 1
.IP \n+[i] 2m
To contribute to the world's spiritual growth.
.IP \n+[i] 2m
To contribute to my own self-discovery and spiritual growth.
.IP \n+[i] 2m
To pay homage to all the great practitioners of MUSIC, past and present, who have added beauty to the world.
.RE
.
.
.
.Heading "D.\h'1m'RID YOUR SELF OF THE FOLLOWING REASONS FOR BEING A PRACTITIONER OF MUSIC"
.RS
.nr i 0 1
.IP \n+[i] 2m
To create self-esteem
.IP \n+[i] 2m
To be "hip"
.IP \n+[i] 2m
To manipulate
.IP \n+[i] 2m
To get rich or famous
.RE

BIN
guide.pdf

Binary file not shown.

View File

@ -1,59 +0,0 @@
Practice Guide for COMPUTER
Before starting your daily practice routine, read and seriously
consider the following:
A. DAILY AFFIRMATIONS
1 How fortunate I am that in this life I am one who has been
allowed to create beauty with COMPUTER.
2 It is my responsibility to create peace, beauty, and love
with COMPUTER.
B. I WILL BE KIND TO MYSELF
1 IT IS ONLY COMPUTER
2 No matter my level of development in COMPUTER, how good or
bad I think I am, it is only COMPUTER and I am a beautiful
person.
3 I will not compare myself with my colleagues. If they do
COMPUTER beautifully, I will enjoy it and be thankful and
proud that I live in fellowship with them.
4 There will always be someone with more abilities in COM-
PUTER than my own as there will be those with less.
C. REASONS TO DO COMPUTER
1 To contribute to the world's spiritual growth.
2 To contribute to my own self-discovery and spiritual
growth.
3 To pay homage to all the great practitioners of COMPUTER,
past and present, who have added beauty to the world.
D. RID YOUR SELF OF THE FOLLOWING REASONS FOR BEING A PRACTI-
TIONER OF COMPUTER
1 To create self-esteem
2 To be "hip"
3 To manipulate
4 To get rich or famous

View File

@ -1,5 +1,5 @@
build:
m4 guide.ms | groff -Tpdf -ms > guide.pdf
watch:
ls guide.ms | entr -r just build
pdf:
m4 -DMUSIC=COMPUTER src/guide.xml \
| xq . \
| mustache - src/guide.tmpl \
| groff -Tpdf -ms > guide.pdf

25
src/guide.tmac 100644
View File

@ -0,0 +1,25 @@
.de Heading
.sp
.SH
.IP \f[B]\s+2\\n+[HX].\s0\f[] 5n
.B
.LG
\\$*
.sp
..
.
.
.de UL
.ie !"\\$1"" \{\
. RE\}
.el \{\
. RS
. nr idx 0 1\}
..
.
.
.de li
.IP \\n+[idx]. 2m
\\$*
..

36
src/guide.tmpl 100644
View File

@ -0,0 +1,36 @@
{{#doc}}
.nr HY 0 \" Turn off hypenation
.nr HX 0 1
.af HX A
.so src/guide.tmac
.
.
.
{{#header}}
.\" HEADER
.ce 2
.ps 21
.B "{{title}}"
.ps
.sp
.LP
.ps 16
.vs 16
{{tagline}}
.\" END HEADER
{{/header}}
.
.
.
{{#main}}
.\" MAIN
{{#section}}
.Heading {{title}}
. UL
{{#item}}
. li {{{.}}}
{{/item}}
. UL OFF
{{/section}}
{{/main}}
{{/doc}}

33
src/guide.xml 100644
View File

@ -0,0 +1,33 @@
<doc>
<header>
<title>Practice Guide for MUSIC</title>
<tagline>Before starting your daily practice routine, read and seriously consider the following:</tagline>
</header>
<main>
<section>
<title>DAILY AFFIRMATIONS</title>
<item>How fortunate I am that in this life I am one who has been allowed to create beauty with MUSIC.</item>
<item>It is my responsibility to create peace, beauty, and love with MUSIC.</item>
</section>
<section>
<title>I WILL BE KIND TO MYSELF</title>
<item>IT IS ONLY MUSIC</item>
<item>No matter my level of development in MUSIC, how good or bad I think I am, it is only MUSIC and I am a beautiful person.</item>
<item>I will not compare myself with my colleagues. If they do MUSIC beautifully, I will enjoy it and be thankful and proud that I live in fellowship with them.</item>
<item>There will always be someone with more abilities in MUSIC than my own as there will be those with less.</item>
</section>
<section>
<title>REASONS TO DO MUSIC</title>
<item>To contribute to the world's spiritual growth.</item>
<item>To contribute to my own self-discovery and spiritual growth.</item>
<item>To pay homage to all the great practitioners of MUSIC, past and present, who have added beauty to the world.</item>
</section>
<section>
<title>RID YOUR SELF OF THE FOLLOWING REASONS FOR BEING A PRACTITIONER OF MUSIC</title>
<item>To create self-esteem</item>
<item>To be "hip"</item>
<item>To manipulate</item>
<item>To get rich or famous</item>
</section>
</main>
</doc>