opus6: format Katolaz's article - tgtimes - The Gopher Times HTML git clone git://bitreich.org/tgtimes git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/tgtimes DIR Log DIR Files DIR Refs DIR Tags DIR README --- DIR commit a490b2664631b88b9b72da536fc98f46af996d35 DIR parent 6cb09c45ab9e637ffdcc811e868b1dbdb14bcbb2 HTML Author: Josuah Demangeon <me@josuah.net> Date: Sat, 3 Sep 2022 20:48:24 +0200 opus6: format Katolaz's article Diffstat: M opus6/article-ig0r-I-Hate-Modern-T… | 28 +++++++++++++++++++++------- M opus6/article-katolaz-formatting-p… | 190 ++++++++++++++++++++++++++++++- 2 files changed, 210 insertions(+), 8 deletions(-) --- DIR diff --git a/opus6/article-ig0r-I-Hate-Modern-Technology.mw b/opus6/article-ig0r-I-Hate-Modern-Technology.mw @@ -2,7 +2,8 @@ I Hate Modern Technology . .PP -Modern technology sucks. This might be me behaving like a pathetic little angsty hipster or trying to LARP thinking I’m somehow cool, but I think it’s a genuine problem. +Modern technology sucks. +This might be me behaving like a pathetic little angsty hipster or trying to LARP thinking I’m somehow cool, but I think it’s a genuine problem. . .SS Planned Obsolesence @@ -14,16 +15,20 @@ Technology is being designed to fail. Apple purposefully makes batteries fail on their devices and solders them in such that replacing the battery on an older device makes no sense, forcing the customer to buy a new device. .PP -Lenovo’s quality has gone down the shitter. Thinkpads used to be thick, bulky, and rugged such that a caveman could use it in place of a club. New models bend and creak, the hinges breaking after several years of use while older models still run like new. +Lenovo’s quality has gone down the shitter. +Thinkpads used to be thick, bulky, and rugged such that a caveman could use it in place of a club. +New models bend and creak, the hinges breaking after several years of use while older models still run like new. . .PP -The reality is companies want people to consume technology, not use it. They care about making a profit rather than giving users a good experience, hence poor quality of manufacturing to speed up distribution, consumption, and the filling of landfills. +The reality is companies want people to consume technology, not use it. +They care about making a profit rather than giving users a good experience, hence poor quality of manufacturing to speed up distribution, consumption, and the filling of landfills. . .SS Modern Software Sucks . .PP -Modern software is just bad. Here’s a few reasons why… +Modern software is just bad. +Here’s a few reasons why… . .IP \(bu It’s idiot proof, in that I have little control over settings and configuration @@ -41,10 +46,17 @@ Smartphones Smartphones are the most annoying little shits, and for some reason they’ve become ubiquitous. . .PP -Restaurants are starting to ditch regular menus in favor of QR codes to be scanned with smartphones. Why? Paper is more reliable. This is a step backwards in my opinion. What if I don’t have a data plan? What if I don’t carry a smartphone? +Restaurants are starting to ditch regular menus in favor of QR codes to be scanned with smartphones. +Why? +Paper is more reliable. +This is a step backwards in my opinion. +What if I don’t have a data plan? +What if I don’t carry a smartphone? . .PP -Also why does everything have to be an app? Why does my passport have to be an app? I’m perfectly happy carrying around paper ID (paper ID doesn’t spy on my). +Also why does everything have to be an app? +Why does my passport have to be an app? +I’m perfectly happy carrying around paper ID (paper ID doesn’t spy on my). . .SS People are idiots @@ -53,4 +65,6 @@ People are idiots Most companies justify making technology suck more by saying it’s ‘easier’ and more ‘convenient’ for normal people. . .PP -Stop making easy and more convenient. Nobody asked for that. We were happy when technology was hard. +Stop making easy and more convenient. +Nobody asked for that. +We were happy when technology was hard. DIR diff --git a/opus6/article-katolaz-formatting-paragraphs.mw b/opus6/article-katolaz-formatting-paragraphs.mw @@ -1 +1,189 @@ -gopher://republic.circumlunar.space/0/~katolaz/phlog/20190213_fold.txt +.SH katolaz +fold, fmt, par: get your text in order +. +.PP +If you happen to read plain text files (e.g., phlog posts), you have +probably noticed that, especially on gopher, the lines of a text file +tend to be wrapped all to a similar length. Some authors are very strict +on the matter, and like all the lines to be "justified" (i.e., all +adjusted to have exactly the same length, by inserting a few spaces to +get the count right). Some other authors (including myself) just do not +allow any line to be longer than a certain amount of characters (in this +case, as you might have noticed, the magic number is 72). But how to +they manage to do that? +. +.PP +Most common editors have a command to format a paragraph ('M-q' in +Emacs, 'gwip' or '{gq}' in vim normal mode, etc.). But obviously, +there are several Unix tools that can help you getting the right +formatting for your files. We are talking of fold(1), fmt(1), and +par(1), so keep reading if you want to know more. +. +.PP +The oldest one is probably `fold(1)` (and it is also the only one to be +defined in the POSIX standard...). It will just break each line to make +it fit a given length in characters (by default, 72, which is indeed a +magic number). Let's see how to wrap the lines of this post at 54 +characters: +. +.DS +$ fold -w 54 20190213_fold.txt | head -10 + fold, fmt, par: get your text in order +============================================ + +If you happen to read plain text files (e.g., phlog po +sts), you have +probably noticed that, especially on gopher, the lines + of a text file +tend to be wrapped all to a similar length. Some autho +rs are very strict +on the matter, and like all the lines to be "justified +$ +.DE +. +.PP +Notice that fold(1) did not really think twice before breaking "posts" +or "authors" across two lines. This is pretty inconvenient, to say the +least. You can actually force fold(1) to break stuff at blank spaces, +using the '-s' option: +. +.DS +$ fold -w 54 -s 20190213_fold.txt |head -10 + fold, fmt, par: get your text in order +============================================ + +If you happen to read plain text files (e.g., phlog +posts), you have +probably noticed that, especially on gopher, the +lines of a text file +tend to be wrapped all to a similar length. Some +authors are very strict +on the matter, and like all the lines to be +$ +.DE +. +.PP +Nevertheless, the output of fold(1) is still quite off: it breaks lines +at spaces, but it does not "join" broken lines to have a more consistent +formatting. This is where `fmt(1)` jumps in: +. +.DS +$ fmt -w 54 20190213_fold.txt |head -10 + fold, fmt, par: get your text in order +============================================ + +If you happen to read plain text files (e.g., phlog +posts), you have probably noticed that, especially on +gopher, the lines of a text file tend to be wrapped +all to a similar length. Some authors are very strict +on the matter, and like all the lines to be +"justified" (i.e., all adjusted to have exactly the +same length, by inserting a few spaces to get the +$ +. +.PP +Now we are talking: fmt(1) seems to be able to to "the right thing" +without much effort, and it has a few other interesting options as well. +Just have a look at the manpage. Simple and clear. +. +.PP +Last but not least, `par(1)` can do whatever fmt(1) and fold(1) can do, +plus much, much more. For instance: +. +.DS +$ par 54 < 20190213_fold.txt | head -10 + fold, fmt, par: get your text in order +============================================ + +If you happen to read plain text files (e.g., phlog +posts), you have probably noticed that, especially on +gopher, the lines of a text file tend to be wrapped +all to a similar length. Some authors are very +strict on the matter, and like all the lines to be +"justified" (i.e., all adjusted to have exactly the +same length, by inserting a few spaces to get the +$ +.DE +. +.PP +will give more or less the same output as fmt(1). But: +. +.DS +$ par 54j < 20190213_fold.txt | head -10 + fold, fmt, par: get your text in order +============================================ + +If you happen to read plain text files (e.g., phlog +posts), you have probably noticed that, especially on +gopher, the lines of a text file tend to be wrapped +all to a similar length. Some authors are very +strict on the matter, and like all the lines to be +"justified" (i.e., all adjusted to have exactly the +same length, by inserting a few spaces to get the +$ +.DE +. +.PP +will additionally "justify" your lines to the prescribed width, while: +something like: +. +.DS +$ head file.h + * + * include/linux/memory.h - generic memory definition + * + * This is mainly for topological representation. We define the + * basic "struct memory_block" here, which can be embedded in per-arch + * definitions or NUMA information. + * + * Basic handling of the devices is done in drivers/base/memory.c + * and system devices are handled in drivers/base/sys.c. + * +$ +.DE +. +.PP +can be easily transformed into: +. +.DS +$ par 40j < file.h + * + * include/linux/memory.h - generic + *memory definition + * + * This is mainly for topological + * representation. We define the basic + * "struct memory_block" here, which can + * be embedded in per-arch definitions + * or NUMA information. + * + * Basic handling of the devices is + * done in drivers/base/memory.c and + * system devices are handled in + * drivers/base/sys.c. + * + * Memory block are exported via + * sysfs in the class/memory/devices/ + * directory. + * + * +$ +. +.PP +Pretty neat, right? +.FS +To be honest, par is not the typical example of a unix tool that +"does exactly one thing", but it certainly "does it very well" all the +things it does. The author of par(1) felt the need to apologise in the +manpage about the style of his code and documentation, but I still think +par(1) is an awesome tool nevertheless. +.FE +. +.IP "fold(1)" +appeared in BSD1 (1978-1979) +. +.IP "fmt(1)" +appeared in BSD1 (1978-1979) +. +.IP "par(1)" +was developed by Adam Costello in 1993, as a replacement for fmt(1).