Skip to content

Commit e6de99e

Browse files
committed
update
1 parent 460ffc2 commit e6de99e

File tree

1 file changed

+39
-7
lines changed

1 file changed

+39
-7
lines changed

raku-advent-2022/articles/tbrowder.md

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Santa's world was increasingly going high-tech, and his IT department was polish
55

66
One problem had initially stymied them, but consultants from the Raku community came to their aid. (As you may recall, IT had become primarily a Raku shop because of the power of the language for all their programming needs ranging from shop management to long-range planning.) The problem was converting the digital output from the OCR hardware to final PDF products for the factories and toy makers. The growing influence of [https://github.com](https://github.com) and its Github-flavored Markdown format had resulted in IT's post-OCR software converting the text into that format.
77

8-
That was fine for initial use for production planning, but for archival purposes it lacked the capability to provide textual hints to create beautiful digital documents for permanent storage. The Raku consultants suggested converting the Markdown to Rakupod which has as much potential expressive, typesetting power as Donald Knuth's TeX and its descendants (e.g., Leslie Lamport's LaTex, ConTeXt, and XeTeX). As opposed to those formats, the product is much easier to scan visually and, although current Raku products are in the early stages of development, the existing Rakupod-to-PDF process can be retroactively improved by modifying the existing Rakupod when future products are improved.
8+
That was fine for initial use for production planning, but for archival purposes it lacked the capability to provide textual hints to create beautiful digital documents for permanent storage. The Raku consultants suggested converting the Markdown to **Rakupod** which has as much potential expressive, typesetting power as Donald Knuth's TeX and its descendants (e.g., Leslie Lamport's LaTex, ConTeXt, and XeTeX). As opposed to those formats, the product is much easier to scan visually and, although current Raku products are in the early stages of development, the existing Rakupod-to-PDF process can be retroactively improved by modifying the existing Rakupod when future products are improved.
99

1010
Side note: Conversion between various digital document formats has been a fruitful arena for academics as well as developers. Raku already has excellent converters from Rakupod to:
1111

@@ -15,7 +15,7 @@ Side note: Conversion between various digital document formats has been a fruitf
1515

1616
* HTML
1717

18-
Other non-Raku converters include [Pandoc](https://pandoc.org) and [Sphinx](https://sphinx-doc.org) which strive to be *universal* converters with varying degrees of fidelity depending upon the input or output formats chosen.
18+
Other non-Raku converters include [Pandoc](https://pandoc.org) and [Sphinx](https://sphinx-doc.org) which strive to be *universal* converters with varying degrees of fidelity depending upon the input or output formats chosen. (However, this author has not been able to find an output format in that set capable of centering text without major effort. That includes Markdown which can only center text through use of inserted html code.)
1919

2020
But back to the immediate situation: getting Markdown transformed to PDF.
2121

@@ -36,17 +36,18 @@ The second step is Rakupod to PDF, but that step can be further broken down into
3636

3737
* Transform PostScript to PDF (ps2pdf)
3838

39-
Santa's IT group decided, given the current state of Raku modules, one of the easiest ways is to use David Warring's modules `Pod::Lite` and the very new module `Pod::To:PDF::Lite` for the direct transformation. That module has encapsulated the huge, low-level collection of PDF utility routines into an easier-to-use interface to get typesetting quality output. (Note David is actively improving the module so keep an eye out for updates.)
39+
Santa's IT group decided, given the current state of Raku modules, one of the easiest ways is to use David Warring's modules `Pod::Lite` and his very new module `Pod::To:PDF::Lite` for the direct transformation. That module has encapsulated the huge, low-level collection of PDF utility routines into an easier-to-use interface to get typesetting quality output. (Note David is actively improving the module so keep an eye out for updates.)
4040

4141
But that route has a bump in the road: `PDF::Lite` requires the user to provide the `$=pod` object (technically it is the root node of a Raku tree-like sructure). That is easy if you're calling it inside a Raku program, but not if you're trying to access it from another program or module. Thus comes a new Raku module to the rescue. The clever algorithm that makes that possible is due to the Raku expert Vadim Belman (AKA @vrurg), and it has been extracted for easy use into a new module **RakupodObject**.
4242

4343
So, using those three modules, we get the following code:
4444

4545
```raku
46-
use Pod::To::PDF::Lite;
4746
use Pod::Lite;
47+
use Pod::To::PDF::Lite;
4848
use RakupodObject;
4949
my $pod-object = rakupod2object $pod-doc;
50+
# pod2pdf $pod-object # args ...
5051
```
5152

5253
IT used the module in its wrapper program and added some convenience input options. Raku is used World-wide so they allowed for various paper sizes and provide settings for US Letter and A4. Finally, they provided some other capabilities by customizing the `PDF::Lite` object after the base document was created:
@@ -55,15 +56,22 @@ IT used the module in its wrapper program and added some convenience input optio
5556

5657
* Provide a cover and a title for the unified document
5758

58-
* Provide a unified set of page numbers for the unified document
59+
* Provide a cover and a title for each of the two articles
5960

6061
```raku
6162
TO BE ADDED
6263
```
6364

64-
Finally, a prettier version of PDF is produced. More features could be added with more detailed, but more complex, processing with other `PDF::*` modules, but that project is for another day--Santa's archivist Elves are happy for now!
65+
In summary, developers finally have a direct and robust way to convert complex documents written in Rakupod into the universal PDF format. Using the semantics of Rakupod to affect the conversion to PDF will improve **Pod::To::PDF::Lite** output to suit authors. For example, here is a Rakupod block that could be used to define defaults for PDF output:
66+
67+
=begin pdf-config
68+
=Config :head1 :font<Times-RomanBold> :size<16> :align<center>:
69+
=Config :head2 :font<Times-RomanBold> :size<14> :align<center>:
70+
=end pdf-config
6571

66-
And the product is a present from Santa to all the Raku-using folks around the world: the two-part article from Tony O'Dell (AKA @tony-o) for creating an Apache website with Jonathon's Raku `Cro` libraries! (See the original posts at [Part1](https://deathbykeystroke.com/articles/20220224-building-a-cro-app-part-1.html) and [Part2](https://deathbykeystroke.com/articles/20220923-building-a-cro-app-part-b.html).)
72+
But that project is for another day--Santa's archivist Elves are happy for now!
73+
74+
The final product of a real-world test of the Markdown-to-PDF work flow is a present from Santa to all the Raku-using folks around the world: a PDF version of the two-part article from Tony O'Dell (AKA @tony-o) for creating an Apache website with Jonathon's Raku `Cro` libraries! (See the original posts at [Part1](https://deathbykeystroke.com/articles/20220224-building-a-cro-app-part-1.html) and [Part2](https://deathbykeystroke.com/articles/20220923-building-a-cro-app-part-b.html).) See the PDF document at [An Apache/Cro Webserve](https://github.com/raku/advent/blob/). (See also Footnote 3 about a lurking bug in the POD-to-PDF tool chain.)
6775

6876
Santa's Epilogue
6977
----------------
@@ -77,3 +85,27 @@ Footnotes
7785

7886
1. *A Christmas Carol*, a short story by Charles Dickens (1812-1870), a well-known and popular Victorian author whose many works include *The Pickwick Papers*, *Oliver Twist*, *David Copperfield*, *Bleak House*, *Great Expectations*, and *A Tale of Two Cities*.
7987

88+
2. Code used in this article is available at [https://github.com/tbrowder/raku-advent-extras/tree/master/2022](https://github.com/tbrowder/raku-advent-extras/tree/master/2022)
89+
90+
3. There is a bug in the POD-to-PDF tool chain that causes some characters in a `=begin code / =end code` block not to be rendered. For example, this input in Tony's article, Part 1, in the pod source is
91+
92+
.
93+
+-- bin
94+
| +-- app
95+
+-- lib
96+
+-- META6.json
97+
+-- resources
98+
+-- templates
99+
100+
and it renders in PDF as
101+
102+
.
103+
bin
104+
app
105+
lib
106+
META6.json
107+
resources
108+
templates
109+
110+
An issue has been filed with `Pod::To::PDF::Lite`.
111+

0 commit comments

Comments
 (0)