Login  Register

AsciiDoctor PDF - Different border thicknesses

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

AsciiDoctor PDF - Different border thicknesses

rbwhitaker
The visual appearance that I want is one in which my headers are underlined all the way across the page.

On the web, I can simply add a border in CSS to my h1 or h2 tags that has a thickness of 1 on the bottom, and 0 on the other three sides.

That doesn't seem to be possible with the current options in the YAML style file. It seems you can only set one border.

I'm not a Ruby developer, but I traced it through the code as best as I could and it seems like even Prawn doesn't really support that at the moment.

I guess I have two related questions about this. Can somebody who has more experience with AsciiDoctor PDF confirm if I'm not just missing something obvious, and/or does anybody have a workaround that might get me what I'm aiming for? (Applying a single underline for my headers that spans the page.) I've considered just putting a horizontal rule after my headings, but that feels a bit hacky.
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: AsciiDoctor PDF - Different border thicknesses

mojavelinux
Administrator

On Sat, Oct 10, 2015 at 9:26 PM, rbwhitaker [via Asciidoctor :: Discussion] <[hidden email]> wrote:
That doesn't seem to be possible with the current options in the YAML style file. It seems you can only set one border.

Currently the theme does not recognize a border setting for a section title (aka heading). This would need to be added. Prawn does support borders. But every setting in the theme file has to map back to code in Asciidoctor PDF that activates it.

Could you file an issue?

In the meantime, it is possible to override the `layout_heading` method and add a line using the Prawn API. There isn't documentation in Asciidoctor PDF on how to do this yet, but I can briefly explain it here.

1. Create a Ruby file called 'pdf_extensions.rb'
2. Add the following code to that file:

module Asciidoctor
module Pdf
class Converter
  def layout_heading string, opts = {}
    ...
  end
end
end
end

3. Load it when you call `asciidoctor-pdf` using the `-r` flag:

asciidoctor-pdf -r ./pdf_extensions.rb sample.adoc


  I've considered just putting a horizontal rule after my headings, but that feels a bit hacky.

Definitely not something I recommend.

-Dan

--
Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen