Description of problem: I have been working of late to see how feasible it is to build documentation from the openstack-manuals project using Publican, allowing us to single source while working with the upstream community. At this time I am looking at using a pre-build script to perform some transformations on the XML to allow this but some of these seem like they should/could be unnecessary. One of these is that the build system used upstream copes with lower case language attribute values on programlisting elements, so for example this is widespread in the source: <programlisting language="bash"> This causes a fatal error when built with publican (Kate.pm expects "Bash") but works with other build systems including the one used to produce docs.openstack.org (clouddocs-maven). The DocBook specification only states that the language attribute must be CDATA. Currently what I am doing in my pre-build scripting is to replace these with the values publican expects, but ideally what I would like to see - and what I am requesting under this bug - is some mapping Assuming that the highlighting functionality built/used by Kate is unlikely to change in this respect I would like to see some translation at the publican level of languages attributes - irrespective of case - to those expected by Kate.pm. Version-Release number of selected component (if applicable): publican-3.1.3-1.fc17.noarch
Created attachment 737001 [details] XSLT to convert programlisting language to value recognized by Kate.pm I have attached XSLT which converts all programlisting language attributes to the values recognized by Kate.pm, assuming that the only difference between the source value and a recognized value is the case. Source values are checked against all values listed as supported by Kate.pm. If the language attribute is not recognized at all then it is left "as is" (source).
This might be better as a patch to the highlighting module. --- a/Syntax/Highlight/Engine/Kate.pm 2010-01-23 06:39:05.000000000 +1000 +++ b/Syntax/Highlight/Engine/Kate.pm 2013-04-18 12:51:36.929757998 +1000 @@ -610,10 +610,28 @@ } sub languagePlug { - my ($self, $req) = @_; + my ($self, $req, $insensitive) = @_; + unless (exists($self->{'syntaxes'}->{$req})) { - warn "undefined language: $req"; - return undef; + if(defined($insensitive) && $insensitive) { + my $matched = 0; + foreach my $key () { + if($key =~ /^$req$/i){ + warn "substituting language $key for $req"; + $req = $key; + $matched = 1; + last; + } + } + + unless ($matched) { + warn "undefined language: $req"; + return undef; + } + } else { + warn "undefined language: $req"; + return undef; + } Then we supply the extra parameter in publican and away we go.
gah -foreach my $key () { +foreach my $key (keys(%{$self->{'syntaxes'}})) {
FYI I have opened an upstream bug to get this added to the highlighting module. https://rt.cpan.org/Ticket/Display.html?id=84982 I'm happy to carry this patch in perl-Syntax-Highlight-Engine-Kate internally until it gets upstream. You will need to contact the Fedora package maintainer if you'd like them to carry the patch. Once the patch is in place there are a couple of small changes we need to make to publican to switch on the new behavior. A: bump the module dep in Build.pm to match the new version of the highlighting module B: this patch to Builder.pm @@ -2314,7 +2314,7 @@ }, ); - my $tmp = $hl->languagePlug($language) || croak( + $language = $hl->languagePlug($language) || croak( C: communicate the patch requirement to maintainers on other distros.
sigh moar coffee B: this patch to Builder.pm @@ -2314,7 +2314,7 @@ }, ); - my $tmp = $hl->languagePlug($language) || croak( + $language = $hl->languagePlug($language, 1) || croak(
HSS-QE has reviewed and declined this request. QE for this bug will be handled by IED.
To ssh://git.fedorahosted.org/git/publican.git bcea0b5..0dec188 HEAD -> devel
The language attribute on programlistings is now case-insensitive. I ran into a small related issue; I filed a separate bug (BZ#987059) so that it doesn't block this. Verified in publican-3.1.5-0.fc17.t62.noarch.
The fix for this bug has been shipped in publican 3.2.0
There seems to be a regression in publican-3.9.9-0.fc19.t28.noarch: Starting html Using XML::LibXSLT on /usr/share/publican/xsl/html.xsl undefined language: xml at /usr/share/perl5/vendor_perl/Syntax/Highlight/Engine/Kate.pm line 621. LibXSLT: error coming back from perl-dispatcher in pm file. 'xml' is not a valid language for highlighting. at /usr/lib64/perl5/vendor_perl/XML/LibXSLT.pm line 81. Changing <programlisting language="xml"> to <programlisting language="XML"> lets the book build fine
I've updated the PUG so that one of the programlistings uses "xml". substituting language XML for xml at /usr/share/perl5/vendor_perl/Syntax/Highlight/Engine/Kate.pm line 626. Works for me.
Thanks Jeff; looks like I had an out-of-date dep here.