Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pandoc template syntax is not completely supported #1038

Open
omentic opened this issue Jul 22, 2024 · 4 comments
Open

Pandoc template syntax is not completely supported #1038

omentic opened this issue Jul 22, 2024 · 4 comments

Comments

@omentic
Copy link

omentic commented Jul 22, 2024

Hakyll recognizes content within the $...$ deliminators in templates as pandoc template syntax, and supports insertation of variables and usage of pandoc control structures within them.

But Pandoc has an alternative syntax that Hakyll does not seem to recognize: ${...}. I was a little surprised by this when first getting Hakyll set up.

[ERROR] _templates/post.html: Cannot parse template "_templates/post.html" (line 14, column 2):
    unexpected "{"
    expecting "-", "if(", "for(", "partial(", "\"" or letter

Could this syntax be supported? It is not at all an important request, but it would be nice for Hakyll to behave more similarly to Pandoc here.

@Minoru Minoru added the feature label Jul 23, 2024
@Minoru
Copy link
Collaborator

Minoru commented Jul 23, 2024

Yeah, Hakyll has its own implementation of templates, that's why there's a disparity in syntax. I think it'd be easy enough to fix: the Parsec parser for templates is defined in lib/Hakyll/Web/Template/Internal/Element.hs. Opening and closing dollar signs are parsed by trimOpen and trimClose. I think these will have to be replaced by some sort of a "bracketing" function, which should then be enhanced to support the curly-bracket syntax.

@omentic
Copy link
Author

omentic commented Jul 23, 2024

Why does Hakyll have its own implementation of templates, out of curiosity?

@Minoru
Copy link
Collaborator

Minoru commented Jul 25, 2024

I checked Git and it seems that Pandoc added its templates a couple years before Hakyll did, so now I'm curious myself! @jaspervdj can answer authoritatively.

@LaurentRDC
Copy link
Collaborator

Recall that using pandoc with Hakyll is completely optional. You can compile pages using non-pandoc machinery.
Hence, templating must be implemented in Hakyll.

It could be nice to support the pandoc template syntax -- I am happy to review pull requests -- but Hakyll's internal template machinery is here to stay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants