CSS::TagSet

CSS Markup Tag-Sets

[Raku CSS Project] / [CSS::TagSet]

CSS::TagSet

Example

# interrogate styling rules for various XHTML tags and attributes
use CSS::TagSet::XHTML;
my CSS::TagSet::XHTML $tag-set .= new;

# show styling for various XHTML tags
say $tag-set.tag-style('i');  # font-style:italic;
say $tag-set.tag-style('b');  # font-weight:bolder;
say $tag-set.tag-side('th');  # display:table-cell;

# styling for <img width="200px" height="250px"/>
say $tag-set.tag-style('img', :width<200px>, :height<250px>);
# height:250px; width:200px;

Description

This module implements document specific styling rules for several markup languages, including XHTML, Pango and Tagged-PDF.

TagSet classes perform the role CSS::TagSet and implement the follow methods, to define how stylesheets are associated with documents and how CSS styling is determined from document content, including the extraction of stylesheets and applying styling to nodes in the document. The methods that need to be implemented are:

MethodDescription
stylesheet-content($doc)Extracts and returns stylesheets for a document
tag-style(Str $tag, :$hidden, *%attrs)Computes styling for a node with a given tag-name and attributes
inline-style-attribute()Returns inline styling attribute. Defaults to style

In the case of XHTML (CSS::TagSet::XHTML):

  • The stylesheet-content($doc) method extracts <style>...</style> tags or externally linked via <link rel="stylesheet href=.../> tags,

  • for example $.tag-style('b') returns a CSS::Properties object font-weight:bolder;

The default styling for given tags can be adjusted via the base-style method:

say $tag-set.tag-style('small'); # font-size:0.83em;
$tag-set.base-style('small').font-size = '0.75em';
say $tag-set.tag-style('small'); # font-size:0.75em;

base-style can also be used to define styling for simple new tags:

$tag-set.base-style('shout').text-transform = 'upppercase';
say $tag-set.tag-style('shout');  # text-transform:upppercase;

Classes

CSS::TagSet v0.1.0

CSS Markup Tag-Sets

Authors

  • David Warring

License

Artistic-2.0

Dependencies

CSS::Module:ver<0.5.8+>CSS::Properties:ver<0.8.4+>CSS::Stylesheet:ver<0.0.27+>Method::AlsoURI:ver<0.3.3+>

Test Dependencies

Provides

  • CSS::TagSet
  • CSS::TagSet::Pango
  • CSS::TagSet::TaggedPDF
  • CSS::TagSet::XHTML

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.