Who's at fault with this error concerning csquotes and LuaLaTeX?
Your first example and your second are actually quite different errors. The first is your fault (see Davids answer), but the second is a bug in lilyglyphs
lua code.
But the problem is not the quote in \directlua
. As the command is defined in lilyglyphs
the catcode of the " is frozen there and so not problematic.
lilyglyphs
uses tex.sprint
to print the char, and the argument contains a "
. As tex.sprint
uses by default the current active catcode regime this explodes. You can tell tex.sprint
to use another catcode table. (I'm not quite sure if \CatcodeTableLaTeX
I used the best one, but it works):
\documentclass{article}
\usepackage{fontspec, csquotes,lilyglyphs}
%copied from lilyglyphs
\begin{luacode}
documentdata = documentdata or { }
local stringformat = string.format
local texsprint = tex.sprint
local slot_of_name = luaotfload.aux.slot_of_name
documentdata.fontchar = function (chr)
local chr = slot_of_name(font.current(), chr, false)
if chr and type(chr) == "number" then
texsprint
(\the\CatcodeTableLaTeX,
stringformat ([[\char"%X"]], chr))
end
end
\end{luacode}
\MakeOuterQuote{"}
\EnableQuotes
\begin{document}
\wholeNote
\end{document}
Sorry but since you ask, I'd say it was your fault:-)
Having made a character active you should have known to make it safe before passing to Lua.
For example:
\documentclass{article}
\usepackage{csquotes}
\MakeOuterQuote{"}
\EnableQuotes
\begin{document}
\directlua{print(\string"hello\string")}
\end{document}
See Ulrike's answer for the second example.