24 Apr 2012 10:42
Re: change latex output with csquotes
23 April 2012 17:02, Diogo <ogoid.backup@...>: > I have no experience with Haskell/functional languages and > have no clue of how to do this. Haskell programmers are like concert pianists: one can admire their virtuosity without longing to be able to do the same. > Basically what I want is to substitute occurrences of > `\enquote{bla}\autocite{key}` in the generated Latex file by > `\textquote[\autocite{key}]{bla}`. > I do that sort of thing with a Lua script: if you have TeX, you have luatex, and luatex does Lua. Anyone can learn basic Lua by just looking at a sample of working code. (Advanced Lua is subtle, but you don't need it.) ~~~ requote.lua name = arg[1] input = assert(io.open(name),"Can't read from"..name) source = input:read("*a") search = "\\enquote{(.-)}\\autocite{(.-)}" replace = "\\textquote[\\autocite{%2}]{%1}" output = assert(io.open(name,"w"),"Can't write to "..name) output:write (source:gsub(search,replace)) ~~~ Then just $ luatex requote.lua generatedfile.tex I'd be scared in general to use a script like this one which replaces the input file instead of writing a new one, but since it's only a generated file, your real source is not at risk. Another advantage of using Pandoc. Dirk
RSS Feed