-
Notifications
You must be signed in to change notification settings - Fork 501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for AsciiDoc cell content #6
Comments
I tried hacking support for this into converter.rb, and can now generate the PDF code for the styled cells, but I can't seem to find a way to insert raw PDF code into Prawn table cells. Any ideas? Inserted into def convert_table(node):
But maybe this is totally the wrong approach. I would really love to have fully supported cells (be able to embed images, code block, lists, etc) |
I'll have a look asap. Thanks for giving this a go! I'll work with you to get it merge ready. |
Dan, I've been super happy with asciidoctor and asciidoctor-pdf -- thanks for creating such great tools. The code here might be totally the wrong approach. I hope it is useful but I kind of doubt it. Let me know how I can help.
|
I looks like we're pretty limited by what we can put into a cell in Prawn. We're going to have to focus on a subset of content that we can offer and make that as good as we can. We can put an image in a cell, but only one. We won't be able to do arbitrary block content. We could probably fake lists. Given that images and lists are the two most likely things you put into cells...maybe source code as well. I'm going to start by focusing on the use case of a single block image. There's actually an API for that :) |
It does look like it's possible to define our own type of Cell and respond to the See the code for Cell::Image to get the idea: https://github.com/prawnpdf/prawn-table/blob/master/lib/prawn/table/cell/image.rb#L62-L64 |
- support a limited subset of AsciiDoc table cell content (single block only) - support a single image, paragraph, literal, listing, verse or quote in table cell - show raw source for AsciiDoc table cell of other types - add support for a literal table cell - add support for a verse table cell
I've added initial support for AsciiDoc table cell content. See #120 The most important and complete support is for a table cell with a single block image. There's also good support for a table cell with a single paragraph. I've hacked in a few additional options, including basic (but incomplete) support for literal, listing, quote and verse. cc: @paulrayner |
I'll leave this issue open a bit longer, though eventually I foresee creating more fine-grained issues so we can tackle each challenge one at a time. |
👍 |
- support a limited subset of AsciiDoc table cell content (single block only) - support a single image, paragraph, literal, listing, verse or quote in table cell - show raw source for AsciiDoc table cell of other types - add support for a literal table cell - add support for a verse table cell
I took this a lot further. What's there now should be sufficient to cover most, if not all, basic use cases. The layouts inside AsciiDoc table cells is a bit lacking, but the content is mostly there and styled somewhat sensibly. In order to do this right, we need to subclass Table::Cell and tie directly into the pdf object. However, the work done in this pull request makes the requirements a bit more clear and hopefully paves the way for that refactoring. |
By basic, I mean things like stacking images in a table cell, a table cell with multiple paragraphs, a paragraph and a few list items, etc. It's not fancy, but it's something. |
I am looking for real world use cases of AsciiDoc table cell content that aren't met sufficiently by this change (or just in general). Keep in mind that a cell must be marked as AsciiDoc content when it contains block-level AsciiDoc. The "a" essentially switches the cell from being of type paragraph (i.e., inline text) to an arbitrary number of blocks. |
I'll do some experiments next week and let you know. This is exciting! Paul On Fri, May 15, 2015 at 8:44 PM, Dan Allen [email protected]
|
The Groovy language guide has some pretty good examples of AsciiDoc table cells. Mostly it's a source listing in a cell. That's a case we should try to cover as well as possible (it won't be perfect, but we can make it readable at least). |
I was playing with asciidcotor-pdf and have cooked up an example which doesn't quite render properly in PDF which may prove useful: https://gist.github.com/msavy/7500fe0bdf08a6297888 Renders cleanly through the usual asciidoctor -> HTML pipeline Not quite right in PDF (i.e. newline missing after initial para) Using latest HEAD
Hope that's helpful! |
Thanks @msavy! That's exactly the type of example I was looking for. I'm happy to say that the pending pull request for this issue will handle this case. I think for the first iteration, I'm going to keep it simple. It will likely support the following blocks:
The rest of the block types will be emitted raw, almost so it looks like the AsciiDoc source. The next step will be to implement the Cell interface so that we can render the remainder of the block types in the normal way. |
Displaying Asciidoc content in table cells seems to work when creating the PDF using https://github.com/asciidocfx/AsciidocFX . What have they done to solve the problem? My Test-document:
The output of asciidoctor (using gradle): The output of asciidocFX: |
AsciiDocFX is not yet using Asciidoctor PDF. Instead, it uses the DocBook toolchain. It's essentially using fopub under the covers, which executes and manages the DocBook toolchain. |
See also this question on StackOverflow: Multiple paragraphs in AsciiDoctor table cell |
… tables) - use custom Cell implementation to support AsciiDoc table cells - works best if column is assigned an explicit (relative) width - does not permit content that exceeds the height of one page - extra padding from last block is added to bottom of cell
… tables) - use custom Cell implementation to support AsciiDoc table cells - works best if column is assigned an explicit (relative) width - does not permit content that exceeds the height of one page - extra padding from last block is added to bottom of cell
… tables) - use custom Cell implementation to support AsciiDoc table cells - works best if column is assigned an explicit (relative) width - does not permit content that exceeds the height of one page - extra padding from last block is added to bottom of cell
I was able to figure how to write a custom Cell implementation. However, it appears that we have a few limitations, some of which are coming from Prawn Table.
|
… tables) - use custom Cell implementation to support AsciiDoc table cells - supports colspan, rowspan and vertical alignment - works best if column is assigned an explicit (relative) width - does not permit content that exceeds the height of one page - extra padding from last block is added to bottom of cell - does not (yet) inherit font properties from table cell
…g nested tables) - use custom Cell implementation to support AsciiDoc table cells - supports colspan, rowspan and vertical alignment - works best if column is assigned an explicit (relative) width - does not permit content that exceeds the height of one page - extra padding from last block is added to bottom of cell - does not (yet) inherit font properties from table cell
…g nested tables) - use custom Cell implementation to support AsciiDoc table cells - supports colspan, rowspan and vertical alignment - works best if column is assigned an explicit (relative) width - does not permit content that exceeds the height of one page - extra padding from last block is added to bottom of cell - does not (yet) inherit font properties from table cell
…g nested tables) - use custom Cell implementation to support AsciiDoc table cells - supports colspan, rowspan and vertical alignment - works best if column is assigned an explicit (relative) width - does not permit content that exceeds the height of one page - extra padding from last block is added to bottom of cell - does not (yet) inherit font properties from table cell
…g nested tables) - use custom Cell implementation to support AsciiDoc table cells - supports colspan, rowspan and vertical alignment - works best if column is assigned an explicit (relative) width - does not permit content that exceeds the height of one page - extra padding from last block is added to bottom of cell - does not (yet) inherit font properties from table cell
Hi @mojavelinux is this fix to make table cells parse as asciidoc content has released? I can see the release version has changed to 1.5.0 beta.1 |
This will be fixed in alpha.14, which is the next release. The release is ready to go out, I just need to do it. |
Awesome, looking forward to that. |
Add support for AsciiDoc cell content. Currently, the raw AsciiDoc source is passed through to the PDF file.
The text was updated successfully, but these errors were encountered: