The preceding post marks a change in how code will be highlighted on this blog, now being based on Google's client side code highlighting library. What I'm using follows what Luka Marinko describes.
Overall, I think the result is decent, but not quite as nice as what I was doing before. But it's so much easier that I'm willing to provisionally accept the new look.
Showing posts with label blogging. Show all posts
Showing posts with label blogging. Show all posts
Wednesday, July 20, 2011
Monday, December 8, 2008
Formatted Program Text for Blogger
This blog features a fair amount of code. So far, I've been doing the formatting from SubEthaEdit. Using SEE has worked OK, but was kind of a fiddly procedure. I'd open the desired program, copy as XHTML, paste that into a new document, remove all the lines breaks, copy the modified text, and paste it into MarsEdit. No step is difficult, but automating it is a pain, requiring GUI scripting in AppleScript. Further, it would require running everything through SEE, whether that would make sense or not.
Thus, before scripting the above approach, I looked for other options. Two seem promising: Pygments and highlight. Both provide shell filters for converting program text into HTML. For now, I've settled on highlight, since Pygments lacks support for highlighting Standard ML.
Several command line options are appropriate. For example, I can format an SML file with
Pasting that into MarsEdit nicely formats the contents of
I'm sure I'll need to refine the approach a bit as I go, but this already seems easier than the approach I'd been using.
Thus, before scripting the above approach, I looked for other options. Two seem promising: Pygments and highlight. Both provide shell filters for converting program text into HTML. For now, I've settled on highlight, since Pygments lacks support for highlighting Standard ML.
Several command line options are appropriate. For example, I can format an SML file with
cat real-ord.sml | highlight --inline-css -f --enclose-pre -S sml -s seashell | pbcopy
Pasting that into MarsEdit nicely formats the contents of
real-ord.sml
:structure RealOrdKey : ORD_KEY where type ord_key = Real.real = struct
open Real
type ord_key = real
end
I'm sure I'll need to refine the approach a bit as I go, but this already seems easier than the approach I'd been using.
Subscribe to:
Posts (Atom)