Skip to content

Commit

Permalink
clean up directories
Browse files Browse the repository at this point in the history
  • Loading branch information
stone-zeng committed Apr 9, 2020
1 parent 53e5aeb commit 64973b6
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 192 deletions.
38 changes: 2 additions & 36 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
106 changes: 95 additions & 11 deletions build.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

module = "zhlipsum"

sourcefiledir = "./source"

sourcefiles = {"*.dtx"}
installfiles = {"*.sty", "*.def"}
unpackfiles = {"zhlipsum.dtx"}
Expand All @@ -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 = {}
Expand All @@ -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 = "%</driver>"
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> ... </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
Expand Down
12 changes: 0 additions & 12 deletions scripts/build-save.sh

This file was deleted.

114 changes: 0 additions & 114 deletions scripts/get-doc-en.lua

This file was deleted.

16 changes: 0 additions & 16 deletions scripts/zhconvert.sh

This file was deleted.

File renamed without changes.
6 changes: 3 additions & 3 deletions source/zhlipsum.dtx → zhlipsum.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ Copyright (C) 2017&ndash;2020 by Xiangdong Zeng <[email protected]>.
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}%
Expand Down

0 comments on commit 64973b6

Please sign in to comment.