Philip
2015-09-23 09:13:03 UTC
Hi,
I want to pass the body of my posts through the sed command before
Pandoc starts processing it. How do I do this?
The details: I want to write posts in Markdown and use hakyll to
convert them to HTML. I would like to use LaTeX-style maths
delimiters, namely \( and \), to denote maths content in my posts, so
that MathJax can then render it as maths when displaying the resulting
HTML.
The trouble with this is that Pandoc sees these as escaped parentheses
and de-escapes them, so that the final HTML does not contain the
back-slashes.
For example, if I have the following in the source of my post:
\(e^{i\pi}= -1\)
, then this gets output in the HTML version as:
(e^{i\pi}= -1)
, with the consequence that this does not look like maths code MathJax,
and hence gets rendered in the browser as LaTeX code rather than as
formatted maths.
My solution to this problem is to escape the back-slashes, so that they
appear in the resulting HTML document. That is, I would write the above
expression as:
\\(e^{i\pi}= -1\\)
in my source (note the double back-slashes). The trouble with this is
that typing the extra backslashes gets old very fast. In many cases, I
end up typing 7 characters to display one maths character, such as in:
"Consider a finite set \\(S\\)."
My solution to *this* problem is to run my sources through the following
sed script which replaces each LaTeX maths delimiter with the
double-escaped version:
sed -e 's/\\(/\\\\(/g; s/\\)/\\\\)/g'
My question is: How can I get hakyll to do this for me, instead of me
running the script whenever I change any post?
I got my site.hs from Alp's repository here:
https://github.com/alpmestan/alpmestan.com . The part of site.hs which
handles posts looks like this:
match "posts/*" $ do
route $ setExtension "html"
compile $ myPandocCompiler
the unixFilter function to get what I want. The trouble is that I don't
know how to work an invocation of this function into the above chain.
Could you help me with this?
Thanks and regards,
Philip
I want to pass the body of my posts through the sed command before
Pandoc starts processing it. How do I do this?
The details: I want to write posts in Markdown and use hakyll to
convert them to HTML. I would like to use LaTeX-style maths
delimiters, namely \( and \), to denote maths content in my posts, so
that MathJax can then render it as maths when displaying the resulting
HTML.
The trouble with this is that Pandoc sees these as escaped parentheses
and de-escapes them, so that the final HTML does not contain the
back-slashes.
For example, if I have the following in the source of my post:
\(e^{i\pi}= -1\)
, then this gets output in the HTML version as:
(e^{i\pi}= -1)
, with the consequence that this does not look like maths code MathJax,
and hence gets rendered in the browser as LaTeX code rather than as
formatted maths.
My solution to this problem is to escape the back-slashes, so that they
appear in the resulting HTML document. That is, I would write the above
expression as:
\\(e^{i\pi}= -1\\)
in my source (note the double back-slashes). The trouble with this is
that typing the extra backslashes gets old very fast. In many cases, I
end up typing 7 characters to display one maths character, such as in:
"Consider a finite set \\(S\\)."
My solution to *this* problem is to run my sources through the following
sed script which replaces each LaTeX maths delimiter with the
double-escaped version:
sed -e 's/\\(/\\\\(/g; s/\\)/\\\\)/g'
My question is: How can I get hakyll to do this for me, instead of me
running the script whenever I change any post?
I got my site.hs from Alp's repository here:
https://github.com/alpmestan/alpmestan.com . The part of site.hs which
handles posts looks like this:
match "posts/*" $ do
route $ setExtension "html"
compile $ myPandocCompiler
= loadAndApplyTemplate "templates/post.html" (postCtx tags)
= saveSnapshot "content"
= loadAndApplyTemplate "templates/default.html" (defaultContext `mappend` yearCtx year)
= relativizeUrls
After a bit of looking around, I figured out that I probably have to use= saveSnapshot "content"
= loadAndApplyTemplate "templates/default.html" (defaultContext `mappend` yearCtx year)
= relativizeUrls
the unixFilter function to get what I want. The trouble is that I don't
know how to work an invocation of this function into the above chain.
Could you help me with this?
Thanks and regards,
Philip
--
You received this message because you are subscribed to the Google Groups "hakyll" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hakyll+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "hakyll" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hakyll+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.