Inline role attribute for docbook backend

85 views
Skip to first unread message

Joel Smith

unread,
Oct 14, 2009, 1:09:06 AM10/14/09
to asci...@googlegroups.com
Hi,
I'm glad to see that AsciiDoc already supports the role attribute for
docbook, but it seems to be block-level only. It would be great to be
able to set the role attribute on quoted items, inline. For example:

[role="normal"]
This is a normal paragraph with some [role="abnormal"]#abnormal text#
contained within.

Currently, I can set the role="normal" at the block level, but not the
[role="abnormal"] inline. This feature would be really helpful since
having a role set on elements in docbook allows me to trigger formatting
with my style sheets or customization layers for elements that have it set.

I have changed the [tags] section of my docbook.conf file to support
inline role attributes for quoted items.

[tags]
# Quoted text
emphasis={role?<phrase role="{role}">}<emphasis>|</emphasis>{role?</phrase>}
strong={role?<phrase role="{role}">}<emphasis
role="strong">|</emphasis>{role?</phrase>}
monospaced=<literal{role? role="{role}"}>|</literal>
singlequoted={role?<phrase
role="{role}">}{amp}#8216;|{amp}#8217;{role?</phrase>}
doublequoted={role?<phrase
role="{role}">}{amp}#8220;|{amp}#8221;{role?</phrase>}
unquoted={role?<phrase role="{role}">}|{role?</phrase>}
subscript=<subscript{role? role="{role}"}>|</subscript>
superscript=<superscript{role? role="{role}"}>|</superscript>

This seems to work great, and it would be wonderful if this
functionality could be added to AsciiDoc proper. As you can see, for
some of them I've added a phrase element for the role to be set upon,
and for others, I've set the role on an existing element. Since some
didn't have an element, it makes sense to add a phrase, but for the
others, I'm not sure. Thoughts?

Cheers,
Joel

Stuart Rackham

unread,
Oct 14, 2009, 11:49:44 PM10/14/09
to asci...@googlegroups.com
Looks like a reasonable idea to me. It could be made to work with HTML using the
span element (<span class="{role}">...</span>) to trigger CSS. I'll put it in
the TODO list. Meanwhile if anyone else has any thoughts on the subject please
speak up.

Cheers, Stuart


>
> Cheers,
> Joel
>
> >
>

Stuart Rackham

unread,
Oct 18, 2009, 5:04:59 PM10/18/09
to asci...@googlegroups.com
Hi Joel

I've just got one question: should the <phrase> element be interior or exterior?
i.e should it just include the quoted text or the quoted text plus markup e.g.

<phrase role="some-role">&#8220;a phrase&#8221;</phrase>
<phrase role="some-role"><emphasis>a phrase</emphasis></phrase>

or:

&#8220;<phrase role="some-role">a phrase</phrase>&#8221;
<emphasis><phrase role="some-role">a phrase</phrase></emphasis>

You have enveloped the text and the markup in the phrase element and I'm
wondering if there is a reason.


Cheers, Stuart

Joel Smith

unread,
Oct 20, 2009, 3:35:11 PM10/20/09
to asciidoc
Hi Stuart,
Thanks for looking at this.

On Oct 18, 3:04 pm, Stuart Rackham <srack...@gmail.com> wrote:
> I've just got one question: should the <phrase> element be interior or exterior?
> i.e should it just include the quoted text or the quoted text plus markup e.g.
>
> <phrase role="some-role">&#8220;a phrase&#8221;</phrase>
> <phrase role="some-role"><emphasis>a phrase</emphasis></phrase>
>
> or:
>
> &#8220;<phrase role="some-role">a phrase</phrase>&#8221;
> <emphasis><phrase role="some-role">a phrase</phrase></emphasis>
>
> You have enveloped the text and the markup in the phrase element and I'm
> wondering if there is a reason.

I'm a docbook novice, so I can't say that I know which way would be
more appropriate. In the case of the single and double quoted
strings, it seems to me like the phrase element should be exterior so
that I can have the formatting for a role apply to the quote marks
themselves too. If you (or others) view this as incorrect, I don't
really mind either way. I'm mostly interested in the "unquoted" use
case of [role="foo"]#some text#. I only added the others for
symmetry, and it seemed to fit.
Thanks,
Joel

Stuart Rackham

unread,
Oct 24, 2009, 9:03:56 PM10/24/09
to asci...@googlegroups.com
Hi Joel

I kept to your exterior scheme, for consistency I wrapped all outputs in the
DocBook phrase element and I extended the role attribute to xhtml11 and html4
backends (generates a <span class="rolename">...</span>) so in theory you could
style DocBook and HTML outputs from the same AsciiDoc source.

http://hg.sharesource.org/asciidoc/rev/d06ad55e519a

Thanks for your suggestion and the patch.


Cheers, Stuart


> Thanks,
> Joel
> >
>

Joel Smith

unread,
Oct 29, 2009, 5:51:04 PM10/29/09
to asciidoc
On Oct 24, 7:03 pm, Stuart Rackham <srack...@gmail.com> wrote:
> I kept to your exterior scheme, for consistency I wrapped all outputs in the
> DocBook phrase element and I extended the role attribute to xhtml11 and html4
> backends (generates a <span class="rolename">...</span>) so in theory you could
> style DocBook and HTML outputs from the same AsciiDoc source.
>
> http://hg.sharesource.org/asciidoc/rev/d06ad55e519a

Looks great! I like that you mirrored the functionality for HTML.
Thanks for the feature addition.

Cheers,
Joel
Reply all
Reply to author
Forward
0 new messages