On Wed, Feb 27, 2019 at 05:05:05PM -0500, Paul Hoffman wrote:
I'm trying to define a new language for use in a bilingual document, but my hyphenation patterns are being ignored and I'm sure I must be doing something wrong.
Never mind, I solved the problem. I'll describe what I did here, in
case anyone finds it helpful down the road.
First, I figured out how to create lang-foo.lua manually -- which wasn't
too painful, since the hyphenation rules for the language are very
simple -- and found that Context uses it if it sits next to the file
that uses \language[foo].
Then, after some detective work, I found that I can generate
/bar/lang-foo.lua from /foo/hyph-foo.tex by running the following
command:
mtxrun --script patterns --convert --path=/foo --destination=/bar \
--specification=foo,hyph-foo,Foobar
This prints a lot of errors ("no valid file", "convertion aborted")
because, after converting hyph-foo.tex, mtx-patterns.lua tries to
convert everything in its hard-coded list, but that's not a big deal.
Besides lang-foo.lua, which is all I really need, I also get
lang-foo.rme, lang-foo.hyp, and lang-foo.pat; the latter two are for
mkii, I gather.
Would a patch for mtx-patterns.lua that adds an option to convert *only*
a particular language's file be useful? I'm thinking an option like
--only that one can use like this:
mtxrun --script patterns --convert --path=/foo --destination=/bar \
--only \
--specification=foo,hyph-foo,Foo \
--specification=bar,hyph-bar,Bar \
The simplest implementation would be to clear the list first (if --only
is used), then add foo and bar to it. Something like this:
------------------------------------------------------------------------
--- OLD/mtx-patterns.lua 2019-02-28 11:10:27.180857745 -0500
+++ NEW/mtx-patterns.lua 2019-02-28 11:16:27.952426988 -0500
@@ -28,6 +28,7 @@
<flag name="path"><short>source path where hyph-foo.tex files are stored</short></flag>
<flag name="destination"><short>destination path</short></flag>
<flag name="specification"><short>additional patterns: e.g.: =cy,hyph-cy,welsh</short></flag>
+ <flag name="only"><short>convert only the specified patterns</short></flag>
<flag name="compress"><short>compress data</short></flag>
<flag name="words"><short>update words in given file</short></flag>
<flag name="hyphenate"><short>show hypephenated words</short></flag>
@@ -42,6 +43,7 @@
<example><command>mtxrun --script pattern --check --path=c:/data/develop/svn-hyphen/trunk/hyph-utf8/tex/generic/hyph-utf8/patterns</command></example>
<example><command>mtxrun --script pattern --convert --path=c:/data/develop/svn-hyphen/trunk/hyph-utf8/tex/generic/hyph-utf8/patterns/tex --destination=e:/tmp/patterns</command></example>
<example><command>mtxrun --script pattern --convert --path=c:/data/develop/svn-hyphen/trunk/hyph-utf8/tex/generic/hyph-utf8/patterns/txt --destination=e:/tmp/patterns</command></example>
+ <example><command>mtxrun --script pattern --convert --path=/foo --destination=/bar --only --specification=cy,hyph-cy,welsh</command></example>
<example><command>mtxrun --script pattern --hyphenate --language=nl --left=3 nogalwiedes inderdaad</command></example>
</subcategory>
</category>
@@ -497,6 +499,9 @@
--
local specification = environment.argument("specification")
if specification then
+ if environment.argument("only") then
+ scripts.patterns.list = {}
+ end
local components = utilities.parsers.settings_to_array(specification)
if #components == 3 then
table.insert(scripts.patterns.list,1,components)
------------------------------------------------------------------------
Paul.
--
Paul Hoffman