From bb94e72db840558bc6419973a8222593eca82d98 Mon Sep 17 00:00:00 2001 From: Norman Walsh Date: Wed, 27 Aug 2003 14:29:55 +0000 Subject: [PATCH] Support startinglinenumber and continuation on verbatim environments --- .../saxon643/.classes/Makefile.common | 2 +- .../com/nwalsh/saxon/NumberLinesEmitter.java | 8 +- .../saxon643/com/nwalsh/saxon/Verbatim.java | 15 +++ xsl/fo/verbatim.xsl | 102 ++++++++++++++++++ xsl/html/verbatim.xsl | 99 ++++++++++++++++- 5 files changed, 223 insertions(+), 3 deletions(-) diff --git a/xsl/extensions/saxon643/.classes/Makefile.common b/xsl/extensions/saxon643/.classes/Makefile.common index d55d94def..50ee5306d 100644 --- a/xsl/extensions/saxon643/.classes/Makefile.common +++ b/xsl/extensions/saxon643/.classes/Makefile.common @@ -1,4 +1,4 @@ -CLASSPATH=$(CLASSBASE):/usr/local/java/saxon-6.4.4/saxon.jar +CLASSPATH=$(CLASSBASE):/usr/local/java/saxon-6.5.2/saxon.jar all: $(CLASSFILES) -@for f in $(SUBDIRS); do \ diff --git a/xsl/extensions/saxon643/com/nwalsh/saxon/NumberLinesEmitter.java b/xsl/extensions/saxon643/com/nwalsh/saxon/NumberLinesEmitter.java index 9d7466c54..ab471e045 100644 --- a/xsl/extensions/saxon643/com/nwalsh/saxon/NumberLinesEmitter.java +++ b/xsl/extensions/saxon643/com/nwalsh/saxon/NumberLinesEmitter.java @@ -63,6 +63,9 @@ public class NumberLinesEmitter extends CopyEmitter { /** The XHTML namespace name. */ protected static String xhURI = "http://www.w3.org/1999/xhtml"; + /** The first line number will be startinglinenumber. */ + protected int startinglinenumber = 1; + /** Every modulus line will be numbered. */ protected int modulus = 5; @@ -85,6 +88,7 @@ public class NumberLinesEmitter extends CopyEmitter { */ public NumberLinesEmitter(Controller controller, NamePool namePool, + int startingLineNumber, int modulus, int width, String separator, @@ -94,6 +98,7 @@ public class NumberLinesEmitter extends CopyEmitter { firstElement = true; this.modulus = modulus; + this.startinglinenumber = startingLineNumber; this.width = width; this.separator = separator; this.foStylesheet = foStylesheet; @@ -108,7 +113,8 @@ public class NumberLinesEmitter extends CopyEmitter { if (lineNumber == 0) { // The first line is always numbered - formatLineNumber(++lineNumber); + lineNumber = startinglinenumber; + formatLineNumber(lineNumber); } // Walk through the text node looking for newlines diff --git a/xsl/extensions/saxon643/com/nwalsh/saxon/Verbatim.java b/xsl/extensions/saxon643/com/nwalsh/saxon/Verbatim.java index 1ba7532d6..9e1febfbc 100644 --- a/xsl/extensions/saxon643/com/nwalsh/saxon/Verbatim.java +++ b/xsl/extensions/saxon643/com/nwalsh/saxon/Verbatim.java @@ -63,6 +63,8 @@ public class Verbatim { private static int modulus = 0; /** The width (in characters) of line numbers (for padding). */ private static int width = 0; + /** The starting line number. */ + private static int startinglinenumber = 1; /** The separator between the line number and the verbatim text. */ private static String separator = ""; @@ -140,6 +142,9 @@ public class Verbatim { *
linenumbering.separator
*
Specifies the string that separates line numbers from lines * in the program listing. (builtin default: " ").
+ *
linenumbering.startinglinenumber
+ *
Specifies the initial line number + * in the program listing. (builtin default: "1").
*
stylesheet.result.type
*
Specifies the stylesheet result type. The value is either 'fo' * (for XSL Formatting Objects) or it isn't. (builtin default: html).
@@ -152,6 +157,7 @@ public class Verbatim { // Hardcoded defaults modulus = 5; width = 3; + startinglinenumber = 1; separator = " "; foStylesheet = false; @@ -173,6 +179,14 @@ public class Verbatim { System.out.println("$linenumbering.width is not a number: " + varString); } + // Get the startinglinenumber + varString = getVariable(context, "linenumbering.startinglinenumber"); + try { + startinglinenumber = Integer.parseInt(varString); + } catch (NumberFormatException nfe) { + System.out.println("$linenumbering.startinglinenumber is not a number: " + varString); + } + // Get the separator varString = getVariable(context, "linenumbering.separator"); separator = varString; @@ -245,6 +259,7 @@ public class Verbatim { NamePool namePool = controller.getNamePool(); NumberLinesEmitter nlEmitter = new NumberLinesEmitter(controller, namePool, + startinglinenumber, listingModulus, listingWidth, separator, diff --git a/xsl/fo/verbatim.xsl b/xsl/fo/verbatim.xsl index 068255fc5..7ced1e45a 100644 --- a/xsl/fo/verbatim.xsl +++ b/xsl/fo/verbatim.xsl @@ -232,6 +232,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Unexpected verbatim environment: + + + + + + + + + + 1 + + + @@ -247,4 +301,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsl/html/verbatim.xsl b/xsl/html/verbatim.xsl index 02282d152..8ac794acb 100644 --- a/xsl/html/verbatim.xsl +++ b/xsl/html/verbatim.xsl @@ -243,6 +243,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Unexpected verbatim environment: + + + + + + + + + + 1 + + + @@ -277,9 +331,52 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.40.0