diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt index 0c14ee7fe..b93d321fd 100644 --- a/docs/CHANGES.txt +++ b/docs/CHANGES.txt @@ -6,7 +6,7 @@ Copyright (c) 2002-2023 Various contributors (see below, and AUTHORS.txt) https://tuxpaint.org/ -2023.July.13 (0.9.31) +2023.July.15 (0.9.31) * New Magic Tools: ---------------- * Loops - Draw loop-the-loops. @@ -105,6 +105,12 @@ https://tuxpaint.org/ and keyboard accessibility mode). Bill Kendrick + * Using `w3m` (rather than `links`) to generated plain text + alternatives to HTML documentation. (It handles word-wrapping + Japanese text properly.) + h/t TOYAMA Shin-ichi + Bill Kendrick + * Bug Fixes: ---------- * In some window size / button size combinations, Eraser diff --git a/docs/Makefile b/docs/Makefile index 5af3a67b2..2cffd41f9 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,21 +1,23 @@ # Makefile for Tux Paint docs -# +# # Uses "links" to convert docs from HTML to plain text. # (Normally only ran by the developers after updating the HTML, prior to # release.) # # Bill Kendrick # bill@newbreedsoftware.com -# -# Sept. 4, 2005 - June 29, 2023 +# +# Sept. 4, 2005 - July 16, 2023 # FIXME: Japanese does not wordwrap in many cases, leading to very long # lines in the TXT output. Post-processing with `fmt` doesn't look like # it would help, because it doesn't know how to wrap Japanese, either. # -bjk 2023.05.02 +# HTML2TXT_OPTIONS:=-dump -codepage utf8 -width 80 +# HTML2TXT:=links $(HTML2TXT_OPTIONS) -LINKS_OPTIONS:=-dump -codepage utf8 -width 80 -LINKS:=links $(LINKS_OPTIONS) +HTML2TXT_OPTIONS:=-dump -cols 80 -no-graph -o pseudo_inlines=f -o display_image=f -T text/html +HTML2TXT:=./w3m.sh $(HTML2TXT_OPTIONS) EN_HTMLFILES:=$(wildcard en/html/*.html) EN_TEXTFILES:=$(patsubst en/html/%.html,en/%.txt,$(EN_HTMLFILES)) @@ -80,35 +82,34 @@ clean: $(ZH_TW_TEXTFILES) $(EN_TEXTFILES): en/%.txt: en/html/%.html - $(LINKS) $< > $@ + $(HTML2TXT) $< > $@ $(ES_TEXTFILES): es_ES.UTF-8/%.txt: es_ES.UTF-8/html/%.html - $(LINKS) $< > $@ + $(HTML2TXT) $< > $@ $(FR_TEXTFILES): fr_FR.UTF-8/%.txt: fr_FR.UTF-8/html/%.html - $(LINKS) $< > $@ + $(HTML2TXT) $< > $@ $(GL_TEXTFILES): gl_ES.UTF-8/%.txt: gl_ES.UTF-8/html/%.html - $(LINKS) $< > $@ + $(HTML2TXT) $< > $@ $(IS_TEXTFILES): is_IS.UTF-8/%.txt: is_IS.UTF-8/html/%.html - $(LINKS) $< > $@ + $(HTML2TXT) $< > $@ $(IT_TEXTFILES): it/%.txt: it/html/%.html - $(LINKS) $< > $@ + $(HTML2TXT) $< > $@ $(JA_TEXTFILES): ja_JP.UTF-8/%.txt: ja_JP.UTF-8/html/%.html - $(LINKS) $< > $@ + $(HTML2TXT) $< > $@ $(NL_TEXTFILES): nl/%.txt: nl/html/%.html - $(LINKS) $< > $@ + $(HTML2TXT) $< > $@ $(RU_TEXTFILES): ru/%.txt: ru/html/%.html - $(LINKS) $< > $@ + $(HTML2TXT) $< > $@ $(ZH_CN_TEXTFILES): zh_cn/%.txt: zh_cn/html/%.html - $(LINKS) $< > $@ + $(HTML2TXT) $< > $@ $(ZH_TW_TEXTFILES): zh_tw/%.txt: zh_tw/html/%.html - $(LINKS) $< > $@ - + $(HTML2TXT) $< > $@ diff --git a/docs/cjkwrap-docs.py b/docs/cjkwrap-docs.py deleted file mode 100755 index e80dc2e49..000000000 --- a/docs/cjkwrap-docs.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env python3 - -# FIXME: Under construction! -# Experimental script to try and wrap -# Japanese plaintext docs, since `links` does not -# currently do this properly. -bjk 2023.07.15 - -import cjkwrap - -with open('ja_JP.UTF-8/README.txt') as f: - while True: - line = f.readline() - if not line: - break - - oldlen = len(line) - line = line.lstrip() - newlen = len(line) - indent = oldlen - newlen - - wrappedlines = cjkwrap.wrap(line, 78 - indent) - for l in wrappedlines: - print(" " * indent, end="") - print(l) - -f.close() - diff --git a/docs/w3m.sh b/docs/w3m.sh new file mode 100755 index 000000000..29193da2f --- /dev/null +++ b/docs/w3m.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +infile=${@: -1} +args=${@:1:${#}-1} + +sed -e "s/<\\/dd>/<\\/dd>/g" $infile | w3m $args +