Re: [docbook-apps] How to remove extra newline in programlisting

2010-11-08 Thread Jason Gilmore
Hi,

Wow Bob thank you so much for working this out. I've just integrated
your customization into my style sheet, and it works like a charm!
I've tested the customization in conjunction with a variety of
 formatting variants, and they all work great, the
most important of which being this:





With the customization in place, the previously preceding and
following newlines have disappeared! Personally, I find this a really
big deal, because I prefer to maintain shorter code listings (such as
the one found above) within the document rather than reference them
externally. The ability to format these short code listings as above
is convenient because should the need arise to cut/paste modified code
into the listing, I can do so without worrying about mistakenly
deleting part of the CDATA enclosure.

Thanks again!
Jason

On Tue, Nov 2, 2010 at 3:38 PM, Bob Stayton  wrote:
> Hi Jason,
> This request has come up before, so maybe it is time for a real solution.
>
> I discovered that the DocBook XSL stylesheets have three named utility
> templates for trimming leading and trailing newlines.  They are named
> 'trim-left', 'trim-right', and 'trim.text', and they reside in the
> lib/lib.xsl stylesheet module.  But it seems they are not currently used in
> any templates that match content.
>
> I worked up this customization using them, but I have not had much of a
> chance to test them.  If you or anyone else wouldn't mind testing them with
> a variety of programlistings and giving me feedback about them, I would
> appreciate it.  I left in xsl:message elements to indicate when each
> template is being used, which is useful during testing.  They would be
> removed or commented out in production.
>
> There are three templates because programlisting allows element content as
> well as text content.  So the three templates apply when the first node is a
> text node (uses trim-left), the last node is a text node (uses trim-right),
> and when the programlisting contains a single node that is a text node (uses
> trim.text), respectively.
>
>
> 
>  match="programlisting/node()[1][self::text()][following-sibling::node()]">
>  got here left
>  
>   
>  
> 
>
> 
> 
>  got here right
>  
>   
>  
> 
>
> 
>              priority="1">
>  got here both
>  
>   
>  
> 
>
> If these are successful at deleting only leading and trailing newlines in
> programlisting, they could be incorporated into the next release of the
> stylesheets, probably with a parameter to turn them on or off (default would
> be off for backwards compatibility).
>
> Bob Stayton
> Sagehill Enterprises
> b...@sagehill.net
>
>
> - Original Message - From: "Jason Gilmore" 
> To: 
> Sent: Wednesday, October 13, 2010 6:35 AM
> Subject: [docbook-apps] How to remove extra newline in programlisting
>
>
>> Hi,
>>
>> Thanks to the great documentation and this mailing list's archive I've
>> managed to complete a pretty straightforward transition from MS Word
>> to Docbook. So far everything is working brilliantly.
>>
>> I am however running into a strange issue involving 
>> elements in which the enclosed text is delimited by .
>> When I convert from Docbook to PDF using oXygen (using the Saxon 6.5
>> transformer), my program listing's include two extra newlines at the
>> top and one at the bottom when the 's look like this:
>>
>> 
>> 
>> 
>>
>> A newline only appears at the top of the rendered listing when the
>> format looks like this:
>>
>> 
>>
>> The only way I can remove the superfluous newlines at both the top and
>> bottom is to format my program listings like this:
>>
>> 
>>
>> As you can imagine, this is not ideal and opens up the possibility for
>> inadvertent editing errors.
>>
>> Surely there is some way to fix this problem perhaps at the XSL
>> transformation stage?
>>
>> Thank you!
>> Jason
>>
>> -
>> To unsubscribe, e-mail: docbook-apps-unsubscr...@lists.oasis-open.org
>> For additional commands, e-mail: docbook-apps-h...@lists.oasis-open.org
>>
>>
>>
>
>

-
To unsubscribe, e-mail: docbook-apps-unsubscr...@lists.oasis-open.org
For additional commands, e-mail: docbook-apps-h...@lists.oasis-open.org



Re: [docbook-apps] How to remove extra newline in programlisting

2010-11-02 Thread Bob Stayton

Hi Jason,
This request has come up before, so maybe it is time for a real solution.

I discovered that the DocBook XSL stylesheets have three named utility templates for 
trimming leading and trailing newlines.  They are named 'trim-left', 'trim-right', and 
'trim.text', and they reside in the lib/lib.xsl stylesheet module.  But it seems they 
are not currently used in any templates that match content.


I worked up this customization using them, but I have not had much of a chance to test 
them.  If you or anyone else wouldn't mind testing them with a variety of 
programlistings and giving me feedback about them, I would appreciate it.  I left in 
xsl:message elements to indicate when each template is being used, which is useful 
during testing.  They would be removed or commented out in production.


There are three templates because programlisting allows element content as well as 
text content.  So the three templates apply when the first node is a text node (uses 
trim-left), the last node is a text node (uses trim-right), and when the 
programlisting contains a single node that is a text node (uses trim.text), 
respectively.




