@@ -66,7 +66,7 @@ function luaxml_sty.parse_snippet(current, xml_string)
66
66
else
67
67
dom = domobject .html_parse (xml_string )
68
68
end
69
- print (dom :serialize ())
69
+ luaxml_sty . debug (dom :serialize ())
70
70
local result = transform :process_dom (dom )
71
71
luaxml_sty .packages .transform .print_tex (result )
72
72
end
@@ -82,4 +82,29 @@ function luaxml_sty.parse_file(current, filename)
82
82
luaxml_sty .parse_snippet (current , content )
83
83
end
84
84
85
+ --- parse environment contents using Lua
86
+ -- idea from https://tex.stackexchange.com/a/574323/2891
87
+ function luaxml_sty .store_lines (env_name , callback_name )
88
+ return function (str )
89
+ print (" str" , str )
90
+ local env_str = [[ \end{]] .. env_name .. " }"
91
+ if string.find (str , env_str :gsub (" %*" , " %%*" )) then
92
+ print (" end of environment" )
93
+ luatexbase .remove_from_callback ( " process_input_buffer" , callback_name )
94
+ return env_str -- str
95
+ else
96
+ table.insert (luaxml_sty .verb_table , str )
97
+ end
98
+ return " "
99
+ end
100
+ end
101
+
102
+ function luaxml_sty .register_verbatim (env_name )
103
+ luaxml_sty .verb_table = {}
104
+ local callback_name = " luaxml_store_lines_" .. env_name
105
+ local fn = luaxml_sty .store_lines (env_name , callback_name )
106
+ luatexbase .add_to_callback (
107
+ " process_input_buffer" , fn , callback_name )
108
+ end
109
+
85
110
return luaxml_sty
0 commit comments