Hi running the following file --- \lefthyphenmin=1 \righthyphenmin=1 \hyphenation{a-b} \showhyphens{ab} --- displays on the terminal all hyphens that plain LuaTeX finds in 'ab'. Unfortunately, the following 1. build the 'ab' node list 2. call lang.hyphenate to insert discretionary hyphens 3. print the hyphenated node list does not print the hyphenated 'ab' list -- it prints 'b' instead (see the code below). --- \lefthyphenmin=1 \righthyphenmin=1 \hyphenation{a-b} \directlua 0 { function traverse_glyphs(head) for t in node.traverse_id(33, head) do % 33 -> glyph node texio.write_nl('char = ' .. t.char) end end head = node.new(33) head.font = font.current() head.char = 97 % ascii a head.lang = 0 tail = node.new(33) tail.font = font.current() tail.char = 98 % ascii b tail.lang = 0 % build 'ab' list head.next = tail tail.next = nil traverse_glyphs(head) lang.hyphenate(head) traverse_glyphs(head) } \end --- Is it possible to rewind the head pointer below on the begining of the list and to print the hyphenated list? --Wlodek Bzyl
Wlodek Bzyl wrote:
Is it possible to rewind the head pointer below on the begining of the list and to print the hyphenated list?
if you make it a double linked list using mnode.slide you can go back to head ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Hans Hagen wrote:
Wlodek Bzyl wrote:
Is it possible to rewind the head pointer below on the begining of the list and to print the hyphenated list?
if you make it a double linked list using mnode.slide you can go back to head
That was not the issue. There was simply a bug if the second argument was not explicit. Best wishes, Taco
Hi Wlodek, Wlodek Bzyl wrote:
Is it possible to rewind the head pointer below on the begining of the list and to print the hyphenated list?
That it doesnt work is a combination of two (maybe three) things. First, there is a bug in the executable so that you need to specify the tail explicitly (I have fixed that in the trunk, just moments ago) Second, you have to create characters (subtype 1) instead of glyphs (subtype 0). This is badly documented, but I do not yet know where to insert the relevant text. Third, if you traverse_id, you will never ever see the hyphens, because they are of type discretionary (id 7), not glyph (33). The code below should run even on the unpatched executable: \directlua 0 { function traverse_glyphs(head) for t in node.traverse(head) do if t.id == 33 then texio.write_nl('char = ' .. t.char) else texio.write_nl('id = ' .. t.id) end end end head = node.new(33,1) head.font = font.current() head.char = 97 % ascii a head.lang = 0 tail = node.new(33,1) tail.font = font.current() tail.char = 98 % ascii b tail.lang = 0 % build 'ab' list head.next = tail tail.next = nil traverse_glyphs(head) lang.hyphenate(head, tail) traverse_glyphs(head) } \end Best wishes, Taco
participants (4)
-
Hans Hagen
-
Hartmut Henkel
-
Taco Hoekwater
-
Wlodek Bzyl