Highlight GUI: Convert AsciiDoc README & CHANGELOG To PlainText
Ciao André,
I was looking at Highlight 3.47 and I noticed that now the AsciiDoc README and CHANGELOG files add some verbosity to the plaintext popup.
You mentioned that Qt doesn't handle well HTML, so I digged a little bit on how to converte AsciiDoc to PlainText. To make a long story short (see Issue #1636 for the full details), I followed @mojavelinux advise and tested a Node app called html-to-text-cli.
After a few attempts, and tweaking Asciidoctor's CLI options, as well as tml-to-text-cli's options, I got some good results and have published them on a Gist, batch script included:
-
adoc2txt.bat
— a sample batch that converts Highlight'sREADME.adoc
andChangeLog.adoc
to HTML and then to txt. -
README.txt
— preview of final result. -
ChangeLog.txt
— preview of final result.
The batch script is dead simple:
CALL :conv2txt README.adoc
CALL :conv2txt ChangeLog.adoc
EXIT /B
:conv2txt
CALL asciidoctor^
-a sectids!^
-a sectanchors!^
%1
TYPE %~n1.html | html-to-text^
--wordwrap=70^
--hideLinkHrefIfSameAsText=true^
--ignoreHref=true^
--unorderedListItemPrefix=" + "^
> %~n1.txt
EXIT /B
And only requires that Asciidoctor (+ Ruby) and html-to-text-cli (+ Node.js) are installed on the system — for the latter:
npm install html-to-text -g
The results are already acceptable (as you can see below, or at the links above), but further customizations are possible via JavaScript functions to process the specic tags (e.g. add Setext-style underlining, etc.).
So, you could adapt my sample script and add its invocation to the makefile
in order to create text versions of the various READMEs and CHANGELOG files required in Highlight GUI's pop-up dialogs, which might improve the text readability.
Since the dialogs are not very wide by default, I've also added to the batch an option to control wrapping width, so you could bring down to fit the window's size:
--wordwrap=70^
I hope it might help!
Tristano
CHANGELOG Preview
HIGHLIGHT 3.46
07.10.2018
* fixed xterm256 and truecolor whitespace output (
https://gitlab.com/saalen/highlight/issues/90
[https://gitlab.com/saalen/highlight/issues/90])
* converted manuals to AsciiDoc (thanks to Tristano Ajmone)
README Preview
OSI Certified Open Source Software
Deutsche Anleitung: README_DE [README_DE.adoc]
1. OVERVIEW
Highlight converts sourcecode to HTML, XHTML, RTF, ODT, LaTeX, TeX,
SVG, BBCode, Pango markup and terminal escape sequences with coloured
syntax highlighting. Syntax definitions and colour themes are
customizable.
1.1. INTENDED PURPOSE
Highlight was designed to offer a flexible but easy to use syntax
highlighter for several output formats. No syntax or colouring
information is hardcoded, instead all relevant data is stored in
configuration scripts. These Lua scripts may be altered and enhanced
with plug-ins.