From 64973b69ebd84f605126707375f271cb94ae1b44 Mon Sep 17 00:00:00 2001 From: Xiangdong Zeng Date: Fri, 10 Apr 2020 03:14:27 +0800 Subject: [PATCH] clean up directories --- .gitignore | 38 +----- build.lua | 106 ++++++++++++++-- scripts/build-save.sh | 12 -- scripts/get-doc-en.lua | 114 ------------------ scripts/zhconvert.sh | 16 --- source/zhlipsum-text.dtx => zhlipsum-text.dtx | 0 source/zhlipsum.dtx => zhlipsum.dtx | 6 +- 7 files changed, 100 insertions(+), 192 deletions(-) delete mode 100644 scripts/build-save.sh delete mode 100644 scripts/get-doc-en.lua delete mode 100644 scripts/zhconvert.sh rename source/zhlipsum-text.dtx => zhlipsum-text.dtx (100%) rename source/zhlipsum.dtx => zhlipsum.dtx (99%) diff --git a/.gitignore b/.gitignore index 502dc24..e18304e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,43 +1,9 @@ -*.aux -*.dvi -*.fdb_latexmk -*.fls -*.fmt -*.glg -*.glo -*.gls -*.hd -*.idx -*.ilg -*.ind -*.log -*.map -*.out -*.synctex.gz -*.synctex(busy) -*.thm -*.toc -*.xdv - *.pdf *.zip -*.sty -*.def -*.ins - .DS_Store + .vscode/ -CTAN/ -TDS/ build/ +support/ test/ - -*.bat - -source/*.sh -source/*.md -source/*.tex -source/ctxdoc.cls -source/latexmkrc -source/latexmkrc-en diff --git a/build.lua b/build.lua index 4cfdd76..ceb5edd 100644 --- a/build.lua +++ b/build.lua @@ -4,8 +4,6 @@ module = "zhlipsum" -sourcefiledir = "./source" - sourcefiles = {"*.dtx"} installfiles = {"*.sty", "*.def"} unpackfiles = {"zhlipsum.dtx"} @@ -20,15 +18,6 @@ typesetsuppfiles = {"ctxdoc.cls"} typesetexe = "xelatex" makeindexexe = "zhmakeindex" -function docinit_hook(file) - local cmd = "texlua" .. " " - .. "../../scripts/get-doc-en.lua" .. " " - .. typesetfiles[1] .. " " - .. typesetfiles[2] - run(typesetdir, cmd) - return 0 -end - stdengine = "xetex" checkengines = {"pdftex", "xetex", "luatex"} specialformats = {} @@ -37,6 +26,101 @@ specialformats.latex = { uptex = {binary = "euptex"} } +function docinit_hook(file) + get_en_doc(typesetdir .. "/" .. typesetfiles[1], + typesetdir .. "/" .. typesetfiles[2]) + return 0 +end + +function get_en_doc(input, output) + local file_banner = "%%\n" + .. "%% This is file `zhlipsum-en.tex',\n" + .. "%% generated with Lua script `get-doc-en.lua'.\n" + .. "%%\n" + .. "%% The original source files were:\n" + .. "%%\n" + .. "%% zhlipsum.dtx\n" + local tag_preamble_str = "\\preamble" + local tag_endpreamble_str = "\\endpreamble" + local tag_driver_begin_str = "%<*driver>" + local tag_driver_end_str = "%" + local tag_inline_str = "%^^A!" + local tag_begin_str = "%^^A+" + local tag_end_str = "%^^A-" + local tag_str_len = string.len(tag_inline_str) + local function test_tag(str, tag) + return string.sub(str, 1, string.len(tag)) == tag + end + local function remove_normal_space(str) + -- Normal text lines begin with 2 spaces. + -- `3` is the first non-space char's position. + return string.sub(str, 3) + end + local function process_preamble_line(str) + return "%% " .. str + end + local function process_verbatim_line(str) + return remove_normal_space(str) + end + local function process_normal_line(str) + return string.sub(str, tag_str_len + 2) + end + -- Test whether it's in the preamble. + local preamble_flag = 0 + -- Test whether it's in the driver part. + local driver_flag = 0 + -- Test whether it's in the verbatim environment. + local inside_flag = 0 + -- Begin processing + local input_file = io.open(input, "r") + local output_file = io.open(output, "w") + output_file:write(file_banner) + for line in input_file:lines() do + -- Check for the preamble, as DocStrip does. + if test_tag(line, tag_preamble_str) then + preamble_flag = preamble_flag + 1 + elseif test_tag(line, tag_endpreamble_str) then + preamble_flag = preamble_flag - 1 + else + -- Check if in the driver part. + if test_tag(line, tag_driver_begin_str) then + driver_flag = driver_flag + 1 + elseif test_tag(line, tag_driver_end_str) then + driver_flag = driver_flag - 1 + else + -- If beginning with `%^^A+` or `%^^A-`, then increase or + -- decrease the flag, in order to determine the start or end + -- position of verbatim. + if test_tag(line, tag_begin_str) then + inside_flag = inside_flag + 1 + elseif test_tag(line, tag_end_str) then + inside_flag = inside_flag - 1 + else + if preamble_flag == 1 then + output_file:write(process_preamble_line(line), "\n") + elseif driver_flag == 1 then + -- Inside <*driver> ... . + -- Similar to normal text but do not have `% ` at beginning. + if inside_flag == 1 then + output_file:write(line, "\n") + elseif test_tag(line, tag_inline_str) then + output_file:write(process_normal_line(line), "\n") + end + elseif inside_flag == 1 then + -- If inside_flag = 1, then it's a verbatim environment. + output_file:write(process_verbatim_line(line), "\n") + elseif test_tag(line, tag_inline_str) then + -- If beginning with `%^^A!`, then this line is normal text. + output_file:write(process_normal_line(line), "\n") + end + end + end + end + end + input_file:close() + output_file:close() +end + function zhconv(input, output, encoding) local input_tmp = input .. ".tmp" local cmd_cp = "cp" .. " " .. input .. " " .. input_tmp diff --git a/scripts/build-save.sh b/scripts/build-save.sh deleted file mode 100644 index d7a2fd0..0000000 --- a/scripts/build-save.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env sh - -# TEST_FILES_UTF8="internal api user encodings01 encodings02 encodings03 encodings04 encodings05 encodings06 encodings07 encodings08 compilation-utf8" -# TEST_FILES_GBK_BIG5="cjk01 cjk02 cjk03 encodings01 encodings02 encodings03 encodings04 encodings05 encodings06 encodings07 encodings08 compilation-gbk compilation-big5" - - -TEST_FILES_UTF8="internal api" -TEST_FILES_GBK_BIG5="cjk01 cjk02" - -texlua build.lua save -e xetex $TEST_FILES_UTF8 -texlua build.lua save -e luatex $TEST_FILES_UTF8 -texlua build.lua save $TEST_FILES_GBK_BIG5 diff --git a/scripts/get-doc-en.lua b/scripts/get-doc-en.lua deleted file mode 100644 index a1bc9bf..0000000 --- a/scripts/get-doc-en.lua +++ /dev/null @@ -1,114 +0,0 @@ -#!/usr/bin/env texlua - --- Generate the English version of the documentation. - -local input_file_name = arg[1] -local output_file_name = arg[2] - -local file_banner = "%%\n" - .. "%% This is file `zhlipsum-en.tex',\n" - .. "%% generated with Lua script `get-doc-en.lua'.\n" - .. "%%\n" - .. "%% The original source files were:\n" - .. "%%\n" - .. "%% zhlipsum.dtx\n" - -local tag_preamble_str = "\\preamble" -local tag_endpreamble_str = "\\endpreamble" - -local tag_driver_begin_str = "%<*driver>" -local tag_driver_end_str = "%" - -local tag_inline_str = "%^^A!" -local tag_begin_str = "%^^A+" -local tag_end_str = "%^^A-" -local tag_str_len = string.len(tag_inline_str) - -local function test_tag(str, tag) - if string.sub(str, 1, string.len(tag)) == tag then - return true - end - return false -end - -local function remove_normal_space(str) - -- Normal text lines begin with 2 spaces. - -- `3` is the first non-space char's position. - return string.sub(str, 3) -end - -local function process_preamble_line(str) - return "%% " .. str -end - -local function process_verbatim_line(str) - return remove_normal_space(str) -end - -local function process_normal_line(str) - return string.sub(str, tag_str_len + 2) -end - ----------------------- --- Begin processing -- ----------------------- - -input_file = io.open(input_file_name, "r") -output_file = io.open(output_file_name, "w") - --- Test whether it's in the preamble. -preamble_flag = 0 - --- Test whether it's in the driver part. -driver_flag = 0 - --- Test whether it's in the verbatim environment. -inside_flag = 0 - -output_file:write(file_banner) - -for line in input_file:lines() do - -- Check for the preamble, as DocStrip does. - if test_tag(line, tag_preamble_str) then - preamble_flag = preamble_flag + 1 - elseif test_tag(line, tag_endpreamble_str) then - preamble_flag = preamble_flag - 1 - else - -- Check if in the driver part. - if test_tag(line, tag_driver_begin_str) then - driver_flag = driver_flag + 1 - elseif test_tag(line, tag_driver_end_str) then - driver_flag = driver_flag - 1 - else - -- If beginning with `%^^A+` or `%^^A-`, then increase or - -- decrease the flag, in order to determine the start or end - -- position of verbatim. - if test_tag(line, tag_begin_str) then - inside_flag = inside_flag + 1 - elseif test_tag(line, tag_end_str) then - inside_flag = inside_flag - 1 - else - if preamble_flag == 1 then - output_file:write(process_preamble_line(line), "\n") - elseif driver_flag == 1 then - -- Inside <*driver> ... . - -- Similar to normal text but do not have `% ` at beginning. - if inside_flag == 1 then - output_file:write(line, "\n") - elseif test_tag(line, tag_inline_str) then - output_file:write(process_normal_line(line), "\n") - end - elseif inside_flag == 1 then - -- If inside_flag = 1, then it's a verbatim environment. - output_file:write(process_verbatim_line(line), "\n") - elseif test_tag(line, tag_inline_str) then - -- If beginning with `%^^A!`, then this line is normal text. - output_file:write(process_normal_line(line), "\n") - end - end - end - end -end - -input_file:close() -output_file:close() diff --git a/scripts/zhconvert.sh b/scripts/zhconvert.sh deleted file mode 100644 index c22ad3d..0000000 --- a/scripts/zhconvert.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env sh - -# This script is used for converting encoding from UTF-8 to GBK/Big5. - -JOB_NAME=zhlipsum - -mv $JOB_NAME-gbk.def $JOB_NAME-gbk.tmp.def -mv $JOB_NAME-big5.def $JOB_NAME-big5.tmp.def - -# iconv -f utf8 -t gbk -o $JOB_NAME-gbk.def $JOB_NAME-gbk.tmp.def -# iconv -f utf8 -t big5 -o $JOB_NAME-big5.def $JOB_NAME-big5.tmp.def - -iconv -f utf8 -t gbk $JOB_NAME-gbk.tmp.def > $JOB_NAME-gbk.def -iconv -f utf8 -t big5 $JOB_NAME-big5.tmp.def > $JOB_NAME-big5.def - -rm *.tmp.def diff --git a/source/zhlipsum-text.dtx b/zhlipsum-text.dtx similarity index 100% rename from source/zhlipsum-text.dtx rename to zhlipsum-text.dtx diff --git a/source/zhlipsum.dtx b/zhlipsum.dtx similarity index 99% rename from source/zhlipsum.dtx rename to zhlipsum.dtx index c5a85c4..4c98483 100644 --- a/source/zhlipsum.dtx +++ b/zhlipsum.dtx @@ -227,9 +227,9 @@ Copyright (C) 2017–2020 by Xiangdong Zeng . gobble=4, label=\rule{0pt}{12pt}\textnormal{\bfseries δΎ‹ \arabic{ctexexam}}, defineactive=\def!{\color{gray}\%}, -%^^A! gobble=2, -%^^A! label=\rule{0pt}{12pt}\textnormal{\bfseries Example \arabic{ctexexam}}, -%^^A! defineactive=\def!{\color{gray}\itshape\%}, +%^^A! gobble=2, +%^^A! label=\rule{0pt}{12pt}\textnormal{\bfseries Example \arabic{ctexexam}}, +%^^A! defineactive=\def!{\color{gray}\itshape\%}, %^^A+ listparameters=% \setlength\topsep{\bigskipamount}%