diff options
Diffstat (limited to 'macros/latex/contrib/tagpdf/tagpdf-backend.dtx')
-rw-r--r-- | macros/latex/contrib/tagpdf/tagpdf-backend.dtx | 61 |
1 files changed, 31 insertions, 30 deletions
diff --git a/macros/latex/contrib/tagpdf/tagpdf-backend.dtx b/macros/latex/contrib/tagpdf/tagpdf-backend.dtx index d80d56778b..42620d46e5 100644 --- a/macros/latex/contrib/tagpdf/tagpdf-backend.dtx +++ b/macros/latex/contrib/tagpdf/tagpdf-backend.dtx @@ -27,7 +27,7 @@ % \begin{macrocode} %<@@=tag> %<*luatex> -\ProvidesExplFile {tagpdf-luatex.def} {2021/02/23} {0.80} +\ProvidesExplFile {tagpdf-luatex.def} {2021/05/14} {0.81} {tagpdf~driver~for~luatex} \newattribute \l_@@_mc_type_attr %the value represent the type @@ -55,41 +55,32 @@ % Old code, I'm not quite sure if this was a good idea. Now I have mix of table in % ltx.@@.tables and ltx.@@.mc/struct. And a lot is probably not needed. -\cs_new:Nn \@@_luatex_get_table_name:Nn - { - \tl_set_rescan:Nnn #1 { \char_set_catcode_ignore:N \\ } { #2 } - } - -\cs_new:Nn \@@_prop_new:N +\cs_new_protected:Nn \@@_prop_new:N { \prop_new:N #1 - \@@_luatex_get_table_name:Nn \l_tmpa_tl { #1 } - \directlua { ltx.@@.tables.\l_tmpa_tl = {} } + \directlua { ltx.@@.tables.\cs_to_str:N#1 = {} } } -\cs_new:Nn \@@_seq_new:N +\cs_new_protected:Nn \@@_seq_new:N { \seq_new:N #1 - \@@_luatex_get_table_name:Nn \l_tmpa_tl { #1 } - \directlua { ltx.@@.tables.\l_tmpa_tl = {} } + \directlua { ltx.@@.tables.\cs_to_str:N#1 = {} } } -\cs_new:Nn \@@_prop_gput:Nnn +\cs_new_protected:Nn \@@_prop_gput:Nnn { \prop_gput:Nnn #1 { #2 } { #3 } - \@@_luatex_get_table_name:Nn \l_tmpa_tl { #1 } - \directlua { ltx.@@.tables.\l_tmpa_tl["#2"] = "#3" } + \directlua { ltx.@@.tables.\cs_to_str:N#1 ["#2"] = "#3" } } -\cs_new:Nn \@@_seq_gput_right:Nn +\cs_new_protected:Nn \@@_seq_gput_right:Nn { \seq_gput_right:Nn #1 { #2 } - \@@_luatex_get_table_name:Nn \l_tmpa_tl { #1 } - \directlua { table.insert(ltx.@@.tables.\l_tmpa_tl, "#2") } + \directlua { table.insert(ltx.@@.tables.\cs_to_str:N#1, "#2") } } %Hm not quite sure about the naming @@ -105,27 +96,25 @@ } %for debugging commands that show both the seq/prop and the lua tables -\cs_new:Nn \@@_seq_show:N +\cs_new_protected:Nn \@@_seq_show:N { \seq_show:N #1 - \@@_luatex_get_table_name:Nn \l_tmpa_tl { #1 } - \directlua { ltx.@@.trace.log ("lua~sequence~array~\l_tmpa_tl",1) } - \directlua { ltx.@@.trace.show_seq (ltx.@@.tables.\l_tmpa_tl) } + \directlua { ltx.@@.trace.log ("lua~sequence~array~\cs_to_str:N#1",1) } + \directlua { ltx.@@.trace.show_seq (ltx.@@.tables.\cs_to_str:N#1) } } -\cs_new:Nn \@@_prop_show:N +\cs_new_protected:Nn \@@_prop_show:N { \prop_show:N #1 - \@@_luatex_get_table_name:Nn \l_tmpa_tl { #1 } - \directlua {ltx.@@.trace.log ("lua~property~table~\l_tmpa_tl",1) } - \directlua {ltx.@@.trace.show_prop (ltx.@@.tables.\l_tmpa_tl) } + \directlua {ltx.@@.trace.log ("lua~property~table~\cs_to_str:N#1",1) } + \directlua {ltx.@@.trace.show_prop (ltx.@@.tables.\cs_to_str:N#1) } } %</luatex> % \end{macrocode} % % \begin{macrocode} %<*pdftex> -\ProvidesExplFile {tagpdf-pdftex.def} {2021/02/23} {0.80} +\ProvidesExplFile {tagpdf-pdftex.def} {2021/05/14} {0.81} {tagpdf~driver~for~pdftex} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -160,8 +149,8 @@ local ProvidesLuaModule = { name = "tagpdf", - version = "0.80", --TAGVERSION - date = "2021-02-23", --TAGDATE + version = "0.81", --TAGVERSION + date = "2021-05-14", --TAGDATE description = "tagpdf lua code", license = "The LATEX Project Public License 1.3c" } @@ -237,6 +226,7 @@ local nodeid = node.id local nodecopy = node.copy local nodegetattribute = node.get_attribute local nodesetattribute = node.set_attribute +local nodehasattribute = node.has_attribute local nodenew = node.new local nodetail = node.tail local nodeslide = node.slide @@ -361,6 +351,17 @@ local function @@_mark_spaces (head) nodesetattribute(kern.next,iwfontattributeid,glyph.font) end end + -- look also back + if glyph.prev and (glyph.prev.id == GLUE) + and not inside_math and (glyph.prev.width >0) and not nodehasattribute(glyph.prev,iwspaceattributeid) + then + nodesetattribute(glyph.prev,iwspaceattributeid,1) + nodesetattribute(glyph.prev,iwfontattributeid,glyph.font) + -- for debugging + if ltx.__tag.trace.showspaces then + __tag_show_spacemark (head,glyph) + end + end elseif id == PENALTY then local glyph = n -- ltx.@@.trace.log ("PENALTY ".. n.subtype.."VALUE"..n.penalty,3) @@ -770,7 +771,7 @@ function ltx.@@.func.fill_parent_tree_line (page) local structnum = ltx.@@.mc[mcnum]["parent"] local propname = "g_@@_struct_"..structnum.."_prop" local objref = ltx.@@.tables[propname]["objref"] or "XXXX" - texio.write_nl("=====>"..tostring(objref)) + ltx.@@.trace.log("=====>"..tostring(objref),5) numsentry = pdfpage .. " [".. objref .. "]" ltx.@@.trace.log("PAGETREE PAGE" .. page.. " NUM ENTRY = ".. numsentry,3) else |