Adding scripts in Mallard?

Shaun McCance <shaunm at gnome.org>
Thu Feb 23 09:10:09 EST 2012

On Mon, 2012-02-20 at 23:42 +0100, Philip Chimento wrote:
> On Mon, Feb 20, 2012 at 17:14, Shaun McCance <shaunm at gnome.org> wrote:
> > 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.
> 
> Ah, okay - I was using gnome-doc-tool and its stylesheets, not
> yelp-build... that clarifies a lot. I see yelp's stylesheets provide
> much more opportunities for customization.

Yeah, the gnome-doc-utils stylesheets are deprecated in favor of
the yelp-xsl stylesheets. All the new Mallard feature development
is in yelp-xsl, as well as a bunch of changes that make the XSLT
a lot easier for customizations.

The stylesheets are reasonably well-documented, but unfortunately
I don't have the documentation built out on the web. If you don't
mind building yourself from a tarball release, do this:

./configure --enable-doc
cd doc/yelp-xsl/
make

The documentation will then be under the C directory, as a Mallard
document. As of yelp-xsl 3.3.2, there's a guide page (stubs.page)
that lists all the stub templates. These are templates that have
no default implementation, and are intended for customizations to
add stuff in.

--
Shaun