Styles/roles in PDF output

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

Styles/roles in PDF output

Marian Schedenig
Hi,

we're new to Asciidoctor (really new - we've started playing around with it a week ago after I finally convinced those in charge that a GUI text processor is the wrong tool for writing complex technical documentation).

Our primary target format is PDF, although I welcome that Asciidoctor will allow us to also produce HTML documentation. The one major feature we need, and which apparently doesn't work out of the box with PDF output, is using custom styles for individual words, instead of * and _. For example, we would like to mark a word as a variable name, and then separately define how variable names should be styled.

According to the documentation, that works via role attributes in HTML, but from what I've been able to find out, it doesn't carry over to the PDF output (and at least with asciidoctor-pdf, which we are currently, using, I've confirmed that).

After browsing this forum for a while, it seems to be that a clean solution to this would be an inline macro, e.g.:
style:myVariableName[variable]

I've managed to create a simple inline macro with Java that simply outputs the input text without special processing (or just simple string replacements), but I can't seem to find out how I could further modify the output e.g. by assigning a style to the text (bold and italic would do for starters).

Am I on the right track to begin with? Any pointers?

Thx,
Marian.
Reply | Threaded
Open this post in threaded view
|

Re: Styles/roles in PDF output

mojavelinux
Administrator
For inline roles, such as a variable name, I tend to just recommend using a role.

[.var]#variable name#

Then you can style it using CSS.

I've filed an issue to add theming support for this type of element in Asciidoctor PDF (mapping a role to style information like CSS):


> I've managed to create a simple inline macro with Java that simply outputs the input text without special processing (or just simple string replacements), but I can't seem to find out how I could further modify the output e.g. by assigning a style to the text (bold and italic would do for starters).

If you take this route, you'll want to return an inline node, which then maps to a node type. For instance, to make bold text, you'd use:

(create_inline parent, :quoted, text, type: :strong).convert

You can see other examples of inline nodes in https://github.com/asciidoctor/asciidoctor/blob/master/lib/asciidoctor/substitutors.rb (search for Inline.new)


Cheers,

-Dan

On Mon, Oct 5, 2015 at 9:40 AM, Marian Schedenig [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Hi,

we're new to Asciidoctor (really new - we've started playing around with it a week ago after I finally convinced those in charge that a GUI text processor is the wrong tool for writing complex technical documentation).

Our primary target format is PDF, although I welcome that Asciidoctor will allow us to also produce HTML documentation. The one major feature we need, and which apparently doesn't work out of the box with PDF output, is using custom styles for individual words, instead of * and _. For example, we would like to mark a word as a variable name, and then separately define how variable names should be styled.

According to the documentation, that works via role attributes in HTML, but from what I've been able to find out, it doesn't carry over to the PDF output (and at least with asciidoctor-pdf, which we are currently, using, I've confirmed that).

After browsing this forum for a while, it seems to be that a clean solution to this would be an inline macro, e.g.:
style:myVariableName[variable]

I've managed to create a simple inline macro with Java that simply outputs the input text without special processing (or just simple string replacements), but I can't seem to find out how I could further modify the output e.g. by assigning a style to the text (bold and italic would do for starters).

Am I on the right track to begin with? Any pointers?

Thx,
Marian.



If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Styles-roles-in-PDF-output-tp3812.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen
Reply | Threaded
Open this post in threaded view
|

Re: Styles/roles in PDF output

mojavelinux
Administrator
In reply to this post by Marian Schedenig

On Wed, Dec 9, 2015 at 3:42 PM, Dan Allen <[hidden email]> wrote:
you'll want to return an inline node

actually, you'll return a converted inline node (which is a string). In the future, you'll return the node itself.

You could just return an HTML string too.

-Dan


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