[docbook-css] better biblioentry styling

David Holroyd dave at badgers-in-foil.co.uk
Wed, 2 Feb 2005 02:40:29 +0000


Hi there,

On Tue, Feb 01, 2005 at 09:47:33AM -0800, Per Bothner wrote:
> Attached a patch to tweak biblioentry/abbrev and biblioentry/title.
> Punctuation is still missing, but fixing that is probably not
> practical with css.  I should probably use bibliomixed.

I'm not particularly familiar with the punctuation expected within
bibliographies, so I've just been looking at the results of db2pdf on
this example:

  http://docbook.sourceforge.net/testdocs/bibliography.001.xml

I've previously played around with tricks like the following to generate
punctuation between items using CSS2:

  authorgroup > author+author:before {
      content: ", ";
  }

The problem with that is that whitespace between elements will set apart
an item from its trailing comma.  For example, with the above CSS, this:

  <authorgroup>
    <author><firstname>Alfred</firstname> <surname>Aho</surname></author>  
    <author><firstname>Ravi</firstname> <surname>Sethi</surname></author>
  </authorgroup>

gives:

  Alfred Aho , Ravi Sethi


I've just had a go at using shiny new CSS3 syntax, we can do a lot
better now -- putting the comma after <author> elements, rather than
before them:

  authorgroup > author:not(:last-child):after {
      content: ", ";
  }

gives, for the same example XML:

  Alfred Aho, Ravi Sethi


Much better, as long as one has a recent Gecko browser.


> It might be worth considering displaying:
>   <xref linkend="entry"/>
> as:
>   [entry]
> but that would be weird for other xrefs.
> One solution might be to use a role attribute:
>   <xref linkend="entry" role="citation"/>

I didn't manage to reconcile content generated by the CSS with content
generated by XUL (they both ended up appearing), so I just reduced the
content CSS generates for <xref> down to a 'section symbol'.

Changing presentation based on a role attribute could be implemented in
a customisation layer.  Making one should be as simple as:

----8<----
  @import "docbook-css-0.4/driver.css"

  xref[role=citation]:before {
      content: "[";
  }
  xref[role=citation]:after {
      content: "]";
  }
---->8----

(I'm presuming this use of role is not already widespread?)


> Of course it would be nice to make the xref a clickable
> link to the biblioentry; I haven't tried the patch you
> patched to the mailing list (which I'm not subscribed to).

Iy you want to try it, the clickability of <xref>s works well;
generating content based on the referenced element does not.



>  biblioentry > title {
>  	display: inline;
> +	font-style: italic;
> +	font-weight: normal;
>  }

I've done this, for both <biblioentry> and <bibliomixed>, and also
changed the selector from 'parent' to just 'ancestor' to catch <title>
within a <biblioset> too:

  biblioentry title, bibliomixed title {
      display: inline;
      font-style: italic;
      font-weight: inherit;
  }


> +biblioentry>abbrev:before {
> +	content: "[";
> +}
> +biblioentry>abbrev:after {
> +	content: "]";
> +}

I've added that in.


Also, to try and match the presentaion in the PDF I'm looking at, I
added the following:

  biblioentry, bibliomixed {
      text-indent: -2em;
  }
  biblioentry > *+*, bibliomixed > *+* {
      text-indent: 0;
  }

Bibliographies still need a lot more work though (as do many other areas
of the stylesheet).


Thanks for your suggestions!  I'm quite tired, so I hope that was
coherent.

dave

-- 
http://david.holroyd.me.uk/