diff options
author | Karl Berry <karl@freefriends.org> | 2016-04-02 21:42:33 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-04-02 21:42:33 +0000 |
commit | 2d629dc1657a546dbe79d71fbfe89d81f15a5aec (patch) | |
tree | 1c2620ba6eb871b111de7a3d6ee58be034ce5c3b /Master/texmf-dist | |
parent | 4b5466704256a0bd84c31cb760a435a3c26fb713 (diff) |
lua-check-hyphen (2apr16)
git-svn-id: svn://tug.org/texlive/trunk@40211 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
l--------- | Master/texmf-dist/doc/lualatex/lua-check-hyphen/README.md | 1 | ||||
-rw-r--r-- | Master/texmf-dist/doc/lualatex/lua-check-hyphen/doc/README.md | 4 | ||||
-rw-r--r-- | Master/texmf-dist/doc/lualatex/lua-check-hyphen/doc/luacheckhyphenmanual.pdf | bin | 110703 -> 111253 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/lualatex/lua-check-hyphen/doc/luacheckhyphenmanual.tex | 15 | ||||
-rw-r--r-- | Master/texmf-dist/doc/lualatex/lua-check-hyphen/doc/mit-license.txt | 19 | ||||
-rw-r--r-- | Master/texmf-dist/doc/lualatex/lua-check-hyphen/doc/sample.pdf | bin | 5327 -> 5275 bytes | |||
-rw-r--r-- | Master/texmf-dist/tex/lualatex/lua-check-hyphen/lua-check-hyphen.lua | 91 | ||||
-rw-r--r-- | Master/texmf-dist/tex/lualatex/lua-check-hyphen/lua-check-hyphen.sty | 9 |
8 files changed, 119 insertions, 20 deletions
diff --git a/Master/texmf-dist/doc/lualatex/lua-check-hyphen/README.md b/Master/texmf-dist/doc/lualatex/lua-check-hyphen/README.md new file mode 120000 index 00000000000..fd42db32e33 --- /dev/null +++ b/Master/texmf-dist/doc/lualatex/lua-check-hyphen/README.md @@ -0,0 +1 @@ +doc/README.md
\ No newline at end of file diff --git a/Master/texmf-dist/doc/lualatex/lua-check-hyphen/doc/README.md b/Master/texmf-dist/doc/lualatex/lua-check-hyphen/doc/README.md index f6fe0bee1d8..de4d6aae600 100644 --- a/Master/texmf-dist/doc/lualatex/lua-check-hyphen/doc/README.md +++ b/Master/texmf-dist/doc/lualatex/lua-check-hyphen/doc/README.md @@ -20,8 +20,8 @@ A typical workflow is: * optionally use the option `mark` to make the unknown hyphenated words visible in the PDF file -Copyright 2012–2014 Patrick Gundlach (patrick@gundla.ch)<br> -Package version: 0.3 +Copyright 2012–2016 Patrick Gundlach (patrick@gundla.ch)<br> +Package version: 0.4 Public repository: https://github.com/pgundlach/lua-check-hyphen<br> Licensed under the MIT license. See the file 'mit-license.txt' for exact terms.<br> Status: works fine, slightly unmaintained.<br> diff --git a/Master/texmf-dist/doc/lualatex/lua-check-hyphen/doc/luacheckhyphenmanual.pdf b/Master/texmf-dist/doc/lualatex/lua-check-hyphen/doc/luacheckhyphenmanual.pdf Binary files differindex 97d054ffb7d..73038da7165 100644 --- a/Master/texmf-dist/doc/lualatex/lua-check-hyphen/doc/luacheckhyphenmanual.pdf +++ b/Master/texmf-dist/doc/lualatex/lua-check-hyphen/doc/luacheckhyphenmanual.pdf diff --git a/Master/texmf-dist/doc/lualatex/lua-check-hyphen/doc/luacheckhyphenmanual.tex b/Master/texmf-dist/doc/lualatex/lua-check-hyphen/doc/luacheckhyphenmanual.tex index aafa334d210..78f34fc6cdc 100644 --- a/Master/texmf-dist/doc/lualatex/lua-check-hyphen/doc/luacheckhyphenmanual.tex +++ b/Master/texmf-dist/doc/lualatex/lua-check-hyphen/doc/luacheckhyphenmanual.tex @@ -1,6 +1,6 @@ \documentclass{ltxdockit} -\usepackage{dtklogos,csquotes} -\newcommand\pkgversion{0.3} +\usepackage{dtklogos,csquotes,graphicx} +\newcommand\pkgversion{0.4} \titlepage{% title={The lua-check-hyphen package}, @@ -30,14 +30,14 @@ \section{Usage} -This package only works with \LuaTeX. To activate it a +This package only works with Lua\TeX. To activate it a \begin{verbatim} \usepackage{lua-check-hyphen} \end{verbatim} is enough. -When you process your document with \LuaLaTeX, a file with the suffix \verb|.uhy| is created with that contains every hyphenated word. You can check that file for hyphenation errors. With the package option \texttt{nofile}, you can tell the package not to write the external file. In any case the list is written to the log file. +When you process your document with Lua\LaTeX, a file with the suffix \verb|.uhy| is created with that contains every hyphenated word. You can check that file for hyphenation errors. With the package option \texttt{nofile}, you can tell the package not to write the external file. In any case the list is written to the log file. \section{Advanced usage} \label{sec:advanced_usage} @@ -82,7 +82,7 @@ You might want to use the PDF viewer to check for incorrectly hyphenated words. \LuaCheckHyphen{mark} \end{verbatim} -This marks all non-whitelisted used hyphenation points in the document with a black square (not to be confused with overfull boxes): +This marks all non-whitelisted used hyphenation points in the document with a black square (not to be confused with overfull boxes): \includegraphics{sample-crop} @@ -102,6 +102,7 @@ For the true/false options you don't need to write the \texttt{=true} part. All \begin{optionlist} + \boolitem[true]{compact}{Words with different hyphenation occurrences are listed only once.} \boolitem[false]{mark}{Create visual markers when an unknown hyphenation encountered.} \boolitem[false]{nofile}{Don't write to an external file (\texttt{.uhy}).} \boolitem[false]{file}{Don't do anything. This is for the last document run, no marks will be generated.} @@ -114,6 +115,10 @@ When you pass the Option \opt{final} to the \cmd{documentclass}, the \cmd{usepac \section{Changes} \begin{changelog} +\begin{release}{0.4}{2016-04-01} + \item Compact representation of hyphenated words that occur more than once with different hyphenation positions (option copmact=true). + \item Sort uhy entries alphabetically and only use lowercase words in the file. +\end{release} \begin{release}{0.2}{2012-06-22} \item Fix ligature counting error (github issue \#1) \item Add nofile option diff --git a/Master/texmf-dist/doc/lualatex/lua-check-hyphen/doc/mit-license.txt b/Master/texmf-dist/doc/lualatex/lua-check-hyphen/doc/mit-license.txt new file mode 100644 index 00000000000..1bc0d0e99ec --- /dev/null +++ b/Master/texmf-dist/doc/lualatex/lua-check-hyphen/doc/mit-license.txt @@ -0,0 +1,19 @@ +Copyright (c) 2012-2014 Patrick Gundlach + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Master/texmf-dist/doc/lualatex/lua-check-hyphen/doc/sample.pdf b/Master/texmf-dist/doc/lualatex/lua-check-hyphen/doc/sample.pdf Binary files differindex 3c9409bf05a..25e730c110a 100644 --- a/Master/texmf-dist/doc/lualatex/lua-check-hyphen/doc/sample.pdf +++ b/Master/texmf-dist/doc/lualatex/lua-check-hyphen/doc/sample.pdf diff --git a/Master/texmf-dist/tex/lualatex/lua-check-hyphen/lua-check-hyphen.lua b/Master/texmf-dist/tex/lualatex/lua-check-hyphen/lua-check-hyphen.lua index e0eee9b88cf..148699382d3 100644 --- a/Master/texmf-dist/tex/lualatex/lua-check-hyphen/lua-check-hyphen.lua +++ b/Master/texmf-dist/tex/lualatex/lua-check-hyphen/lua-check-hyphen.lua @@ -1,13 +1,13 @@ --- Copyright 2012 Patrick Gundlach (patrick@gundla.ch) +-- Copyright 2012-2016 Patrick Gundlach (patrick@gundla.ch) -- Public repository: https://github.com/pgundlach/lua-check-hyphen -- Licensed under the MIT license. See the file 'mit-license.txt' for exact terms. --- Version: 0.3 +-- Version: 0.4 -- for debugging purpuse: -- function w( ... ) --- texio.write_nl(string.format(...)) +-- texio.write_nl("--->" .. string.format(...)) -- end local explode = function(s,p) @@ -38,8 +38,9 @@ local a_whatsit_node = node.id("whatsit") local subtype_rightskip = 9 +local sln = unicode.utf8 + luacheckhyphen.deligature = function ( glyph_node ) - local sln = unicode.utf8 local head = glyph_node.components local str = "" while head do @@ -56,6 +57,12 @@ luacheckhyphen.deligature = function ( glyph_node ) end +-- This functions analyzes the list beginning at head. If it encounters a box, +-- it recurses into the box. If it finds a disc node, it goes back until it finds the word +-- start. Then it analyzes the word und finds all hyphenation points. For example the German +-- word "Salpetersäure" has these disc nodes: , "Sal-petersäure", "Salpe-tersäure", +-- "Salpeter-säure", and "Salpetersäu-re". Each of these "word with hyphen" gets stored in +-- the hash hyphenwords luacheckhyphen.collect_discs = function(head) local word_start local word @@ -95,6 +102,7 @@ luacheckhyphen.collect_discs = function(head) end if thisbreakpoint then word_with_hyphen = sln.sub(word,1,thisbreakpoint) .. "-" .. sln.sub(word,thisbreakpoint+1,-1) + -- word with hyphen has all possible hyphenation points luacheckhyphen.hyphenwords[hyphencounter] = word_with_hyphen hyphencounter = #luacheckhyphen.hyphenwords + 1 end @@ -104,6 +112,12 @@ luacheckhyphen.collect_discs = function(head) return true end +-- Remove '-' from word +local function removedash( word ) + local ret = sln.gsub(word,"-","") + return ret +end + luacheckhyphen.check_discs = function (head,parent) local c local word @@ -119,7 +133,14 @@ luacheckhyphen.check_discs = function (head,parent) if luacheckhyphen.word_whitelist[word] then -- word found, but OK (whitelisted) else - luacheckhyphen.all_hyphenatedwords[word] = true + if luachekchyphen.compact == nil or luachekchyphen.compact == "true" then + local word_without_hyphen = sln.lower(removedash(word)) + local tmp = luacheckhyphen.all_hyphenatedwords[word_without_hyphen] or {} + tmp[word] = true + luacheckhyphen.all_hyphenatedwords[word_without_hyphen] = tmp + else + luacheckhyphen.all_hyphenatedwords[word] = true + end if luacheckhyphen.drawmarks then tmp = node.copy(luacheckhyphen.rectangle) node.insert_after(parent,head,tmp) @@ -131,6 +152,21 @@ luacheckhyphen.check_discs = function (head,parent) return true end +-- http://www.lua.org/pil/19.3.html +local function pairsByKeys (t) + local a = {} + for n in pairs(t) do table.insert(a, n) end + table.sort(a) + local i = 0 -- iterator variable + local iter = function () -- iterator function + i = i + 1 + if a[i] == nil then return nil + else return a[i], t[a[i]] + end + end + return iter +end + luacheckhyphen.listhyphenatedwords = function() if luacheckhyphen.final == "true" then return @@ -139,9 +175,31 @@ luacheckhyphen.listhyphenatedwords = function() if not luacheckhyphen.nofile then local unknown_hyphenation_filename = tex.jobname .. ".uhy" local unknown_hyphenation_file = io.open(unknown_hyphenation_filename,"w") - - for k,v in pairs(luacheckhyphen.all_hyphenatedwords) do - unknown_hyphenation_file:write(k .. "\n") + for k,v in pairsByKeys(luacheckhyphen.all_hyphenatedwords) do + if luachekchyphen.compact == "true" or luachekchyphen.compact == nil then + local hyphenationlist = {} + local hyphenpos = {} + for l,_ in pairs(v) do + local tmp = string.find(l,"-") + if tmp then + hyphenpos[#hyphenpos + 1] = tmp + end + hyphenationlist[#hyphenationlist + 1] = l + end + table.sort(hyphenpos) + local word_with_all_hyphenationpoints = {} + local cur = 1 + for i=1,string.len(k) do + if hyphenpos[cur] == i then + word_with_all_hyphenationpoints[#word_with_all_hyphenationpoints + 1] = "-" + cur = cur + 1 + end + word_with_all_hyphenationpoints[#word_with_all_hyphenationpoints + 1] = string.sub(k,i, i) + end + unknown_hyphenation_file:write(table.concat(word_with_all_hyphenationpoints,"") .. "\n") + else + unknown_hyphenation_file:write(k .. "\n") + end end unknown_hyphenation_file:close() end @@ -166,7 +224,22 @@ luacheckhyphen.enable = function() else filecontents = whitelistfile:read("*a") for _,entry in ipairs(explode(filecontents,"[^%s]+")) do - luacheckhyphen.word_whitelist[entry] = true + parts = string.explode(entry,"-") + if #parts > 2 then + local c = 1 + for c=1,#parts - 1 do + local word = {} + for i=1,#parts do + word[#word + 1] = parts[i] + if i == c then + word[#word + 1] = "-" + end + end + luacheckhyphen.word_whitelist[table.concat(word,"")] = true + end + else + luacheckhyphen.word_whitelist[entry] = true + end end end end diff --git a/Master/texmf-dist/tex/lualatex/lua-check-hyphen/lua-check-hyphen.sty b/Master/texmf-dist/tex/lualatex/lua-check-hyphen/lua-check-hyphen.sty index b919bd3b654..d38ebeab8cb 100644 --- a/Master/texmf-dist/tex/lualatex/lua-check-hyphen/lua-check-hyphen.sty +++ b/Master/texmf-dist/tex/lualatex/lua-check-hyphen/lua-check-hyphen.sty @@ -1,9 +1,9 @@ -% Copyright 2012 Patrick Gundlach (patrick@gundla.ch) -% Public repository: https://github.com/pgundlach/lua-check-hyphen +% Copyright 2012 Patrick Gundlach (patrick@gundla.ch) +% Public repository: https://github.com/pgundlach/lua-check-hyphen % Licensed under the MIT license. See the file 'mit-license.txt' for exact terms. -\def\luachekchyphenpkgdate{2014/07/30} -\def\luachekchyphenversion{0.3} +\def\luachekchyphenpkgdate{2016/04/02} +\def\luachekchyphenversion{0.4} \RequirePackage{ifluatex} @@ -23,6 +23,7 @@ \def\luachekchyphendothings{\directlua{luachekchyphen.enable() }} \define@key{luacheckhyphen}{nofile}[true]{\directlua{luachekchyphen.nofile = "\luatexluaescapestring{#1}"}} +\define@key{luacheckhyphen}{compact}[true]{\directlua{luachekchyphen.compact = "\luatexluaescapestring{#1}"}} \define@key{luacheckhyphen}{final}[true]{\directlua{luachekchyphen.final = "\luatexluaescapestring{#1}"}} \define@key{luacheckhyphen}{mark}[true]{\directlua{luachekchyphen.mark = "\luatexluaescapestring{#1}"}} \define@key{luacheckhyphen}{whitelist}{\directlua{luachekchyphen.whitelist = "\luatexluaescapestring{#1}"}} |