Quantcast
Channel: Active questions tagged starred-version - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 63

Passing a star to lua

$
0
0

I hope this is a simple question, but I could not find documentation on it. Maybe I am searching for the wrong keywords.

I want to pass a star * option to my lua code. I believe it is a boolean, based on code from an older project. \bool_if:NTF #1 {do true stuff}{do false stuff}

But something about passing a star as a parameter breaks the code.

\NewDocumentCommand{\addline}{smm}{\directlua{myluacodefile.addline(#1,"#2","#3")}}%

Here is a minimum "working" example

main.tex

\documentclass[letterpaper]{article}\usepackage{xparse}%for advanced command declaration\directlua{myluacodefile = require("myluacodefile")}%this links the .lua\newcommand{\sanitycheck}[2]{\directlua{myluacodefile.sanitycheck(#1,#2)}}%%\NewDocumentCommand{\addline}{mm}{\directlua{myluacodefile.addline("A","#1","#2")}}%turn this on to see the code "work"\NewDocumentCommand{\addline}{smm}{\directlua{myluacodefile.addline(#1,"#2","#3")}}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\begin{document}hello\sanitycheck{1}{2}\addline{first}{second}\addline*{third}{fourth}\end{document}

myluacodefile.lua

local myluacodefile = {}--lua module startname = "Sanity Check"function myluacodefile.sanitycheck(a,b)    c=a+b    tex.print(c)    tex.print(name)endfunction myluacodefile.addline(star, alpha, beta)    local testa = alpha    local testb = beta    tex.print(testa)    tex.print(testb)endreturn myluacodefile--lua module end

Viewing all articles
Browse latest Browse all 63

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>