I'm having a heck of a time getting Pygments or Highlights to furnish syntax coloring in my pollen documents. I followed the tutorial (9 Mini tutorials). I got Pygments to color the code, but the CSS styles that I copied into my template.html.p don't seem to affect the colors! I need to change them because I am using a dark background. I got Highlights to render the code, but there are no colors! The cited example from Matthew Butterick (unitscale.com) is a dead link. Google searching did not reveal a copy (perhaps I should try the Wayback Machine).
I'd be grateful for a working example of either approach!
@joeld thanks for your kind attention! DISCLAIMER: I admit this is my first and non-fancy attempt at a pollen document. I am operating on guesswork from a thin reading of the documentation and a gaseous, even nebulous, understanding of both html and pollen. I would not blame you if you ignored me as a hopeless dunce! OTOH, my early success with the tufte CSS encouraged me to plow-on semi-blindly!
Also, I must break this up into multiple posts due to restrictions on new users (like me) from the web-site. Please forgive me! Here is post 1 of 3:
Yes, a #lang pollen file with a .pmd extension is equivalent to #lang pollen/markdown.
I think you’re on the right track with your second attempt. When using pollen\markdown, the results of any embedded Racket expressions get converted to strings before the document is parsed as Markdown. So in order to be really useful, any such expressions need to produce strings of Markdown—or HTML, which is valid Markdown.
The error from your second attempt stems from a small syntax error: in line 152 of your excerpt, there should be no space between ['scheme] and {, so the line should read:
◊(->html ◊highlight['scheme]{
Pollen command syntax (which follows @ Syntax in every respect except that it uses ◊ by default instead of @) requires that there be no whitespace between the [datum] portion of the command and the {text-body} portion.
Maybe you knew this already and it was a simple typo. When I started with Pollen (which was my introduction to Racket), I was thinking of the curly braces as simple grouping operators that could be placed anywhere (as in C programming, for example), and ran into similar issues.
Now it appears that the ->html from pollen/template is not visible within your pollen source file, so in that file ->html is not bound to any value. In normal Racket this would cause an error, but Pollen intervenes to convert the failed function call into a simple X-expression.
So, try adding ◊(require pollen/template) to your .pmd file to see if that fixes it. (This is the module that provides Pollen’s ->html function.)
Because bindings in a nearby pollen.rkt are automatically imported to your Pollen file, you can use this racketcode function, and you won’t have to (require pollen/template) in your documents:
#lang pollen
Here is an example function with syntax highlighting:
◊racketcode{
(define (hello name)
(format "Hello, ~a" name))
}