pandoc is a tool suite for converting between text formats. I find it useful as a writer (rather than a techie) to convert something written in plain text into an RTF file that I can read readily, with some formatting, in a word processor, up to and including the dreaded Word. What I outline here is a tiny fraction of what it can do.
It is as simple as:
$ pandoc -s file.txt -o file.rtf
(Replace ‘rtf’ with html etc to get something else.)
It can convert a file of nothing but typing, but if you use a little simple formatting, pretty much a version of markdown syntax, you can get a nice RTF with some useful extra features (italics, for example). For a heading, underline with equals or hyphens on the very next line;
Heading here ------------
Heading here ============
when processed, that gives a heading. (Though for proper H1 H2 etc, see below.)
Paragraphing is determined by empty lines, so this text gives one paragraph in the RTF, and…
in the RTF.
If I want to force a return, I end a line with a backslash.
This will not work inside back ticks (see below), which is the verbatim environment, so for example if I want a bunch of stuff verbatim, without interparagraph spacing, I end each line with a backslash outside the backtics:
The word is the character used to delimit the modified text. The code, verbatim, is also given.
dollar (math, which does not translate into RTF)
Note that when using back ticks (verbatim) the nesting of the instructions matters
***back tick outside 3 asterisks***
3 asterisks outside back tick
2 asterisks outside back tick
1 asterisk outside back tick
(Note, line above (‘Other stuff’) was underlined with hyphens on the immediate next line.)
nonbreaking space – precede a space with a backslash: ‘\⌴’ (I’m using ⌴ for a space)
block quote: > (greater than introduces a block quote indented by 1 tab)
block quote, again: >> same, bigger indent
So, for example
>This text would appear as a block quote indented by 1 tab.
H1 (1 hash, #)
# Here is my heading 1
H2 (2 hashes, ##)
## Here is my heading 2
H3 (3 hashes, ###)
### Here is my heading 3
- bullet point (+ at start of line, then space)
- bullet point (- (hyphen) at start of line, then space)
- bullet point (* at start of line, then space)
- Numbered list
- Numbered list still
- Numbered list again
(just start a line with a number and a stop)
– 2 hyphens for en rule
— 3 hyphens for em rule
Some formats (eg HTML) like metadata to be specified. Simplest is to put
at the very top of the file (replace ‘title’, ‘author’ and ‘date’ with your own text).
The gnu program diction searches text files for known poor constructions, based on a database. (See also gnu style.)
I installed it from GetGnuWin32.
$ diction -s makeemf.txt makeemf.txt:5: I have all the poppler stuff installed, [so -> (do not use as intensifier)]: makeemf.txt:13: I use pdfcrop from TeXLive pdfcrop --margins "-52 -250 -20 -25" page4.pdf page4-crop.pdf [So -> (do not use as intensifier)] now I have my PDF. makeemf.txt:17: [Can -> (do not confuse with "may")] I import it into Word? 3 phrases in 14 sentences found.
The things to be checked are enclosed in square brackets. The -s causes diction to provide suggestions.
Tools to be used along with it might include unrtf, unhtml, libreoffice command line, and other tools that convert marked-up and formatted files to plain text.
Look here for interesting examples of how to make a custom style to find things in your documents: https://mrsatterly.com/diction.html
The diction databases are, in my case, stored in:
I imagine on a Linux system they’d be in /usr/share, but I have not checked. Anyway, typically a file look like this:
$ head /cygdrive/c/Users/darren/installs/getgnuwin32/GetGnuWin32/gnuwin32/share/diction/en a considerable amount of much a large number of many a lot of Often obsolete, should sometimes be replaced by "many" a majority of most a man who a matter of concern (cliche, avoid) a need for need a number of many, several a particular preference for a small number of few (and so on)
Note that the left is the phrase to check for — including any leading spaces — and then after a tab (must be a tab to distinguish it from spaces within the phrase) comes the suggestion, if there is one. Very simple!
Could easily make up a diction file to look for your pet hates or common errors.
The Text WINdow manager, twin, is quite a nice piece of software if you don’t
want to have to run X, though it can run within an X term.
I have found that it works extremely well with the ‘leggie’ fonts, from
Leggie, a legible, pretty bitmap font
Here is an example of a twin session, captured using fbcat.
So this was a twin session, using the leggie18 font, on a netbook.
twin has many capabilities — this only shows you what it looks like. One cannot run framebuffer graphics inside twin windows — eg fbi, or dosbox (which uses sdl) — but I have found that a twin window on one virtual console, and then a ‘bare’ framebuffer on a second one makes for a good combination for working without X.
I have noticed that some fonts give ugly outlines on the windows (rows of diamonds or non-characters). The leggie fonts on 32-bit Debian give neat lines around the windows. YMMV.
Some nice features include a built-in clock (see bottom-right corner), and the ability to type in a window while keeping it behind others. That’s why the screen capture command is invisible in the screen grab above. Alpine, links, lynx and other text-based network tools work fine, plus all your other console tools. It is very light on resources, too. top suggests it uses about 0.5% of my memory and CPU — and I am running an old netbook with 1GB RAM and an Atom N550 chip!
Could form the basis of a Linux distro to challenge TinyCore,
Note to self
- Booted Win 10 machine.
- Got usual login screen.
- Logged in as per usual.
- Got a black screen with a working, visible mouse pointer.
- Got the menu and chose Task Manager.
- Went to start up items and disabled most items, but enabled ‘Lenovo Utility’.
- Used Ctrl-Alt-Del to reboot.
- Got the screen back.
Of course, I’ve skipped all the messing around that I really did.
I don’t know why. Other non-admin account on the machine worked fine, so something funny happened in a setting somewhere. Anyway, there you go.
The whole world of ’tilde’ accounts is to give you a little server space where you can monkey around in bash and maybe build a website the 1990s way — by editing HTML in nano, emacs or vim.
Mine is here: https://tilde.club/~mz721/, and this is how it looked as-provided by the admin:
I have set it up so that if I scp files into the right directory, they will be automatically added to the index.html.
Consider the following bash script. I log into my account and run it from ~/public_html using nohup so that it does not stop when I log out. The makelinks.sh script lives in the ~/public_html/pages directory and just creates a block of HTML with links to each of the HTML files it finds in there.
The script then creates a little file with the time and date updated information in it, then cats all the bits together, then sleeps for a day and runs again. My scripting is very crude, but seems to work.
while true do cd pages ./makelinks.sh cd .. echo \<p\> \</p\> > date echo \<p\> \</p\> >> date echo Last updated: `date` >> date cat index.top.html pages/index.middle.html date index.tail.html > index.html rm date sleep 24h done
Here is the text of makelinks.sh. It loops over all the .html files in the directory. The echo command prints out a line of the form of a basic HTML link. It grabs the second line of the html file for use as the link text (that is what the head/tail bit does) then creates the link.
rm index.middle.html for f in *.html do echo \<p\>\<a href=\"pages/$f\"\>$(head -2 $f | tail -1)\</a\>\</p\> >> index.middle.html done
The output of makelinks.sh looks something like
$ cat pages/index.middle.html <p><a href="pages/hermes10.html">The Hermes 10 electric typewriter</a></p>
So all I have to do is make sure I upload a HTML file (with its dependencies) that looks something like the one below. Top 3 lines are:
- open comment
- link text
- close comment.
After that, any legit HTML should do.
<!-- Link text - always here. --> <html><head> <title>Title</title> </head> <center> <h1>Main heading</h1> </center> Content </body></html>
So I make up my new page locally, with the correct 3-line header, then scp it to the correct folder, and the script wakes up once a day and adds the page to the index.
Crude, but effective. Obviously, I can complexify what I do and add more features, but I’ll let that evolve with time.
Here’s a random example for no good reason.
Here is the gnuplot script (surfaceplot.gp):
set iso 30 set samp 50 unset key #set title "sin(r)" set xlabel "x" font "Times:Italic,14" set ylabel "y" font "Times:Italic,14" set zlabel "z" font "Times:Italic,14" set xrange [-4:4] set yrange [-4:4] set xtics offset -0.5,-0.5 set ztics 1 unset surf set style line 1 lt 4 lw 0.5 set pm3d set term post level1 color font "Times,12" fontscale 1.0 set output "plotfile.eps" splot sin(sqrt(x**2+y**2))
Here are the commands run at the command line:
$ gnuplot surfaceplot.gp $ epspdf plotfile.eps $ xpdf plotfile.pdf $ pdftoppm.exe -r 600 plotfile.pdf > plotfile.ppm $ convert plotfile.ppm plotfile.png $ display plotfile.png $ rm plotfile.ppm
And this gives me an eps, a pdf and a png:
89K plotfile.eps 56K plotfile.pdf 990K plotfile.png
And here’s a simple script to plot sections through the surface:
$ cat cuts.gp unset key #set title "sin(r)" set xlabel "x" font "Times:Italic,18" set ylabel "z" font "Times:Italic,18" set xrange [-4:4] set yrange [-1:1] set border lw 0.25 #set style line 1 lt 4 lw 0.5 set term post level1 color font "Times,12" fontscale 1.0 set output "plotfile-cut-y=0.eps" plot sin(sqrt(x**2+0**2)) lc rgb 'black' lw 4 set output "plotfile-cut-y=1.eps" plot sin(sqrt(x**2+1**2)) lc rgb 'black' lw 4
And here is plotfile-cut-y=1