I want to make a character active/sensitive and pass its preceding character as an argument of some command. I could do it using LuaLaTeX engine and luacode package. Thanks to this and this post.
% !TEX TS-program = lualatex
\documentclass{article}
\usepackage{luacode}
\begin{luacode}
function myligs ( s )
s = unicode.utf8.gsub ( s , '(\\?)([%a@]+)' , function( backslash, text )
if backslash=='' then
text = unicode.utf8.gsub(text, '(.)(æ)', '%1%\\textbf{%1}' )
end
return backslash .. text
end)
return s
end
\end{luacode}
\begin{document}
\directlua{luatexbase.add_to_callback("process_input_buffer", myligs, "myligs")}
aæ
bæ
\end{document}
but this seems to not work with dependent diacritic characters. See the following example -
% !TEX TS-program = lualatex
\documentclass{article}
\usepackage{luacode}
\begin{luacode}
function myligs ( s )
s = unicode.utf8.gsub ( s , '(\\?)([%a@]+)' , function( backslash, text )
if backslash=='' then
text = unicode.utf8.gsub(text, '(.)(◌́)', '%1%\\textbf{%1}' )
end
return backslash .. text
end)
return s
end
\end{luacode}
\begin{document}
\directlua{luatexbase.add_to_callback("process_input_buffer", myligs, "myligs")}
a◌́
\end{document}
Probably the dependent diacritic is not interpreted in the same way a normal character is. Can somebody please explain me what is exactly wrong in the second code? I want the output of both of these codes to be identical i.e. aa where the second a is bold.

◌́does not match either element of the[%a@]"character class" (a Lua jargon term), i.e., either%a("any alphabetic character") or@("at character"). Because the◌́character is never matched in the first-stage or "outer" gsub operation, it doesn't get passed on to the second-stage or "inner" gsub operation, and hence no match involving this character can ever occur in that second stage. – Mico Sep 20 '20 at 14:43unitipa! I have submitted it. Soon it'll appear on the CTAN. I have cited your answer in the documentation. It helped me a lot. :) If you are curious about the package you can see it here. – Niranjan Sep 20 '20 at 16:22