summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/tagpdf
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-01-05 22:41:39 +0000
committerKarl Berry <karl@freefriends.org>2019-01-05 22:41:39 +0000
commit2450bb6d5a67acf34496177de7c84bca5f0fc6aa (patch)
treeb65f39c2d1a44c13b47eb05272fa2cf14844b2fa /Master/texmf-dist/tex/latex/tagpdf
parent0cadd95f76694626fd0d7d21045d4a8e7f87d8be (diff)
tagpdf (5jan19)
git-svn-id: svn://tug.org/texlive/trunk@49609 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/tagpdf')
-rw-r--r--Master/texmf-dist/tex/latex/tagpdf/tagpdf-attr-code.sty110
-rw-r--r--Master/texmf-dist/tex/latex/tagpdf/tagpdf-checks-code.sty5
-rw-r--r--Master/texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def6
-rw-r--r--Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-generic.sty2
-rw-r--r--Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-lua.sty2
-rw-r--r--Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-shared.sty2
-rw-r--r--Master/texmf-dist/tex/latex/tagpdf/tagpdf-pdftex.def2
-rw-r--r--Master/texmf-dist/tex/latex/tagpdf/tagpdf-roles-code.sty2
-rw-r--r--Master/texmf-dist/tex/latex/tagpdf/tagpdf-space-code.sty45
-rw-r--r--Master/texmf-dist/tex/latex/tagpdf/tagpdf-struct-code.sty8
-rw-r--r--Master/texmf-dist/tex/latex/tagpdf/tagpdf-tree-code.sty35
-rw-r--r--Master/texmf-dist/tex/latex/tagpdf/tagpdf-user.sty9
-rw-r--r--Master/texmf-dist/tex/latex/tagpdf/tagpdf.lua119
-rw-r--r--Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty21
14 files changed, 341 insertions, 27 deletions
diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-attr-code.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-attr-code.sty
new file mode 100644
index 00000000000..986a2ca9ca5
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-attr-code.sty
@@ -0,0 +1,110 @@
+\ProvidesExplPackage {tagpdf-attr-code} {2019/01/04} {0.50}
+ {part of tagpdf - code related to attributes and attribute classes}
+
+% the obj is written in tagpdf-tree-code.
+
+\seq_new:N \g__uftag_attr_class_used_seq
+\prop_new:N \g__uftag_attr_objnum_prop %will contain obj num of used attributes
+
+\prop_new:N \g__uftag_attr_entries_prop
+\tl_new:N \g__uftag_attr_class_content_tl
+\tl_new:N \l__uftag_attr_objtmp_tl
+\tl_new:N \l__uftag_attr_value_tl
+
+
+\cs_new_protected:Nn \__uftag_attr_new_entry:nn %#1:name, #2: content
+ {
+ \prop_gput:Nnn \g__uftag_attr_entries_prop
+ {#1}{#2}
+ }
+
+\keys_define:nn { uftag / setup }
+ {
+ newattribute .code:n =
+ {
+ \__uftag_attr_new_entry:nn #1
+ }
+ }
+
+
+% the key for the structure:
+\keys_define:nn { uftag / struct }
+{
+ attribute-class .code:n =
+ {
+ \clist_set:No \l_tmpa_clist { #1 }
+ \seq_set_from_clist:NN \l_tmpa_seq \l_tmpa_clist
+ \seq_map_inline:Nn \l_tmpa_seq
+ {
+ \prop_if_in:NnF \g__uftag_attr_entries_prop {##1}
+ {
+ \msg_error:nnn { uftag } { attr-unknown } { ##1 }
+ }
+ \seq_gput_left:Nn\g__uftag_attr_class_used_seq { ##1}
+ }
+ \seq_set_map:NNn \l_tmpb_seq \l_tmpa_seq
+ {
+ /##1
+ }
+ \tl_set:Nx \l_tmpa_tl
+ {
+ \int_compare:nT { \seq_count:N \l_tmpa_seq > 1 }{[}
+ \seq_use:Nn \l_tmpb_seq { \c_space_tl }
+ \int_compare:nT { \seq_count:N \l_tmpa_seq > 1 }{]}
+ }
+ \int_compare:nT { \seq_count:N \l_tmpa_seq > 0 }
+ {
+ \__uftag_prop_gput:cnx
+ { g__uftag_struct_\int_eval:n {\c@g__uftag_struct_abs_int}_prop }
+ { C }
+ { \l_tmpa_tl }
+ %\prop_show:c { g__uftag_struct_\int_eval:n {\c@g__uftag_struct_abs_int}_prop }
+ }
+ }
+}
+
+\keys_define:nn { uftag / struct }
+ {
+ attribute .code:n = % A property (attribute, value currently a dictionary)
+ {
+ \clist_set:No \l_tmpa_clist { #1 }
+ \seq_set_from_clist:NN \l_tmpa_seq \l_tmpa_clist
+ \tl_set:Nx \l__uftag_attr_value_tl
+ {
+ \int_compare:nT { \seq_count:N \l_tmpa_seq > 1 }{[}
+ }
+ \seq_map_inline:Nn \l_tmpa_seq
+ {
+ \prop_if_in:NnF \g__uftag_attr_entries_prop {##1}
+ {
+ \msg_error:nnn { uftag } { attr-unknown } { ##1 }
+ }
+ \prop_if_in:NnF \g__uftag_attr_objnum_prop {##1}
+ {
+ \__uftag_pdfreserveobjnum:N \l_tmpa_tl
+ \__uftag_pdfuseobjnum:Nx \l_tmpa_tl
+ {
+ \prop_item:Nn\g__uftag_attr_entries_prop {##1}
+ }
+ \prop_gput:NnV \g__uftag_attr_objnum_prop {##1} {\l_tmpa_tl}
+ }
+ \tl_put_right:Nx \l__uftag_attr_value_tl
+ {
+ \c_space_tl
+ \prop_item:Nn \g__uftag_attr_objnum_prop {##1}
+ \c_space_tl 0 \c_space_tl R
+ }
+ % \tl_show:N \l__uftag_attr_value_tl
+ }
+ \tl_put_right:Nx \l__uftag_attr_value_tl
+ {
+ \int_compare:nT { \seq_count:N \l_tmpa_seq > 1 }{]}
+ }
+ % \tl_show:N \l__uftag_attr_value_tl
+ \__uftag_prop_gput:cnx
+ { g__uftag_struct_\int_eval:n {\c@g__uftag_struct_abs_int}_prop }
+ { A }
+ { \l__uftag_attr_value_tl }
+ },
+ }
+\endinput
diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-checks-code.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-checks-code.sty
index cd0ee0d70ab..83822187ffb 100644
--- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-checks-code.sty
+++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-checks-code.sty
@@ -1,4 +1,4 @@
-\ProvidesExplPackage {tagpdf-checks-code} {2018/08/06} {0.3}
+\ProvidesExplPackage {tagpdf-checks-code} {2019/01/04} {0.50}
{part of tagpdf - code related to checks and messages}
@@ -19,6 +19,9 @@
\msg_new:nnn {uftag} {struct-used-twice} { structure~with~label~#1~has~already~been~used}
\msg_new:nnn {uftag} {struct-label-unknown} { structure~with~label~#1~is~unknown~rerun}
+% attributes
+\msg_new:nnn {uftag} {attr-unknown} { attribute~#1~is~unknown}
+
%Roles
\msg_new:nnn {uftag} {role-missing} { tag~#1~has~no~role~assigned }
diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def
index cee2e931e9a..f9085e96fbf 100644
--- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def
+++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def
@@ -1,8 +1,10 @@
-\ProvidesExplFile {tagpdf-luatex.def} {2018/08/06} {0.3}
+\ProvidesExplFile {tagpdf-luatex.def} {2019/01/04} {0.50}
{tagpdf driver for luatex}
\newattribute \g__uftag_mc_type_attr %the value represent the type
\newattribute \g__uftag_mc_cnt_attr %will hold the \c@g__uftag_MCID_abs_int value
+\newattribute \g__uftag_interwordspace_attr
+\newattribute \g__uftag_interwordfont_attr
% The lua code
\directlua { tagpdf=require('tagpdf.lua') }
@@ -11,7 +13,7 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% needed for \str_set_convert:Nnon
-\tl_new:N \g__uftag_inputencoding_tl
+\tl_new:N \g__uftag_inputencoding_tl
\tl_gset:Nn \g__uftag_inputencoding_tl {}
diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-generic.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-generic.sty
index b8839782ca1..a26fd0fa3ad 100644
--- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-generic.sty
+++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-generic.sty
@@ -1,4 +1,4 @@
-\ProvidesExplPackage {tagpdf-mc-code-generic} {2018/08/06} {0.3}
+\ProvidesExplPackage {tagpdf-mc-code-generic} {2019/01/04} {0.50}
{part of tagpdf - code related to marking chunks - generic mode}
% for the label system
diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-lua.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-lua.sty
index eeee1bd80a8..5ae1c51f6ec 100644
--- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-lua.sty
+++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-lua.sty
@@ -1,4 +1,4 @@
-\ProvidesExplPackage {tagpdf-mc-code-lua} {2018/08/06} {0.3}
+\ProvidesExplPackage {tagpdf-mc-code-lua} {2019/01/04} {0.50}
{tagpdf - mc code only for the luamode }
% the two attibutes are defined in the driver file.
diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-shared.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-shared.sty
index 173967b945d..789059f4249 100644
--- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-shared.sty
+++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-shared.sty
@@ -1,4 +1,4 @@
-\ProvidesExplPackage {tagpdf-mc-code-shared} {2018/08/06} {0.3}
+\ProvidesExplPackage {tagpdf-mc-code-shared} {2019/01/04} {0.50}
{part of tagpdf - code related to marking chunks - code shared by generic and luamode }
% I use a latex counter for the absolute count, so that it is added to
diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-pdftex.def b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-pdftex.def
index af9382748e6..19d5bd926c5 100644
--- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-pdftex.def
+++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-pdftex.def
@@ -1,4 +1,4 @@
-\ProvidesExplFile {tagpdf-pdftex.def} {2018/08/06} {0.3}
+\ProvidesExplFile {tagpdf-pdftex.def} {2019/01/04} {0.50}
{tagpdf driver for pdftex}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-roles-code.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-roles-code.sty
index bd8c680f963..47c55a640f8 100644
--- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-roles-code.sty
+++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-roles-code.sty
@@ -1,4 +1,4 @@
-\ProvidesExplPackage {tagpdf-roles-code} {2018/08/06} {0.3}
+\ProvidesExplPackage {tagpdf-roles-code} {2019/01/04} {0.50}
{part of tagpdf - code related to roles and structure names}
\__uftag_seq_new:N \g__uftag_role_tags_seq %to get names from numbers
diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-space-code.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-space-code.sty
new file mode 100644
index 00000000000..7e8c5337010
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-space-code.sty
@@ -0,0 +1,45 @@
+\ProvidesExplPackage {tagpdf-space-code} {2019/01/04} {0.50}
+ {part of tagpdf - code related to real space chars}
+% luatex uses an attribute (declared in the driver file) and some luacode in tagpdf.lua
+% perhaps I will split the code by engine in the future
+
+\sys_if_engine_pdftex:T
+{
+ \pdfglyphtounicode{space}{0020}
+ \keys_define:nn { uftag / setup }
+ {
+ interwordspace .choices:nn = { true, on } { \pdfinterwordspaceon },
+ interwordspace .choices:nn = { false, off }{ \pdfinterwordspaceon },
+ show-spaces .bool_set:N = \l__uftag_showspaces_bool
+ }
+
+}
+
+
+\sys_if_engine_luatex:T
+{
+ \keys_define:nn { uftag / setup }
+ {
+ interwordspace .choices:nn = { true, on }
+ { \directlua{uftag.func.markspaceon()} },
+
+ interwordspace .choices:nn = { false, off }
+ {\directlua{uftag.func.markspaceoff()} },
+ show-spaces .choice:,
+ show-spaces / true .code:n = {\directlua{uftag.trace.showspaces=true}},
+ show-spaces / false .code:n = {\directlua{uftag.trace.showspaces=nil}},
+ show-spaces .default:n = true
+ }
+ \cs_new_protected:Nn \__uftag_fakespace:
+ {
+ \group_begin:
+ \setattribute\g__uftag_interwordspace_attr{1}
+ \setattribute\g__uftag_interwordfont_attr{\directlua{tex.print(\the\catcodetable@latex, font.current())}}
+ \skip_horizontal:n{\c_zero_skip}
+ \group_end:
+ }
+}
+
+
+
+\endinput
diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-struct-code.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-struct-code.sty
index 898f33a7115..c6da45cd34c 100644
--- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-struct-code.sty
+++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-struct-code.sty
@@ -1,4 +1,4 @@
-\ProvidesExplPackage {tagpdf-struct-code} {2018/08/06} {0.3}
+\ProvidesExplPackage {tagpdf-struct-code} {2019/01/04} {0.50}
{part of tagpdf - code related to storing structure}
% I will use a latex counter for the structure count
@@ -41,8 +41,7 @@
% when the entries are created (title,lange,alt,E,actualtext)
-\seq_new:N \c__uftag_struct_StructTreeRoot_entries_seq
-\seq_set_from_clist:Nn \c__uftag_struct_StructTreeRoot_entries_seq
+\seq_const_from_clist:Nn \c__uftag_struct_StructTreeRoot_entries_seq
{%p. 857/858
Type, % always /StructTreeRoot
K, % kid, dictionary or array of dictionaries
@@ -53,8 +52,7 @@
ClassMap
}
-\seq_new:N \c__uftag_struct_StructElem_entries_seq
-\seq_set_from_clist:Nn \c__uftag_struct_StructElem_entries_seq
+\seq_const_from_clist:Nn \c__uftag_struct_StructElem_entries_seq
{%p 858 f
Type, %always /StructElem
S, %tag/type
diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-tree-code.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-tree-code.sty
index d30b82a004e..b9667b43f75 100644
--- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-tree-code.sty
+++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-tree-code.sty
@@ -1,4 +1,4 @@
-\ProvidesExplPackage {tagpdf-tree-code} {2018/08/06} {0.3}
+\ProvidesExplPackage {tagpdf-tree-code} {2019/01/04} {0.50}
{part of tagpdf - code related to writing trees and dictionaries to the pdf}
%this does the actual finishing:
@@ -123,11 +123,44 @@
}
}
+%classmap, should only be written, if values has been used
+
+\cs_new_protected:Nn \__uftag_tree_class_write_map:
+ {
+ \tl_gclear:N \g__uftag_attr_class_content_tl
+ \seq_gremove_duplicates:N \g__uftag_attr_class_used_seq
+ \seq_set_map:NNn \l_tmpa_seq \g__uftag_attr_class_used_seq
+ {
+ /##1\c_space_tl
+ \prop_item:Nn \g__uftag_attr_entries_prop
+ {##1}
+ }
+ \tl_gset:Nx \g__uftag_attr_class_content_tl
+ {
+ \seq_use:Nn \l_tmpa_seq
+ { \iow_newline: }
+ }
+ \tl_if_empty:NF \g__uftag_attr_class_content_tl
+ {
+ \__uftag_pdfreserveobjnum:N \l_tmpa_tl
+ \tl_const:Nx \c__uftag_tree_obj_classmap_tl { \l_tmpa_tl }
+ \__uftag_pdfuseobjnum:Nx \c__uftag_tree_obj_classmap_tl
+ { <<\g__uftag_attr_class_content_tl>> }
+
+ \__uftag_prop_gput:cnx
+ { g__uftag_struct_0_prop }
+ { ClassMap }
+ { \c__uftag_tree_obj_classmap_tl\c_space_tl0\c_space_tl R }
+ }
+ }
+
+
\cs_new:Nn \uftag_finish_structure:
{
\__uftag_pdfcatalog:n {^^J/MarkInfo\c_space_tl<</Marked\c_space_tl true>> }
\__uftag_tree_write_parenttree:
\__uftag_tree_write_rolemap:
+ \__uftag_tree_class_write_map:
\__uftag_tree_write_structelements:
\__uftag_tree_write_structtreeroot:
}
diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-user.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-user.sty
index 1b01e1521b6..c4a16b29420 100644
--- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-user.sty
+++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-user.sty
@@ -1,4 +1,4 @@
-\ProvidesExplPackage {tagpdf-user} {2018/08/06} {0.3}
+\ProvidesExplPackage {tagpdf-user} {2019/01/04} {0.50}
{tagpdf - user commands}
\NewDocumentCommand \tagpdfsetup { m }
@@ -84,6 +84,13 @@
}
}
+\sys_if_engine_luatex:T
+{
+ \NewDocumentCommand\pdffakespace { }
+ {
+ \__uftag_fakespace:
+ }
+}
\endinput
diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf.lua b/Master/texmf-dist/tex/latex/tagpdf/tagpdf.lua
index 0bd8c1441ca..c0262626181 100644
--- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf.lua
+++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf.lua
@@ -1,5 +1,5 @@
--- Packageversion: 0.3
--- Packagedate: 2018/08/06
+-- Packageversion: 0.50
+-- Packagedate: 2019/01/04
-- tagpdf.lua
-- Ulrike Fischer
@@ -42,16 +42,21 @@ functions
uftag.func.mark_shipout (): a wrapper around the core function which inserts the last EMC
uftag.func.fill_parent_tree_line (page): outputs the entries of the parenttree for this page
uftag.func.output_parenttree(): outputs the content of the parenttree
+ uftag.func.markspaceon(), uftag.func.markspaceoff(): (de)activates the marking of positions for space chars
uftag.trace.show_mc_data (num): shows uftag.mc[num]
uftag.trace.show_all_mc_data (max): shows a maximum about mc's
uftag.trace.show_seq: shows a sequence (array)
uftag.trace.show_struct_data (num): shows data of structure num
uftag.trace.show_prop: shows a prop
uftag.trace.log
+ uftag.trace.showspaces : boolean
--]]
-local mctypeattributeid = luatexbase.registernumber ("g__uftag_mc_type_attr")
-local mccntattributeid = luatexbase.registernumber ("g__uftag_mc_cnt_attr")
+local mctypeattributeid = luatexbase.registernumber ("g__uftag_mc_type_attr")
+local mccntattributeid = luatexbase.registernumber ("g__uftag_mc_cnt_attr")
+local iwspaceattributeid = luatexbase.registernumber ("g__uftag_interwordspace_attr")
+local iwfontattributeid = luatexbase.registernumber ("g__uftag_interwordfont_attr")
+
local catlatex = luatexbase.registernumber("catcodetable@latex")
local tagunmarkedbool= token.create("g__uftag_tagunmarked_bool")
@@ -63,11 +68,13 @@ local tableinsert = table.insert
local nodeid = node.id
local nodecopy = node.copy
local nodegetattribute = node.get_attribute
+local nodesetattribute = node.set_attribute
local nodenew = node.new
local nodetail = node.tail
local nodeslide = node.slide
local noderemove = node.remove
local nodetraverseid = node.traverse_id
+local nodetraverse = node.traverse
local nodeinsertafter = node.insert_after
local nodeinsertbefore = node.insert_before
local pdfpageref = pdf.pageref
@@ -77,6 +84,7 @@ local VLIST = node.id("vlist")
local RULE = node.id("rule")
local DISC = node.id("disc")
local GLUE = node.id("glue")
+local GLYPH = node.id("glyph")
local KERN = node.id("kern")
local PENALTY = node.id("penalty")
local LOCAL_PAR = node.id("local_par")
@@ -146,6 +154,88 @@ local function __uftag_insert_bdc_node (head,current,tag,dict)
return head
end
+-- this is for debugging the space chars
+local function __uftag_show_spacemark (head,current,color,height)
+ local markcolor = color or "1 0 0"
+ local markheight = height or 10
+ local pdfstring = node.new("whatsit","pdf_literal")
+ pdfstring.data =
+ string.format("q "..markcolor.." RG "..markcolor.." rg 0.4 w 0 %g m 0 %g l S Q",-3,markheight)
+ head = node.insert_after(head,current,pdfstring)
+ return head
+end
+
+--[[ a function to mark up places where real space chars should be inserted
+ it only sets an attribute.
+--]]
+
+local function __uftag_mark_spaces (head)
+ local inside_math = false
+ for n in nodetraverse(head) do
+ local id = n.id
+ if id == GLYPH then
+ local glyph = n
+ if glyph.next and (glyph.next.id == GLUE)
+ and not inside_math and (glyph.next.width >0)
+ then
+ nodesetattribute(glyph.next,iwspaceattributeid,1)
+ nodesetattribute(glyph.next,iwfontattributeid,glyph.font)
+ -- for debugging
+ if uftag.trace.showspaces then
+ __uftag_show_spacemark (head,glyph)
+ end
+ end
+ elseif id == PENALTY then
+ local glyph = n
+ -- uftag.trace.log ("PENALTY ".. n.subtype.."VALUE"..n.penalty,3)
+ if glyph.next and (glyph.next.id == GLUE)
+ and not inside_math and (glyph.next.width >0) and n.subtype==0
+ then
+ nodesetattribute(glyph.next,iwspaceattributeid,1)
+ -- nodesetattribute(glyph.next,iwfontattributeid,glyph.font)
+ -- for debugging
+ if uftag.trace.showspaces then
+ __uftag_show_spacemark (head,glyph)
+ end
+ end
+ elseif id == MATH then
+ inside_math = (n.subtype == 0)
+ end
+ end
+ return head
+end
+
+local function __uftag_activate_mark_space ()
+ if not luatexbase.in_callback ("pre_linebreak_filter","markspaces") then
+ luatexbase.add_to_callback("pre_linebreak_filter",__uftag_mark_spaces,"markspaces")
+ luatexbase.add_to_callback("hpack_filter",__uftag_mark_spaces,"markspaces")
+ end
+end
+
+uftag.func.markspaceon=__uftag_activate_mark_space
+
+local function __uftag_deactivate_mark_space ()
+ if luatexbase.in_callback ("pre_linebreak_filter","markspaces") then
+ luatexbase.remove_from_callback("pre_linebreak_filter","markspaces")
+ luatexbase.remove_from_callback("hpack_filter","markspaces")
+ end
+end
+--
+uftag.func.markspaceoff=__uftag_deactivate_mark_space
+
+local default_space_char = node.new(GLYPH)
+local default_fontid = font.id("TU/lmr/m/n/10")
+default_space_char.char = 32
+default_space_char.font = default_fontid
+
+local function __uftag_insert_space_char (head,n,fontid)
+ if luaotfload.aux.slot_of_name(fontid,"space") then
+ local space
+ -- head, space = node.insert_before(head, n, ) -- Set the right font
+ -- n.width = n.width - space.width
+ -- space.attr = n.attr
+ end
+end
--[[
Now follows the core function
@@ -179,6 +269,7 @@ function uftag.func.mark_page_elements (box,mcpagecnt,mccntprev,mcopen,name,mcty
end
for n in node.traverse(head) do
local mccnt, mctype, tag = __uftag_get_mc_cnt_type_tag (n)
+ local spaceattr = nodegetattribute(n,iwspaceattributeid) or -1
uftag.trace.log ("NODE ".. node.type(node.getid(n)).." MC"..tostring(mccnt).." => TAG "..tostring(mctype).." => " .. tostring(tag),3)
if n.id == HLIST
then -- enter the hlist
@@ -187,10 +278,26 @@ function uftag.func.mark_page_elements (box,mcpagecnt,mccntprev,mcopen,name,mcty
elseif n.id == VLIST then -- enter the vlist
mcopen,mcpagecnt,mccntprev,mctypeprev=
uftag.func.mark_page_elements (n,mcpagecnt,mccntprev,mcopen,"INTERNAL VLIST",mctypeprev)
- elseif n.id == GLUE then -- glue is ignored
+ elseif n.id == GLUE then -- at glue real space chars are inserted, for the rest it is ignored
+ -- for debugging
+ if uftag.trace.showspaces and spaceattr==1 then
+ __uftag_show_spacemark (head,n,"0 1 0")
+ end
+ if spaceattr==1 then
+ local space
+ local space_char = node.copy(default_space_char)
+ local curfont = nodegetattribute(n,iwfontattributeid)
+ uftag.trace.log ("FONT ".. tostring(curfont),3)
+ if curfont and luaotfload.aux.slot_of_name(curfont,"space") then
+ space_char.font=curfont
+ end
+ head, space = node.insert_before(head, n, space_char) --
+ n.width = n.width - space.width
+ space.attr = n.attr
+ end
elseif n.id == LOCAL_PAR then -- local_par is ignored
elseif n.id == PENALTY then -- penalty is ignored
- elseif n.id == KERN then -- kern is ignored
+ elseif n.id == KERN then -- kern is ignored
else
-- math is currently only logged.
-- we could mark the whole as math
diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty
index cc91ad5cee1..1c1b7740037 100644
--- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty
+++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty
@@ -1,7 +1,15 @@
\RequirePackage{expl3}[2018/06/14]
+%\RequirePackage[enable-debug]{expl3}[2018/06/14]
-\ProvidesExplPackage {tagpdf} {2018/08/06} {0.3}
+\ProvidesExplPackage {tagpdf} {2019/01/04} {0.50}
{A package to experiment with pdf tagging}
+%\debug_on:n{check-declarations,check-expressions,deprecation}
+
+%map internal tag to package name
+\prop_if_exist:NT \g_msg_module_name_prop
+ {
+ \prop_gput:Nnn \g_msg_module_name_prop { uftag }{ tagpdf }
+ }
% storing internal names to my name space:
\cs_set_eq:NN \__uftag_tex_pdffeedback:D \tex_pdffeedback:D
@@ -33,8 +41,8 @@
\RequirePackage{atbegshi}
\RequirePackage{zref-base,zref-lastpage}
\RequirePackage{etoolbox}
-\RequirePackage{pdfescape}
-\RequirePackage{pdftexcmds}
+%\RequirePackage{pdfescape} %check if needed
+%\RequirePackage{pdftexcmds}%check if needed (expandable commands!)
\RequirePackage{l3str-convert}
\cs_generate_variant:Nn \str_set_convert:Nnnn {Nonn, Noon, Nnon }
@@ -59,7 +67,7 @@
activate-tree .bool_gset:N = \g_uftag_active_tree_bool,
activate-struct .bool_gset:N = \g_uftag_active_struct_bool,
activate-all .meta:n ={activate-mc,activate-tree,activate-struct},
- check-tags .bool_set:N = \g__uftag_check_tags_bool,
+ check-tags .bool_gset:N = \g__uftag_check_tags_bool,
check-tags .initial:n = true,
log .choice:,
log / none .code:n = {\int_set:Nn \l__uftag_loglevel_int { 0 }},
@@ -155,7 +163,7 @@
\cs_generate_variant:Nn \__uftag_prop_show:N { c }
\cs_generate_variant:Nn \prop_gput:Nnn {Nxx}
\cs_generate_variant:Nn \prop_put:Nnn {Nxx}
-\cs_generate_variant:Nn \__uftag_pdfuseobjnum:Nn {Nx}
+\cs_generate_variant:Nn \__uftag_pdfuseobjnum:Nn {Nx,No}
\cs_generate_variant:Nn \__uftag_pdfuseobjnum:nn {nx,xx}
\cs_generate_variant:Nn \__uftag_gset_pdfpageattr:n {x}
@@ -176,6 +184,7 @@
\RequirePackage { tagpdf-user }
\RequirePackage { tagpdf-tree-code }
\RequirePackage { tagpdf-roles-code }
+\RequirePackage { tagpdf-attr-code }
% mc-code is split:
\RequirePackage { tagpdf-mc-code-shared }
\bool_if:NTF \g__uftag_mode_lua_bool
@@ -187,5 +196,5 @@
}
\RequirePackage { tagpdf-struct-code }
-
+\RequirePackage { tagpdf-space-code }
\endinput