Generating LaTeX code by reading template as a raw string

398 views
Skip to first unread message

Bill Kranec

unread,
Mar 12, 2013, 2:31:40 PM3/12/13
to mako-d...@googlegroups.com
Like the subject states, I'm trying to use Mako to generate some LaTeX code, in particular, I'd like to format some tabular data, like so

% for time in times:
  ${time} & & \\ \hline
% endfor

The problem is that '\\' is interpreted as a single escaped backslash, and '\' is printed in the result, which LaTeX doesn't like.  I'm not sure if this is due to Mako or how Python reads strings.

Is there any way that I can tell Mako to read the template as a raw string?  I know that I can use '\\\' to print a literal double backslash, but I would like to keep the template code as similar to the original TeX code as possible.

Thanks for your help!

Bill

Michael Bayer

unread,
Mar 12, 2013, 3:02:36 PM3/12/13
to mako-d...@googlegroups.com
${'\\'} is how it has to be, if you want, you can specify a preprocessor function to your Template(Lookup) that will search for strings of the form "\\" and add the brackets around them.


--
You received this message because you are subscribed to the Google Groups "Mako Templates for Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mako-discuss...@googlegroups.com.
To post to this group, send email to mako-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/mako-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages