Multi-line attributes and PDF generation

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

Multi-line attributes and PDF generation

joster
I'm generating a custom title page in asciidoctor-pdf by monkey-patching the layout_title_page function. One of the elements that I need to use is a multi-line attribute from the document. It looks something like this:

:response-contact: W. Witch + \
Magic Sleigh Corp AG + \
Secrit Projjects Dept. + \
Narnia, Land of + \
Project ref.: some string + \
Offer Number: ATS12345678

When I use it in the body of the document, it's fine, and renders as expected. When I use it directly in my monkey-patched layout_title_page function via doc.attr 'response-contact', however, it still has the plus signs at the end of each line:

W. Witch +
Magic Sleigh Corp AG +
Secrit Projjects Dept. +
Narnia, Land of +
Project ref.: some string +
Offer Number: ATSDDMMYYYY

I could of course just strip them out myself, but that seems hackish. I'm sure there's a better way to do this, right?
Reply | Threaded
Open this post in threaded view
|

Re: Multi-line attributes and PDF generation

mojavelinux
Administrator
You need to apply substitutions to the value. You can do that using:

doc.apply_subs doc.attr('response-contact'), [:post_replacements]

You can apply whatever substitutions you want applied.

Cheers,

-Dan

On Tue, Jun 27, 2017 at 8:28 AM joster [via Asciidoctor :: Discussion] <[hidden email]> wrote:
I'm generating a custom title page in asciidoctor-pdf by monkey-patching the layout_title_page function. One of the elements that I need to use is a multi-line attribute from the document. It looks something like this:

:response-contact: W. Witch + \
Magic Sleigh Corp AG + \
Secrit Projjects Dept. + \
Narnia, Land of + \
Project ref.: some string + \
Offer Number: ATS12345678

When I use it in the body of the document, it's fine, and renders as expected. When I use it directly in my monkey-patched layout_title_page function via doc.attr 'response-contact', however, it still has the plus signs at the end of each line:

W. Witch +
Magic Sleigh Corp AG +
Secrit Projjects Dept. +
Narnia, Land of +
Project ref.: some string +
Offer Number: ATSDDMMYYYY

I could of course just strip them out myself, but that seems hackish. I'm sure there's a better way to do this, right?


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Multi-line-attributes-and-PDF-generation-tp5703.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux