You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have successfully installed sile - and can use it to typeset this little document for example:
the lua script therein being one of the first examples from the sile manual:
\begin{document}
Hello SILE!
\begin{script}
for i=1,10 do
SILE.typesetter:typeset(i .. " x " .. i .. " = " .. i*i .. ". ")
SILE.typesetter:leaveHmode()
SILE.call("smallskip")
end
\end{script}
\end{document}
(each [i value (ipairs ["b""b""c"])]
;; (print index value)
(SILE.typesetter:typeset (.. i " x " i " = " (* i i)))
(SILE.typesetter:leaveHmode)
(SILE.call "smallskip")
)
This (sile foobar.sil) creates a foobar.pdf as attached. foobar.pdf
I yet have to find out how to just use fennel - without a separate main.fnl - somehow like this ??:
\begin{document}
Hello SILE!
\begin{script}
require("fennel").install().(each [i value (ipairs ["b" "b" "c"])]
(SILE.typesetter:typeset (.. i " x " i " = " (* i i)))
(SILE.typesetter:leaveHmode)
(SILE.call "smallskip")
)
\end{script}
\end{document}
Maybe fennel could become a first class sile citizen ?
What always works, of course: use fennel as a converter:
fennel file.fnl
to create a file.lua - and this could be sile-lua file
but I was interested here really, how to integrate fennel in a (normal) .sil file.
I'm not at home and have spotty access and time for a few weeks, but off the top of my head it should be possible to simplify this quite a bit. I would probably write a LuaRocks package as a 3rd party module for SILE that copies most of the current lua inputter code but adds the Fennel preprocessor step. Then post it to LuaRocks with a dependency on fennel. That done a simple "luarocks install fennel.sile" should get things going, and in a document you could then \use[module=fennel] to load the inputer, after which you could have a \fennel{...} command available to use in place of \lua{} (of which \script{} is just an alias).
Great! - And thanks for getting back to me about this. - I will have a look (and a stab) at writing
a loarocks sile package for fennel then sometime - not immediately though: I am busy myself, and have only just started reading the sile manual, and I prefer to continue reading / progressing step by step: but I see that in the later chapters
of the manual writing a sile package is explained.
I agree with @alerque that this is best addressed as a 3rd-party package. The fennel.lua file is above 5KLoc and 230kB of machine-generated code, which is quite a lot for such a niche use case, without clear rationale (except a vague user preference for Lisp-like syntax?) Besides, it's certainly not the task of the SILE core distribution to maintain such an embedding and keep track of versions and updates for such a niche language - not even mentioning investigating potential bugs.
On the technical aspect, however, I don't think an inputter is even needed, neither the need for a reserving a \fennel command as SIL pass-through exception... Raw command handlers should be largely sufficient and have the necessary API, and provided one does read the manual up to the relevant chapter before asking how to implement things, one should find there the needed information. I would suggest starting with this solution...
As for being busy, aren't we all?
But bear with me, the above suggestion is then at most 15-20mn of coding for an experienced senior developer :)
Really? Aye, just did it. This said, I will close this issue and move it to the discussions (Q&A). I'll post my PoC code there.
Activity
reuleaux commentedon Jul 18, 2023
To answer my own question: I got it working (at least with a separat main.fnl file, cf. below) - like so:
(I am installing everything as a normal user rx (/home/rx), except sile's luarocks deps - those as root)
clone & make fennel
(there should be a fennel.lua file then in ~/tmp/fennel)
then configure/make/install sile - with fennel in mind:
configure 1st time - just so that sile-dev-1.rockspec is created:
install lua deps (this step as root):
now do the real configure - and as for fennel: use LDFLAGS
make & inscall
then have a sample file foobar.sil
and next to it a file main.fnl:
This (
sile foobar.sil) creates a foobar.pdf as attached.foobar.pdf
I yet have to find out how to just use fennel - without a separate main.fnl - somehow like this ??:
Maybe fennel could become a first class sile citizen ?
What always works, of course: use fennel as a converter:
to create a file.lua - and this could be sile-lua file
but I was interested here really, how to integrate fennel in a (normal) .sil file.
Thanks, A'
alerque commentedon Jul 18, 2023
I'm not at home and have spotty access and time for a few weeks, but off the top of my head it should be possible to simplify this quite a bit. I would probably write a LuaRocks package as a 3rd party module for SILE that copies most of the current lua inputter code but adds the Fennel preprocessor step. Then post it to LuaRocks with a dependency on fennel. That done a simple "luarocks install fennel.sile" should get things going, and in a document you could then
\use[module=fennel]to load the inputer, after which you could have a\fennel{...}command available to use in place of\lua{}(of which\script{}is just an alias).reuleaux commentedon Jul 18, 2023
Great! - And thanks for getting back to me about this. - I will have a look (and a stab) at writing
a loarocks sile package for fennel then sometime - not immediately though: I am busy myself, and have only just started reading the sile manual, and I prefer to continue reading / progressing step by step: but I see that in the later chapters
of the manual writing a sile package is explained.
Omikhleia commentedon Jul 23, 2023
I agree with @alerque that this is best addressed as a 3rd-party package. The
fennel.luafile is above 5KLoc and 230kB of machine-generated code, which is quite a lot for such a niche use case, without clear rationale (except a vague user preference for Lisp-like syntax?) Besides, it's certainly not the task of the SILE core distribution to maintain such an embedding and keep track of versions and updates for such a niche language - not even mentioning investigating potential bugs.On the technical aspect, however, I don't think an inputter is even needed, neither the need for a reserving a
\fennelcommand as SIL pass-through exception... Raw command handlers should be largely sufficient and have the necessary API, and provided one does read the manual up to the relevant chapter before asking how to implement things, one should find there the needed information. I would suggest starting with this solution...As for being busy, aren't we all?
But bear with me, the above suggestion is then at most 15-20mn of coding for an experienced senior developer :)
Really? Aye, just did it. This said, I will close this issue and move it to the discussions (Q&A). I'll post my PoC code there.