match="programlisting/node()[1][self::text()][following-sibling::node()]">

 got here left
 
   
 





 got here right
 
   
 




 priority="1">
 got here both
 
   
 


If these are successful at deleting only leading and trailing newlines in 
programlisting, they could be incorporated into the next release of the stylesheets, 
probably with a parameter to turn them on or off (default would be off for backwards 
compatibility).


Bob Stayton
Sagehill Enterprises
b...@sagehill.net


- Original Message - 
From: "Jason Gilmore" 

To: 
Sent: Wednesday, October 13, 2010 6:35 AM
Subject: [docbook-apps] How to remove extra newline in programlisting



Hi,

Thanks to the great documentation and this mailing list's archive I've
managed to complete a pretty straightforward transition from MS Word
to Docbook. So far everything is working brilliantly.

I am however running into a strange issue involving 
elements in which the enclosed text is delimited by .
When I convert from Docbook to PDF using oXygen (using the Saxon 6.5
transformer), my program listing's include two extra newlines at the
top and one at the bottom when the 's look like this:





A newline only appears at the top of the rendered listing when the
format looks like this:



The only way I can remove the superfluous newlines at both the top and
bottom is to format my program listings like this:



As you can imagine, this is not ideal and opens up the possibility for
inadvertent editing errors.

Surely there is some way to fix this problem perhaps at the XSL
transformation stage?

Thank you!
Jason

-
To unsubscribe, e-mail: docbook-apps-unsubscr...@lists.oasis-open.org
For additional commands, e-mail: docbook-apps-h...@lists.oasis-open.org






-
To unsubscribe, e-mail: docbook-apps-unsubscr...@lists.oasis-open.org
For additional commands, e-mail: docbook-apps-h...@lists.oasis-open.org



Re: [docbook-apps] How to remove extra newline in programlisting

2010-10-13 Thread John W. Shipman

On Wed, 13 Oct 2010, Jason Gilmore wrote:

+--
| I am however running into a strange issue involving 
| elements in which the enclosed text is delimited by .
| When I convert from Docbook to PDF using oXygen (using the Saxon 6.5
| transformer), my program listing's include two extra newlines at the
| top and one at the bottom when the 's look like this:
+--

Here's how I format code snippets (with a little context to show the
indentation):


  This code destroys Western Snivelization:


 10 PRINT "BASIC IS OLDER THAN DIRT"

  20 GOTO 10
  30 END


  And now...


We're especially sensitive to how  works because we
use this element for literate programming: the code snippets are
the ones that get executed.  Remarks on the above example:

 a. Whitespace, including newlines, is always allowed before the
closing '>' of a tag.

 b. We use the 'role' attribute, which is reserved for application
use, to mark the source file to which each fragment is written.
The lines written to file "hardloop.bas" look like this:


  10 PRINT "BASIC IS OLDER THAN DIRT"
  20 GOTO 10
  30 END


 c. Note that the first code line is misaligned relative to the
following line because of the '>'.  This is annoying only while
you're editing the source; it looks correct in HTML and PDF
output.

With CDATA it'd look like this:





Here's a boatload of literate programming examples and some pointers
to the why and how in our local practice:

http://www.nmt.edu/~shipman/soft/litprog/

Happy happy joy joy,
John Shipman (j...@nmt.edu), Applications Specialist, NM Tech Computer Center,
Speare 119, Socorro, NM 87801, (575) 835-5735, http://www.nmt.edu/~john
  ``Let's go outside and commiserate with nature.''  --Dave Farber

-
To unsubscribe, e-mail: docbook-apps-unsubscr...@lists.oasis-open.org
For additional commands, e-mail: docbook-apps-h...@lists.oasis-open.org



[docbook-apps] How to remove extra newline in programlisting

2010-10-13 Thread Jason Gilmore
Hi,

Thanks to the great documentation and this mailing list's archive I've
managed to complete a pretty straightforward transition from MS Word
to Docbook. So far everything is working brilliantly.

I am however running into a strange issue involving 
elements in which the enclosed text is delimited by .
When I convert from Docbook to PDF using oXygen (using the Saxon 6.5
transformer), my program listing's include two extra newlines at the
top and one at the bottom when the 's look like this:





A newline only appears at the top of the rendered listing when the
format looks like this:



The only way I can remove the superfluous newlines at both the top and
bottom is to format my program listings like this:



As you can imagine, this is not ideal and opens up the possibility for
inadvertent editing errors.

Surely there is some way to fix this problem perhaps at the XSL
transformation stage?

Thank you!
Jason

-
To unsubscribe, e-mail: docbook-apps-unsubscr...@lists.oasis-open.org
For additional commands, e-mail: docbook-apps-h...@lists.oasis-open.org