Bug 919474
| Summary: | RFE: Ability to use case-insensitive "language" attributes on programlistings for compatibility with other docbook projects. | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Community] Publican | Reporter: | Stephen Gordon <sgordon> | ||||
| Component: | publican | Assignee: | Jeff Fearn 🐞 <jfearn> | ||||
| Status: | CLOSED CURRENTRELEASE | QA Contact: | tools-bugs <tools-bugs> | ||||
| Severity: | unspecified | Docs Contact: | |||||
| Priority: | unspecified | ||||||
| Version: | 3.1 | CC: | aigao, pbokoc, rlandman, xma | ||||
| Target Milestone: | 3.2 | Keywords: | FutureFeature, Regression, Reopened | ||||
| Target Release: | --- | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Unspecified | ||||||
| Whiteboard: | |||||||
| Fixed In Version: | 3.2.0 | Doc Type: | Enhancement | ||||
| Doc Text: | Story Points: | --- | |||||
| Clone Of: | Environment: | ||||||
| Last Closed: | 2013-11-29 00:35:04 UTC | Type: | Bug | ||||
| Regression: | --- | Mount Type: | --- | ||||
| Documentation: | --- | CRM: | |||||
| Verified Versions: | Category: | --- | |||||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
| Cloudforms Team: | --- | Target Upstream Version: | |||||
| Embargoed: | |||||||
| Bug Depends On: | |||||||
| Bug Blocks: | 913281 | ||||||
| Attachments: |
|
||||||
|
Description
Stephen Gordon
2013-03-08 15:29:52 UTC
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. |