OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Re: [docbook-apps] aligning code to the right


This is actually difficult to do inside a programlisting. The problem is that a programlisting is handled as a single string containing white space and line breaks that are preserved by the formatter.  But neither XSL-FO or CSS provide a way to change the alignment of an inline string, even when it is bounded by line feeds on both sides. 
 
To effect a change of alignment, the long string would need to be broken and "text to the right" would need to be placed inside an fo:block (or div for HTML) so that the text-align="right" formatting property could be applied.  But when you put that text in its own fo:block, that breaks the line before and after.  Those line breaks add to the line breaks already existing in the text string, so you get a blank line before and after from the double line breaks.
 
The only solution I can see is to remove the line breaks in the source file programlisting before and after such text, and wrap the text in <phrase role="right-align"> like this:
 
<programlisting>First line<phrase role="right-align">text to the right</phrase>Third line
And more lines.
</programlisting>
 
and add this template to your customization layer:
 
<xsl:template match="phrase[@role='right-align']">
  <fo:block text-align="end">
    <xsl:apply-templates/>
  </fo:block>
</xsl:template>
 
And something similar using <div> for HTML output.  This should result in:
 
-------------------------------------------------------------------
First line
                                                  text to the right
Third line
And more lines
--------------------------------------------------------------------
 
Removing the line breaks in the programlisting makes it difficult to read, but it does work.
 
Bob Stayton
Sagehill Enterprises
bobs@sagehill.net
 
 
----- Original Message -----
From: "Lorenzo Caminiti" <lorcaminiti@gmail.com>
To: <docbook-apps@lists.oasis-open.org>
Sent: Tuesday, May 08, 2012 5:34 AM
Subject: [docbook-apps] aligning code to the right

> Hello all,
>
> How can I align code to the right?
>
> +-------------------------------------------+
> test to the left
>                        text to the right
> text to the left again
>
> Ideally, I'd do this not within a table but in normal text I'd start a
> few lines that are aligned to the right and then go back to left
> alignment.
>
> Thanks a lot.
> --Lorenzo
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
docbook-apps-unsubscribe@lists.oasis-open.org
> For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org
>
>
>


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]