Preventing tables from breaking across pages

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Preventing tables from breaking across pages

confuseddesi
Hi all,

I have a doc that I was to convert to DocBook. How do I prevent imported CSV tables from wrapping across pages?
Reply | Threaded
Open this post in threaded view
|

Re: Preventing tables from breaking across pages

mojavelinux
Administrator
I'm assuming you are talking about preventing tables from wrapping across pages in the PDF output.

This worked in AsciiDoc Python by specifying the "unbreakable" option on the table.

[source,asiidoc]
----

[format="csv", options="unbreakable"]
|===
include::data.csv[]
|===

----

AsciiDoc Python would then add a special hint in the form of a processing instruction inside the table in the DocBook XML:

[source,xml]
----

<informaltable frame="all" rowsep="1" colsep="1">
<?dbfo keep-together="always"?>
....

----

That would tell the PDF processor, in this case Apache FOP, to keep the table on the same page.

The unbreakable hint is not currently implemented in Asciidoctor. However, you could modify the DocBook XML to add this processing instruction where it is needed before invoking the PDF processor (I'm assuming you are using fopub, jdocbook or something similar).

-Dan

On Wed, Sep 10, 2014 at 6:19 PM, confuseddesi [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Hi all,

I have a doc that I was to convert to DocBook. How do I prevent imported CSV tables from wrapping across pages?


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Preventing-tables-from-breaking-across-pages-tp2182.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Reply | Threaded
Open this post in threaded view
|

Re: Preventing tables from breaking across pages

rockyallen
In reply to this post by confuseddesi
I use this a lot in my documents and it is not practical for me to adjust the XML manually each time. Is there a plan to fix it, or can someone point me at the code to change? I tried a pass-through, but couldn't get it to come out in the right place.
Reply | Threaded
Open this post in threaded view
|

Re: Preventing tables from breaking across pages

rockyallen
To answer my own question:

in AsciiDoctor 1.5.1, insert after line 367 of lib/asciidoctor/converter/docbook5.rb

if (node.option? 'breakable')
  result << %(<?dbfo keep-together="auto"?>)
end

Apologies if my syntax is ugly, I have never used Ruby before.
Reply | Threaded
Open this post in threaded view
|

Re: Preventing tables from breaking across pages

mojavelinux
Administrator

On Fri, Oct 10, 2014 at 4:35 PM, rockyallen [via Asciidoctor :: Discussion] <[hidden email]> wrote:
if (node.option? 'breakable')
  result << %(<?dbfo keep-together="auto"?>)
end

Apologies if my syntax is ugly, I have never used Ruby before.

The syntax looks good, except if we want to align with AsciiDoc Python, I believe we need the also support the option 'unbreakable'. See the following line from the docbook45.conf file from AsciiDoc Python.


We should add this feature for each place it's supported in AsciiDoc Python (see linked file).