diff options
| author | Arun Isaac <arunisaac@systemreboot.net> | 2026-03-09 16:23:17 +0000 |
|---|---|---|
| committer | Arun Isaac <arunisaac@systemreboot.net> | 2026-06-21 16:15:18 +0100 |
| commit | 139558fa9e4e1b9cc6aac5f65b7a89dccc6a29c5 (patch) | |
| tree | 189eb203065a2ddbc1ebe6a0ab8cb3f7154dd40c /gnu/packages/docbook.scm | |
| parent | b30fb9e4c80aa18b7ece6d76e0021b35b7068ee2 (diff) | |
gnu: Add docbook-xsltng.
* gnu/packages/docbook.scm (docbook-xsltng): New variable.
Change-Id: Ic2a41ffa2bcc922aab03c5a38594efad35f66ac3
Diffstat (limited to 'gnu/packages/docbook.scm')
| -rw-r--r-- | gnu/packages/docbook.scm | 193 |
1 files changed, 193 insertions, 0 deletions
diff --git a/gnu/packages/docbook.scm b/gnu/packages/docbook.scm index 91e2da25998..870ac6318f8 100644 --- a/gnu/packages/docbook.scm +++ b/gnu/packages/docbook.scm | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | ;;; Copyright © 2021 Efraim Flashner <efraim@flashner.co.il> | 9 | ;;; Copyright © 2021 Efraim Flashner <efraim@flashner.co.il> |
| 10 | ;;; Copyright © 2021 Andrew Whatson <whatson@gmail.com> | 10 | ;;; Copyright © 2021 Andrew Whatson <whatson@gmail.com> |
| 11 | ;;; Copyright © 2023 Bruno Victal <mirai@makinata.eu> | 11 | ;;; Copyright © 2023 Bruno Victal <mirai@makinata.eu> |
| 12 | ;;; Copyright © 2026 Arun Isaac <arunisaac@systemreboot.net> | ||
| 12 | ;;; | 13 | ;;; |
| 13 | ;;; This file is part of GNU Guix. | 14 | ;;; This file is part of GNU Guix. |
| 14 | ;;; | 15 | ;;; |
| @@ -31,6 +32,8 @@ | |||
| 31 | #:use-module (gnu packages bash) | 32 | #:use-module (gnu packages bash) |
| 32 | #:use-module (gnu packages compression) | 33 | #:use-module (gnu packages compression) |
| 33 | #:use-module (gnu packages groff) | 34 | #:use-module (gnu packages groff) |
| 35 | #:use-module (gnu packages java) | ||
| 36 | #:use-module (gnu packages java-xml) | ||
| 34 | #:use-module (gnu packages imagemagick) | 37 | #:use-module (gnu packages imagemagick) |
| 35 | #:use-module (gnu packages inkscape) | 38 | #:use-module (gnu packages inkscape) |
| 36 | #:use-module (gnu packages tex) | 39 | #:use-module (gnu packages tex) |
| @@ -38,6 +41,7 @@ | |||
| 38 | #:use-module (gnu packages perl) | 41 | #:use-module (gnu packages perl) |
| 39 | #:use-module (gnu packages python) | 42 | #:use-module (gnu packages python) |
| 40 | #:use-module (gnu packages python-build) | 43 | #:use-module (gnu packages python-build) |
| 44 | #:use-module (gnu packages python-xyz) | ||
| 41 | #:use-module (gnu packages base) | 45 | #:use-module (gnu packages base) |
| 42 | #:use-module (gnu packages web) | 46 | #:use-module (gnu packages web) |
| 43 | #:use-module (gnu packages web-browsers) | 47 | #:use-module (gnu packages web-browsers) |
| @@ -50,6 +54,7 @@ | |||
| 50 | #:use-module (guix packages) | 54 | #:use-module (guix packages) |
| 51 | #:use-module (guix download) | 55 | #:use-module (guix download) |
| 52 | #:use-module (guix git-download) | 56 | #:use-module (guix git-download) |
| 57 | #:use-module (guix build-system ant) | ||
| 53 | #:use-module (guix build-system copy) | 58 | #:use-module (guix build-system copy) |
| 54 | #:use-module (guix build-system gnu) | 59 | #:use-module (guix build-system gnu) |
| 55 | #:use-module (guix build-system pyproject) | 60 | #:use-module (guix build-system pyproject) |
| @@ -503,6 +508,194 @@ V4.1.2 that adds support for MathML in equation markup.") | |||
| 503 | "This package provides XSL style sheets for DocBook.") | 508 | "This package provides XSL style sheets for DocBook.") |
| 504 | (license (license:x11-style "" "See 'COPYING' file."))))) | 509 | (license (license:x11-style "" "See 'COPYING' file."))))) |
| 505 | 510 | ||
| 511 | (define-public docbook-xsltng | ||
| 512 | ;; docbook-xsltng 1.4.0 is the last version that does not depend on | ||
| 513 | ;; org.xmlresolver. | ||
| 514 | (package | ||
| 515 | (name "docbook-xsltng") | ||
| 516 | ;; When updating this package, also update the gitref in the build phase. | ||
| 517 | (version "1.4.0") | ||
| 518 | (source (origin | ||
| 519 | (method git-fetch) | ||
| 520 | (uri (git-reference | ||
| 521 | (url "https://codeberg.org/DocBook/xslTNG") | ||
| 522 | ;; The Codeberg repo does not have the tag for the 1.4.0 | ||
| 523 | ;; release; only the older GitHub repo does. | ||
| 524 | (commit "f5c8bd9930d75191d029a3f01d3b58d8bb873551"))) | ||
| 525 | (file-name (git-file-name name version)) | ||
| 526 | (sha256 | ||
| 527 | (base32 | ||
| 528 | "0assl9p52lhrscyd47j1dq9r48j6d8jcl4a75350x5d20qc5f6yy")) | ||
| 529 | (snippet | ||
| 530 | #~(begin | ||
| 531 | ;; Delete bundled CSS and javascript files. | ||
| 532 | (for-each delete-file | ||
| 533 | (list "src/main/web/css/prism.css" | ||
| 534 | "src/main/web/js/prism.js")))))) | ||
| 535 | (build-system ant-build-system) | ||
| 536 | ;; Upstream uses gradle to build and run the tests. Since we don't have a | ||
| 537 | ;; gradle package yet, we translate many of the build steps to scheme. For | ||
| 538 | ;; simplicity, we skip the tests for now. | ||
| 539 | (arguments | ||
| 540 | (list | ||
| 541 | #:tests? #f | ||
| 542 | #:jar-name "docbook-xsltng.jar" | ||
| 543 | #:source-dir "src/main/java" | ||
| 544 | #:modules '((guix build ant-build-system) | ||
| 545 | (guix build utils) | ||
| 546 | (ice-9 match)) | ||
| 547 | #:phases | ||
| 548 | #~(modify-phases %standard-phases | ||
| 549 | (add-after 'unpack 'rearrange-sources | ||
| 550 | (lambda _ | ||
| 551 | ;; Unify all sources under the same directory tree. | ||
| 552 | (rename-file "buildSrc/src/main/java/org/docbook/xsltng/extensions" | ||
| 553 | "src/main/java/org/docbook/xsltng/extensions") | ||
| 554 | ;; From line 29 of buildSrc/build.gradle | ||
| 555 | (call-with-output-file "src/main/java/org/docbook/xsltng/BuildConfig.java" | ||
| 556 | (lambda (port) | ||
| 557 | (format port | ||
| 558 | "package org.docbook.xsltng; | ||
| 559 | |||
| 560 | public final class BuildConfig { | ||
| 561 | public static final String TITLE = \"DocBook xslTNG\"; | ||
| 562 | public static final String VERSION = \"~a\"; | ||
| 563 | public static final String SAXON_VERSION = \"~a\"; | ||
| 564 | private BuildConfig() {} | ||
| 565 | } | ||
| 566 | " | ||
| 567 | #$version | ||
| 568 | #$(package-version java-saxon-he-10)))) | ||
| 569 | ;; We have not packaged com.nwalsh.xslt and | ||
| 570 | ;; org.iso_relax.verifier. Hence we cannot compile these | ||
| 571 | ;; extensions; delete them for now. | ||
| 572 | (substitute* "src/main/java/org/docbook/xsltng/extensions/Register.java" | ||
| 573 | (("config\\.registerExtensionFunction\\(new XInclude\\(\\)\\);") | ||
| 574 | "") | ||
| 575 | (("config\\.registerExtensionFunction\\(new ValidateRNG\\(\\)\\);") | ||
| 576 | "")) | ||
| 577 | (for-each delete-file | ||
| 578 | (list "src/main/java/org/docbook/xsltng/extensions/ValidateRNG.java" | ||
| 579 | "src/main/java/org/docbook/xsltng/extensions/XInclude.java")))) | ||
| 580 | (add-after 'build 'build-stylesheets | ||
| 581 | (lambda* (#:key inputs #:allow-other-keys) | ||
| 582 | ;; Build XSLT stylesheets using saxon. | ||
| 583 | (let ((saxon (search-input-file inputs "share/java/saxon-he.jar"))) | ||
| 584 | (for-each (match-lambda | ||
| 585 | ((source stylesheet output params ...) | ||
| 586 | (format #t "SAXON ~a + ~a -> ~a ~a~%" | ||
| 587 | source stylesheet output params) | ||
| 588 | (apply invoke | ||
| 589 | "java" | ||
| 590 | "-classpath" saxon | ||
| 591 | "net.sf.saxon.Transform" | ||
| 592 | (string-append "-s:" source) | ||
| 593 | (string-append "-xsl:" stylesheet) | ||
| 594 | (string-append "-o:" output) | ||
| 595 | params))) | ||
| 596 | `(("src/main/xslt/param.xsl" | ||
| 597 | "tools/parameter-maps.xsl" | ||
| 598 | "src/main/xslt/parameter-maps.xsl") | ||
| 599 | ("tools/version.xsl" | ||
| 600 | "tools/version.xsl" | ||
| 601 | "src/main/xslt/VERSION.xsl" | ||
| 602 | ,(string-append "version=" #$version) | ||
| 603 | ;; When updating this package, update this gitref | ||
| 604 | ;; to the commit corresponding to the release. | ||
| 605 | "gitref=f5c8bd993") | ||
| 606 | ,@(map (lambda (xml) | ||
| 607 | (list xml | ||
| 608 | "tools/xform-locale.xsl" | ||
| 609 | (string-append "src/main/xslt/locale/" | ||
| 610 | (basename xml)))) | ||
| 611 | (find-files "src/main/locales/locale" | ||
| 612 | "\\.xml$"))))) | ||
| 613 | ;; Substitute in TITLE and VERSION. | ||
| 614 | (substitute* (append (find-files "src/main/web/css" "\\.css$") | ||
| 615 | (find-files "src/main/web/js" "\\.js$")) | ||
| 616 | (("@@TITLE@@") "DocBook xslTNG") | ||
| 617 | (("@@VERSION@@") #$version)) | ||
| 618 | ;; ;; Generate pygments CSS file. | ||
| 619 | (invoke "python3" "tools/generate-pygments.py" | ||
| 620 | "--version" #$version | ||
| 621 | "--title" "DocBook xslTNG" | ||
| 622 | "--output" "src/main/web/css/pygments.css"))) | ||
| 623 | (add-after 'install 'install-bin | ||
| 624 | (lambda* (#:key inputs outputs #:allow-other-keys) | ||
| 625 | ;; Install XSLT stylesheets. | ||
| 626 | (copy-recursively "src/main/xslt" | ||
| 627 | (string-append #$output | ||
| 628 | "/xml/xsl/docbook-xsltng-" | ||
| 629 | #$version)) | ||
| 630 | ;; Install CSS and javascript files. | ||
| 631 | (copy-recursively "src/main/web" | ||
| 632 | (string-append #$output "/share/web")) | ||
| 633 | ;; Configure paths in docbook script. | ||
| 634 | (let ((bin (string-append #$output "/bin"))) | ||
| 635 | (mkdir-p bin) | ||
| 636 | (substitute* "src/bin/docbook.py" | ||
| 637 | ;; Path to java | ||
| 638 | (("self._java = None") | ||
| 639 | (string-append "self._java = \"" | ||
| 640 | (search-input-file inputs "bin/java") | ||
| 641 | "\"")) | ||
| 642 | ;; Path to docbook.xsl | ||
| 643 | (("\\{self\\.root\\}/xslt/docbook.xsl") | ||
| 644 | (search-input-file outputs | ||
| 645 | (string-append "xml/xsl/docbook-xsltng-" | ||
| 646 | #$version | ||
| 647 | "/docbook.xsl"))) | ||
| 648 | ;; Path to web resources | ||
| 649 | (("\\{self\\.root\\}/resources") | ||
| 650 | (search-input-directory outputs "share/web")) | ||
| 651 | ;; Disable computing classpath. | ||
| 652 | (("docbook\\.compute_dependencies\\(\\)") "") | ||
| 653 | ;; Set classpath explicitly. | ||
| 654 | (("cp = self\\.classpath\\(\\)") | ||
| 655 | (let ((docbook-xsltng | ||
| 656 | (search-input-file outputs | ||
| 657 | "share/java/docbook-xsltng.jar")) | ||
| 658 | (metadata-extractor | ||
| 659 | (search-input-file inputs | ||
| 660 | "share/java/metadata-extractor.jar")) | ||
| 661 | (saxon | ||
| 662 | (search-input-file inputs | ||
| 663 | "share/java/saxon-he.jar"))) | ||
| 664 | (string-append "cp = \"" | ||
| 665 | (list->search-path-as-string | ||
| 666 | (list docbook-xsltng | ||
| 667 | metadata-extractor | ||
| 668 | saxon) | ||
| 669 | ":") | ||
| 670 | "\""))) | ||
| 671 | ;; Disable references to org.xmlresolver dependencies that | ||
| 672 | ;; have not been packaged yet. | ||
| 673 | (("\"-x:org.xmlresolver.tools.ResolvingXMLReader\",") "") | ||
| 674 | (("\"-y:org.xmlresolver.tools.ResolvingXMLReader\",") "") | ||
| 675 | (("\"-r:org.xmlresolver.Resolver\",") "")) | ||
| 676 | ;; Install docbook script. | ||
| 677 | (copy-file "src/bin/docbook.py" | ||
| 678 | (string-append bin "/docbook")) | ||
| 679 | ;; Wrap docbook script in python environment. | ||
| 680 | (wrap-program (string-append bin "/docbook") | ||
| 681 | `("GUIX_PYTHONPATH" ":" prefix | ||
| 682 | (,(getenv "GUIX_PYTHONPATH")))))))))) | ||
| 683 | (inputs | ||
| 684 | (list bash-minimal | ||
| 685 | java-metadata-extractor | ||
| 686 | java-saxon-he-10 | ||
| 687 | python | ||
| 688 | python-click | ||
| 689 | python-pygments)) | ||
| 690 | (home-page "https://xsltng.docbook.org/") | ||
| 691 | (synopsis "XSLT 3.0 stylesheets for DocBook") | ||
| 692 | (description "This package provides XSLT 3.0 stylesheets for DocBook. | ||
| 693 | They transform DocBook XML documents into clean, semantically rich HTML5. CSS | ||
| 694 | stylesheet and javascript suitable for online presentation is included. | ||
| 695 | Producing high quality print output with a paged media capable CSS processor | ||
| 696 | is also supported.") | ||
| 697 | (license license:expat))) | ||
| 698 | |||
| 506 | (define-public docbook-dsssl | 699 | (define-public docbook-dsssl |
| 507 | (package | 700 | (package |
| 508 | (name "docbook-dsssl") | 701 | (name "docbook-dsssl") |
