[luatex] Library for regular expressions in lualatex

Саша Козловский k.sasha1994 at yandex.ru
Tue Jun 11 11:19:50 CEST 2019


Hello Henri.
> insert ActualText within the
> mlist_to_hlist callback
May be it's a very good idea,but how i can get text of formula. Because 
if i redefine $$ or $ or another commands,i can get text of formula,but 
how i can do it in node tree?
> You asked a similar question about that before as well, but for
> local_par instead of mlist

Thank you very mutch fore link to my question,because i couldn't found 
it,but in your example exist issue,because if in pdf document in 
paragraf more then one line,pdfliteral only inserted at the first line. 
Please,if it not difficult for you,fix this issue. here is a document 
where you can see this issue. Thank you very mutch for your help.

\documentclass[11pt]{amsart}
\usepackage{atbegshi}
\usepackage{luacode}
%\usepackage{tagpdf}
%\tagpdfsetup{tabsorder=structure,uncompress,activate-all,interwordspace=true}
%\pdfextension catalog{/Lang (ru-RU)}
\begin{luacode}
local local_par_counter=0
local BDC = node.new("whatsit","pdf_literal")
local EMC = node.new("whatsit","pdf_literal")
BDC.mode = 2
EMC.data = 'EMC'
EMC.mode = 2
function fields(par)
f,f0=node.fields(par.id,par.subtype),""
for _,c in ipairs(f) do
if c~=nil and par[c]~=nil then
f0=f0.."field "..c.." value "..tostring(par[c]).." "
end
end
return f0
end
function tag_local_par(parent, level)
     local head = parent.list
     while head do
texio.write_nl("type "..(node.type(head.id)~=nil and node.type(head.id) 
or "unknown"))
texio.write_nl("fields "..fields(head))
         if head.id == node.id"hlist" or head.id == node.id"vlist" then
             if head.list and head.list.id == node.id"local_par" then
                 local par_list = head.list and head.list.next -- 
local_par should always be followed by a list
local_par_counter=local_par_counter+1
BDC.data = string.format('/Span <</ActualText(paragraph %s)>> 
BDC',local_par_counter)
                 head.list = node.insert_before(head.list, head.list, 
node.copy(BDC))
                 par_list = node.insert_after(par_list, 
node.tail(par_list), node.copy(EMC))
elseif head.list~=nil then
end
             tag_local_par(head, level + 1)
         end
         head = head.next
     end
end
\end{luacode}
\AtBeginShipout{\directlua{texio.write_nl("type 
"..node.type(tex.box["AtBeginShipoutBox"].id)) texio.write_nl("fields 
"..fields(tex.box["AtBeginShipoutBox"])) 
tag_local_par(tex.box["AtBeginShipoutBox"], 0)}}%
\begin{document}
a b c d e f g h
a $a_{n} = 0$ for some $n$, then show that either $a_{0} = 0$ or $a_{1} 
= 0$.
\end{document}



More information about the luatex mailing list