Adding scripts in Mallard?

Shaun McCance <shaunm at gnome.org>
Mon Feb 20 11:14:18 EST 2012

On Wed, 2012-02-15 at 21:37 +0100, Philip Chimento wrote:
> Hello,
> 
> I'm wondering if there's a way to include <script>s in the HTML that
> Mallard generates. For example, I'd like to have my code listings
> highlighted with highlight.js [1], so I'd want to add, say, the
> following to the <head> in the generated HTML:
> 
> <link rel="stylesheet"
> href="http://yandex.st/highlightjs/6.1/styles/github.min.css"></link>
> <script src="../highlight.pack.js"></script>
> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
> <script>
> $(document).ready(function() {
>   $('pre.code').each(function(i, e) {hljs.highlightBlock(e, '    ')});
> });
> </script>
> 
> But there's no <xsl:apply-templates> in the section of
> mal2html-page.xsl that generates the HTML's <head>, so no place for a
> custom XSLT stylesheet to hook into.

You want to override the html.head.custom template, defined in
common/html.xsl.

Incidentally, Yelp's stylesheets can do syntax highlighting using the
jQuery.Syntax library if you set the mime attribute on code elements
and you set the html.syntax.highlight parameter to true. I still need
to do quite a bit of work on the colorers, though, so if you're happier
with the results with highlight.js, just use that.

--
Shaun