How to use Galleys
To prevent the complex calculation of a text flow while composing a page, the concept of the Proof is used to separate these stages. A galley is the old endless list of typeset text that came from old photographic typesetting machines. After the typesetting pieces of the text were cut and pasted to the page layout. After composing all, the full page would be photographed to film negative in order to expose offset plates.The order in which Xierpa is performing (automatic) page composition is similar.
| proof = Galley(data) | Create a new galley proof from XML text or a record. |
| proof = galley.getproof() | Create a new galley proof from the typesetting of a galley. |
| document.compose(gp) | Build the document by composing the required pages. |
| document.expose(canvas) | Expose the composed pages to the canvas. |
The inheriting of Galley classes is as follows:
- GalleyNodeSet
- GalleyFreeSpace
- GalleyStyle
- GalleyBuilder
- GalleyBase
- GalleyNode
- GalleyPage
- GalleyGroup
- GalleyMarker
- GalleyGraphic
- GalleyImage
- GalleyModule
- GalleyText
- GalleyEmptyNode
GalleyNodes and GalleyBuilder
GalleyBase
| Method | Attributes | Docstring or default value |
|---|---|---|
| A4HEIGHT | 842 | |
| A4LHEIGHT | 595 | |
| A4LWIDTH | 842 | |
| A4WIDTH | 595 | |
| ADJUST | 'adjust' | |
| ADJUSTCENTER | 'center' | |
| ADJUSTLEFT | 'left' | |
| ADJUSTRIGHT | 'right' | |
| COMPOSELINEAIRFILL | 'composelineairfill' | |
| COMPOSEPROOFS | 'composeproofs' | |
| DEFAULTDEBUGSTYLENAME | 'defaultdebugstyle' | |
| DEFAULTERRORSTYLENAME | 'defaulterrorstyle' | |
| DEFAULTIMAGEFIT | 'auto' | |
| DEFAULTLANGUAGE | 'nl' | |
| DEFAULTNAME | 'Untitled' | |
| DEFAULTSTYLENAME | 'defaultstyle' | |
| DEFAULTUSER | 'guest' | |
| DEFAULTWARNINGSTYLENAME | 'defaultwarningstyle' | |
| DEFAULTXSLTEMPLATEPATH | '/_xsl/galley.xsl' | |
| ERRORSTYLE | 'error' | |
| EVENT_NEWPAGE | 'slice_newpage' | |
| GROUPNAME_BOOK | 'book' | |
| GROUPNAME_CHAPTER | 'chapter' | |
| GROUPNAME_COVER | 'cover' | |
| GROUPNAME_NEWPAGE | 'newpage' | |
| IMAGESTYLENAME | 'imagestyle' | |
| MAXINTEGER | 10000000 | |
| PDFCANVAS | {'icc_handle': 0, 'color': 'black', 'stroke': 0, 'font': 'Productus-Book', 'quality': None, 'underline': False, 'fill': True, 'title': '', 'bgcolor': 'white', 'strokecolor': 'black', 'opacity': 1, 'pagewidth': 100, 'format': 'pdf', 'offsetx': 0, 'offsety': 0, 'toporigin': 0, 'fontsize': 10, 'user': 'author', 'path': 'galleybase', 'rotation': 0, 'tracking': 0, 'imagefit': 'auto', 'pageheight': 100, '_openedpage': True, 'mask': None, 'zoom': 1, 'strokeopacity': 1, 'pdf': '_8bd37b8_PDF_p', 'options': {}} | |
| PLACEMENT_EMPTY | None | |
| PLACEMENT_NOTPLACED | False | |
| PLACEMENT_PLACED | True | |
| SLICE_ALL | 'slice_all' | |
| SLICE_HEIGHT | 'slice_height' | |
| SLICE_INITIALWIDTH | 'slice_initialwidth' | |
| SLICE_MARKER | 'slice_marker' | |
| SLICE_NONE | None | |
| SLICE_SPLITDOCUMENTLIST | 'slice_splitdocumentlist' | |
| SLICE_WIDTH | 'slice_width' | |
| STYLEALIGN | 'align' | |
| STYLEAUTHOR | 'author' | |
| STYLEAUTONEWPAGE | 'autonewpage' | |
| STYLEAUTOTEXTWRAP | 'autotextwrap' | |
| STYLEBACKGROUNDCOLOR | 'bgcolor' | |
| STYLEBASELINE | 'baseline' | |
| STYLEBASELINECOLOR | 'baselinecolor' | |
| STYLEBASELINESHIFT | 'baselineshift' | |
| STYLEBOTTOMMARGIN | 'bottommargin' | |
| STYLEBULLETINCREMENT | 'bulletincrement' | |
| STYLEBULLETSTYLENAME | 'bulletstylename' | |
| STYLECHECKSPELLING | 'checkspelling' | |
| STYLECOLOR | 'color' | |
| STYLECOLUMNHEIGHT | 'cheight' | |
| STYLECOLUMNWIDTH | 'cwidth' | |
| STYLECOMPOSERGRIDCOLOR | 'composergridcolor' | |
| STYLECOMPOSERPLACEDCOLOR | 'composerplacedcolor' | |
| STYLECOMPOSINGTYPE | 'composingtype' | |
| STYLECUTTABLE | 'cuttable' | |
| STYLEFILL | 'fill' | |
| STYLEFIRSTINDENT | 'firstindent' | |
| STYLEFIRSTPAGENUMBER | 'firstpagenumber' | |
| STYLEFIXEDLEADING | 'fixedleading' | |
| STYLEFONT | 'font' | |
| STYLEFONTSIZE | 'fontsize' | |
| STYLEFREESPACECOLOR | 'freespacecolor' | |
| STYLEFREESPACETYPE | 'freespacetype' | |
| STYLEGALLEYROOT | 'galleyroot' | |
| STYLEGRIDCOLOR | 'gridcolor' | |
| STYLEGUTTERX | 'gutterx' | |
| STYLEGUTTERY | 'guttery' | |
| STYLEHEIGHT | 'height' | |
| STYLEHYPHENATE | 'hyphenate' | |
| STYLEHYPHENGLYPH | 'hyphenglyph' | |
| STYLEID | 'id' | |
| STYLEIMAGEFIT | 'imagefit' | |
| STYLEIMAGEHOTSPOTS | 'imagehotspots' | |
| STYLEIMAGEPATH | 'imagepath' | |
| STYLEIMAGERESIZELIMIT | 'imageresizelimit' | |
| STYLEIMAGESCALE | 'imagescale' | |
| STYLELANGUAGE | 'language' | |
| STYLELAYER | 'layer' | |
| STYLELEADING | 'leading' | |
| STYLELEFTINDENT | 'leftindent' | |
| STYLELEFTMARGIN | 'leftmargin' | |
| STYLELEFTMINHYPHEN | 'leftminhyphen' | |
| STYLELISTBULLET | 'listbullet' | |
| STYLEMIRRORPAGE | 'mirrorpage' | |
| STYLENAME | 'name' | |
| STYLENEEDSNEWPAGE | 'needsnewpage' | |
| STYLENEXTPLACEMENT | 'nextplacement' | |
| STYLEOPACITY | 'opacity' | |
| STYLEPAGENUMBERX | 'pagenumberx' | |
| STYLEPAGENUMBERY | 'pagenumbery' | |
| STYLERELEVANCE | 'relevance' | |
| STYLERIGHTBULLETINDENT | 'rightbulletindent' | |
| STYLERIGHTINDENT | 'rightindent' | |
| STYLERIGHTMARGIN | 'rightmargin' | |
| STYLERIGHTMINHYPHEN | 'rightminhyphen' | |
| STYLEROTATION | 'rotation' | |
| STYLESCALEX | 'scalex' | |
| STYLESCALEY | 'scaley' | |
| STYLESHADOWBLUR | 'shadowblur' | |
| STYLESHADOWCOLOR | 'shadowcolor' | |
| STYLESHADOWOPACITY | 'shadowopacity' | |
| STYLESHADOWX | 'shadowx' | |
| STYLESHADOWY | 'shadowy' | |
| STYLESHOWBASELINEGRID | 'showbaselinegrid' | |
| STYLESHOWFREESPACE | 'showfreespace' | |
| STYLESHOWGRID | 'showgrid' | |
| STYLESLICEABLE | 'sliceable' | |
| STYLESNAPBASELINE | 'snapbaseline' | |
| STYLESOFTHYPHENATE | 'softhyphenate' | |
| STYLESPACEWIDTH | 'spacewidth' | |
| STYLESTROKE | 'stroke' | |
| STYLESTROKECOLOR | 'strokecolor' | |
| STYLESTROKEOPACITY | 'strokeopacity' | |
| STYLESTYLENAME | 'stylename' | |
| STYLETABS | 'tabs' | |
| STYLETEXTBLOCKHEIGHT | 'textblockheight' | |
| STYLETEXTBLOCKWIDTH | 'textblockwidth' | |
| STYLETEXTHOTSPOTS | 'texthotspots' | |
| STYLETITLE | 'title' | |
| STYLETOPMARGIN | 'topmargin' | |
| STYLETOPORIGIN | 'toporigin' | |
| STYLETRACKING | 'tracking' | |
| STYLETYPE | 'type' | |
| STYLEUNDERLINE | 'underline' | |
| STYLEUNIT | 'unit' | |
| STYLEWIDTH | 'width' | |
| STYLEX | 'x' | |
| STYLEXSLTEMPLATE | 'xsltemplate' | |
| STYLEY | 'y' | |
| UNIT | 12 | |
| applytypographicstyles | canvas |
The applytypographicstyles method applies the style color and all style values that have
influence on the flow of a text: font, fontsize, tracking.
|
| ch2h | ch |
The ch2h (Column Height to Point) method translates a column height into a point measurement value, depending on the values of
self.get(self.STYLECOLUMNHEIGHT) and self.get(self.STYLEGUTTERY). Note that the column height value assumes an extra gutter on at the top
of the column, that is compensated by a top indent. This way the positioning of free space is more easy.
|
| cw2w | cw |
The cw2w (Column Width to Point measure) method translates a column width into a point measurement value, depending on the values of
self.get(self.STYLECOLUMNWIDTH) and self.get(self.STYLEGUTTERX). Note that the column width value assumes an extra gutter on the left side
of the column, that is compensated by a left indent. This way the positioning of free space is more easy.
|
| cwh2wh | ch cw |
The cwh2wh (Column Width/Height to Point measure) method translates a column w/h size into a point w/h tuple value.
|
| cx2x | cx |
The cx2x (Column X to Point measure) method translates a column horizontal position into a point value, depending on the values of
self.get(self.STYLECOLUMNWIDTH) and self.get(self.STYLEGUTTERX).
|
| cxy2xy | cx cy |
The cxy2xy (Column X/Y to Point measure) method translates a column x/y position into a point x/y tuple value.
|
| cy2y | cy |
The cx2x (Column Y to Point measure) method translates a column horizontal position into a point value, depending on the values of
self.get(self.STYLECOLUMNHEIGHT) and self.get(self.STYLEGUTTERY).
|
| getalign |
The getalign method answers alignment of the node.
|
|
| getauthor |
The getauthor method answers the current author style.
|
|
| getbackgroundcolor |
The getbackgroundcolor method answers the background color of the current cascading style as self.get(self.STYLEBACKGROUNDCOLOR).
|
|
| getbaselineshift |
The getbaselineshift method answers the baselineshift of the current cascading style as self.get(self.STYLEBASELINESHIFT).
If the entry does not not exist, answer 0.
|
|
| getcolor |
The getcolor method answers the color of the current cascading style as self.get(self.STYLECOLOR).
|
|
| getcomposingtype |
The getcomposingtype method answers the document/page composing fill type.
|
|
| getdocumenttype |
The getdocumenttype method answers the current document type style.
|
|
| getfirstindent |
The getfirstindent method gets the first line indent of the text.
|
|
| getfont |
The getfont method answers the font of the current cascading style as self.get(self.STYLEFONT).
|
|
| getfontsize |
The getfontsize method answers the fontsize of the current cascading style as self.get(self.STYLEFONTSIZE).
|
|
| getheight |
The getheight method answers the node.height if it is not None.
Otherwise self.get(self.STYLEHEIGHT).
|
|
| getid |
The getid method answers the id of the node.
|
|
| getimagepath |
The getimagepath method answers the image path of the style.
|
|
| getlanguage |
The getlanguage method answers the current language style.
|
|
| getleading |
The getleading method answers the leading of the current cascading style as self.get(self.STYLELEADING).
If the entry does not not exist, answer 0.
|
|
| getleftindent |
The getleftindent method gets the left indent of the text.
|
|
| getname |
The getname method answers name of the node.
|
|
| getneedsnewpage |
The getneedsnewpage method answers the flag if this node requires a new page as defined by the style.
|
|
| getrelevance |
The getrelevance method answers the relevance of the node.
|
|
| getrightindent |
The getrightindent method gets the right indent of the text.
|
|
| getrotation |
The getrotation method answers the rotaton angle of the current cascading style as self.get(self.STYLEROTATION).
|
|
| getsize |
The getsize method answers the size of the node in a (self.width, self.height) tuple.
|
|
| getsliceable |
The getsliceable method answers the minimum height that makes this node sliceable.
|
|
| getstrokecolor |
The getcolor method answers the stroke color of the current cascading style as self.get(self.STYLESTROKECOLOR).
|
|
| gettabs |
The gettabs method answers the current set of tabs.
|
|
| gettitle |
The gettitle method answers the current title style.
|
|
| gettoporigin |
The gettoporigin method answers top-left origin flag.
|
|
| gettracking |
The gettracking method answers the tracking of the current cascading style as self.get(self.STYLETRACKING).
|
|
| gettype |
The gettype method answers the type of the node.
|
|
| getunderline |
The getunderline method answers the underline flag of the current cascading style as self.get(self.STYLEUNDERLINE).
|
|
| getunit |
The getunit method answers the size of the page unit measure.
|
|
| getwidth |
The getwidth method answers the node.width if it is not None.
Otherwise self.get(self.STYLEWIDTH).
|
|
| getxsltemplate |
The getxsltemplate method answers the current XSL template path of the style.
Check on definition in the style return of self.get(self.STYLEXSLTEMPLATE) .
|
|
| h2ch | h |
The h2ch (Height to Columnheight measure) method translats a pt height into the (truncated+1) number of columns.
The h add half gutter and then rounds. This make tiny overfill (within half the gutter) not create another column.
|
| setcomposingtype | composingtype |
The setcomposingtype method sets the document/page composing fill type.
|
| setxsltemplate | template |
The setxsltemplate method sets the template of the current style to template.
|
| stringwidth | s |
The stringwidth method answers the string width with the defined font, font size and tracking.
Calling this method, make sure to call self.applytypographicstyles() once for every change
on typographic values.
|
| truncate2unit | v |
The truncate2unit method truncates the value v to the largest whole unit measure inside v.
|
| w2cw | w |
The w2cw (Width to Columnwidth measure) method translats a pt width into the (truncated+1) number of columns.
The w add half gutter and then rounds. This make tiny overfill (within half the gutter) not create another column.
|
| wh2cwh | h w |
The wh2cwh (Point to Column Width/Height measure) method translates a point w/h size into a column w/h tuple value.
|
| x2cx | x |
The x2cx (Point to Column X measure) method translates a point horizontal position into a column value, depending on the values of
self.get(self.STYLECOLUMNWIDTH) and self.get(self.STYLEGUTTERX).
|
| y2cy | y |
The y2cy (Point to Column Y measure) method translates a point vertical position into a column value, depending on the values of
self.get(self.STYLECOLUMNWIDTH) and self.get(self.STYLEGUTTERX).
|
GalleyNodes
The GalleyNode is the base class for all Galley node instances.| Method | Attributes | Docstring or default value |
|---|---|---|
| SHOWTIME | False | |
| append | height item style width x y |
The append method appends the node to the current list of self.getnodes().
If item is not an instance of GalleyNode then assume it needs to be handled as a string.
In that case a GalleyText instance is created with its unicode representation.
Set the parent of the item node to self.
Answer the item.
|
| expose | canvas level originx originy |
The expose method takes a canvas to expose the content of the node at its position on the canvas.
Draw the node border if the local value of self.get(self.STYLEBORDER) is defined.
|
| get | default name |
The get method answers the name style value of the current node.
If the entry does not exist, then get the value from the parent node if it exists. If the result
of all parents in the tree is None then answer either the default value.
In most cases the node will contain all values if the node is made by the GalleyBuilder.
Note that the default is rarely used, since the Galley instance on the tree root
always contains the result style of self.getdefaultstyle() by default. So the default attribute value is
only used if the requested value is not in the default style.
|
| getheighty |
The getheighty method answers the positioned height of the node in a column calculated by
self.y + max(self.height, self.get(self.STYLESLICEABLE)). This method can be used to
decide if the node (plus what is supposed to come after it when sliced) fits in a particular space.
|
|
| getindex | node |
The getindex method answers the index of node in the list self.getnodes().
|
| getlastindexwithsamey |
The getlastindexwithsamey method answers index self or the index of the last node with the same y position
as self in the list of siblings. This is used to make a split on the node, while taking all next nodes with the same y as well.
|
|
| getnext |
The getnext method answers the next node of self in the list self.parent.getnodes().
If there is not next node, answer None.
|
|
| getnodes |
The getnodes method answers the self._nodes node list.
|
|
| getprevious |
The getprevious metod answers the previous node of self in the list self.parent.getnodes().
If there is not previous node, answer None.
|
|
| getproof | proof |
The getproof method answers a Proof instance that holds a flat list of
all nodes of self. It is assumed that all position and size attributes are set in the nodes
by self.typeset. Note that all nodes are added to the proof, even if they contain
other nodes, such as groups. This way we can derive the information from the nodes in a lineair
way, pretending it is not a tree. The Proof instance will never look inside the nodes.
|
| getref |
The getref answers the node ref field.
|
|
| getsiblingindex |
The getsiblingindex method answers the index of self in the sibling list self.parent.getnodes().
If self is the root, then answer None.
|
|
| getstyle |
The getstyle method answers the style of the node.
|
|
| gettext | level result |
The gettext method answer the plain string of all content of the node and children merged.
|
| getwidthx |
The getwidthx method answers the positioned width of the node in a column calculated by
self.x + self.width. This method can be used to decide if the node fits in a particular space.
|
|
| getxml | level result |
The getxml method answers the XML representation of the galley tree.
|
| iscontainer |
The iscontainer method answers the boolean flag True, because by default all nodes can contain other nodes.
|
|
| isempty |
The isempty method answers True if there are no children and self.data is empty.
Also the node is assumed to be empty if it only contains empty nodes.
|
|
| isgroup |
The isgroup method answers if this node is a group that requires special attention during
the composition of a page or exposing the document.
|
|
| ismarker |
The ismarker method answers if this node is a marker that requires special attention during
the composition of a page or exposing the document.
|
|
| isplaceable |
The isplaceable method answers the boolean flag True, because by default all nodes can be placed in a page.
|
|
| iswidow |
The iswidow method answers False.
|
|
| needsnewpage |
The needsnewpage method answers the boolean flag False, because by default all nodes can be placed in a page.
|
|
| parent | ||
| printtree | level |
The printtree method prints an indented tree of node names.
|
| printtreenode | level |
The printtreenode method is called by printtree to print the indented content
of self.
|
| set | name value |
The set method creates a new Style to avoid disturbing the behaviour of other
nodes that may reference to the same style. Then value under name.
|
| setnodes | nodeset |
The setnodesnodes method set the node._nodes to the optional nodeset attribute.
If omitted then the nodeset is initialized to an empty GalleyNodeSet instance.
The method checks with an assert if the nodeset is really an instance of GalleyNodeset.
|
| setref | ref |
The setdata stores application reference related ref into self. The application is free to store
any object in this field, as long as it is not related to self in a circular way.
|
| settime |
The settime method sets the internal time marker. This method is used for debugging and tracing
what time parts of the exposing costs. If self.SHOWTIME is False then ignore.
|
|
| showtime |
The showtime method show the time spend on execution from the moment self.settime() was called.
This method is used for debugging and tracing what time parts of the exposing costs.
If self.SHOWTIME is False then ignore. |
GalleyNodeSet
| Method | Attributes | Docstring or default value |
|---|
Proof
| Method | Attributes | Docstring or default value |
|---|---|---|
| DEBUG | False | |
| DEBUGBASELINES | False | |
| DEBUGBOUNDINGBOX | False | |
| DEBUGCOLOR | '#2020C0' | |
| DEBUGFONT | 'Productus-Book' | |
| DEBUGFONTSIZE | 6 | |
| DEBUGFRAMECOLOR | 'red' | |
| DEBUGSTYLEBACKGROUNDCOLOR | 'black' | |
| DEBUGSTYLENAMECOLOR | 'yellow' | |
| DEBUGSTYLENAMES | False | |
| SHOWTIME | False | |
| UNIT | 12 | |
| add | proof |
The add method adds self proof to self and answers self with adjusted
width and height attributes. Note that the (node.x, node.y) position is changed for
the nodes in proof, so this instance should can no longer be used. To avoid mistakes there,
the node storage of proof and the width and height attributes are cleared.
|
| adjustsize | node |
The adjustsize method adjusts self.width and self.height. Only placeable
nodes are examined.
|
| append | item |
The append method appends item to self.
The attribute item can be one of [Proof, list, tuple, GalleyNode]. If item
fits on the right side of the lowest node in the current node list, then add it on the lowest baseline.
If the the horizontal position would overlap existing nodes, the add the leading of the appending node. The node list always remains sorted on node.y. Note that if nodes are added one by one by the caller the sorting is performed for every append. This is not optimal efficient. Best it to add chunks of nodes all at once. The node.parent value is untouched, so when slicing a Proof instance the nodes always maintain contact with the original galley. |
| appendnode | node x y |
The appendnode method appends a copy of the GalleyNode instance node to the node list.
The size of self is adjusted to the position and size of the added nodes. Assumed if that the position
of node is already set. Don’t set the parent of the node copy to self, because the style getting needs
the reference to the original root node. The optional x and y attributes are used as the new coordinates of the copy of the node. This avoid to make a double copy of node by the caller, since we don't want to damage the position of the original node. |
| appendnodes | nodes offsety |
The appendnodes method appends all nodes to self with offsety as offset.
The size of self is adjusted to the position and size of the added nodes.
|
| copy |
The copy method answers a copy of self including a copy of the contained nodes.
This way cutting of splitting the proof will not damage the coordinates of the original nodes.
This allows a page to cut and paste proofs and then backtrack to the original proof if needed.
|
|
| cut | height |
The cut method does split on distance where the split method splits on index.
Two new Proof are answrered containing the parts, both with their own bounding box defined. If the whole
proof fits witin the requested height then answer self, None. The method runs over
the contained nodes until the first one that exceeds height + node.get(self.STYLESLICEABLE).
Also make sure that sliceable space can run over the proof height when there is a head close
to the bottom. In that case compare with the proof height. On the found index the split is made, since we can assume that the nodes are ordered by baseline y position. |
| debug | marker |
The debug method prints self debug info.
|
| estimatecuttingindex | height |
The estimatecuttingindex method answers the best guess to cut the proof so that the largest possible length of the first
part does not exceed height, while it takes care of possible orphans and widows that may be the result of the cut.
If there is a chance that an orphan or widow will appear on the top of the second part, then try to cut higher. This is fuzzy logic,
because is may be hard to distinguish between e.h. a widow and a cut through an list of single words. But we’ll give it a shot. The
actual decision for the best cutting index is calculated by self.getvalidcuttingindex(index, height).
|
| expose | canvas level originx originy |
The expose methods calls the expose of all nodes in the list. Only expose non-container nodes,
we are not interested in their children, since a Proof is already a flattened list.
The positioning of the nodes uses self.x and self.y as offset. This
way a proof can be “hard position” or relative positioned by the calling node. At the very last, the baseline shift of the node is added. This value is thus invisible for the position and size of the galley. If self.DEBUG is set, then draw the baselines, local y positions and the proof bouding box as red frame. |
| exposebaselines | canvas originx originy |
The exposebaselines method does draw a little baseline indicator with the local
proof y-position in 6 pt font in color self.DEBUGCOLOR.
|
| exposeboundingbox | canvas originx originy |
The exposeboundingbox method draws the bouding box of the proof as a red frame.
|
| exposedebug | canvas originx originy |
The exposedebug method decides on the value of the flags self.DEBUGBASELINES, self.DEBUGBOUNDINGBOX
and self.DEBUGSTYLENAMES if respectively the baseline and vertical relative position is exposed, the bounding box of the content
of the proof in a red rectangle and little yellow/black tags showing the current style name.
|
| exposestylenames | canvas originx originy |
The exposestylenames method draws the styles of the node on the origin of the nodes
as very small diapositive labels. Only show a name if it differs from the previous style.
|
| getlastindexwithsamey | node |
The getlastindexwithsamey method answers index self or the index of the last node with the same y position
as self in the list of siblings. This is used to make a split on the node, while taking all next nodes with the same y or empty nodes
into the slice as well.
|
| getnodes |
The getnodes method answers the nodes of the proof.
|
|
| getpreviousindexwithdifferenty | node |
The getpreviousindexwithdifferenty method answers index self or the index of the last previous node with a diferent y position
as self in the list of siblings. This is used to make a split on the node, while taking all next nodes with the same y or empty nodes
into the slice as well.
|
| getproof | proof |
The getproof method adds a flat list of all nodes of self to proof. using (self.x, self.y)
as offset. It is assumed that all proof-relative position and size attributes are set in the nodes by self.typeset.
Note that because the x,y values of the nodes are actually changed, all nodes are copied. Note also that all nodes are added to the proof, even if they contain other nodes, such as groups. This way we can derive the information from the nodes in a lineair way, pretending it is not a tree. The Proof instance will never look inside the nodes. If the proof attribute is omitted or None then just answer a copy of self. |
| getsize |
The getsize method answers the tuple (self.width, self.height).
|
|
| getstyle |
The getstyle method answers None to be compatible with GalleyNode
instances. A Proof instance never has a style by itself.
|
|
| gettext |
The gettext method answers a concatenated string of all node.gettext() results.
|
|
| getvalidcuttingindex | height index |
The getvalidcuttingindex method investigates and answers the first valid cutting index as seen from the position
if the defined index attribute does not exceed the total height. If there is not a fit possible
at the defined index then answers 0.
|
| getxml |
The getxml method answers a concatenated string of all node.getxml() results.
|
|
| isempty |
The isempty method answers the boolean flag if the proof does not contain nodes or if it only contains
nodes that are empty.
|
|
| issliced |
The issliced method answers the flag if this proof was ever sliced from an original or not. This way the
composing application can decide if the proof is in its original state, or that there may be pieces missing due to
slicing.
|
|
| printtree | level |
The printtree method calls node.printtreenode() for all contained nodes. We are
not interested in the child node of nodes, since a Proof instances only contain a flat (flattened) list of
nodes.
|
| settime |
The settime method sets the internal time marker. This method is used for debugging and tracing
what time parts of the exposing costs. If self.SHOWTIME is False then ignore.
|
|
| showtime |
The showtime method show the time spend on execution from the moment self.settime() was called.
This method is used for debugging and tracing what time parts of the exposing costs.
If self.SHOWTIME is False then ignore.
|
|
| sort |
The sort method sorts the nodes of the proof. @@@ Bug to solve: when node have the same node.y
position, then their order (and thus the z-order) may change. We want to keep the z-order unchanged.
|
|
| split | index |
The split method splits self> into two new Proof instances
that contain the two parts of the self.getnodes() split on position (including) index.
All nodes are copied on append by the new proofs, so the reposition of nodes in the second slice does
not damage the nodes in self.
|
GalleyPage
| Method | Attributes | Docstring or default value |
|---|---|---|
| acceptsimulation |
The acceptsimulation method stops the current (local) simulation mode and takes the current simulated
result as current composer state. This way the original (locally pushed) composer is deleted. Note that the page
may still be in simulation from another level of composition.
|
|
| clearhot |
The clearhot method clears the current hot position of the composer, equivalent to composer.sethot().
This method is used by a builder to clear the hot element position for future use, if it used all available space of the
hot element.
|
|
| deletesimulation |
The deletesimulation method stops the (local) simulation mode and restores the saved composer state.
This way the current state of the (local) simulation is deleted. Note that the page may still be in simulation
from another level of composition.
|
|
| expose | canvas level originx originy |
The expose method does expose the composed page on the canvas and then all
nodes that were appended to the page separately. The method checks with an assert of the
page is not still in simulation mode.
|
| exposebaselines | canvas |
|
| exposegrid | canvas |
|
| findfirstfree | height hotspots placement width |
The findfirstfree method is the equivalent of the self.getcomposer().findfirstfree(...).
The method answers the first topleft coordinate from the result list of findfree().
The placement can have the values self.RELEVANCE, Composer.MAGNETIC,
Composer.VERTICAL (default) and Composer.HORIZONTAL to indicate the searching direction.
The optional width and height attributes define a requested size to accommodate.
If the search is done by self.RELEVANCE, then the composer answers the first point in the hotspot list that
is not occupied. This technique allows to define a list of areas that will be filled in a particular order. Note that one
placement may occupy several hotspots at the time. If there are no free hostspot points available hotspots left, the
page is considered “filled” without searching of other free area’s. If the search is done by self.MAGNETIC, then the composer answers the free space closest to one of the hotspot points. If the attribute hotspots is None then the single magnetic point [(0,0)] is used. In general the format of the list is [(x1,y1), (x2,y2), ...]. If one of x or y values is None, then use the tuple as the indicator of a magnetic line. |
| getcolumngridsize |
The getcolumngridsize method answers the number of grid elements (w,h) on the page.
This can be used as width and height attributes to create a Composer
instance. Calling this method from a page will show the number of columns on a page. Calling it from a smaller node
will answer the local number of columns. Note that in that case the (page)margins should be redefined on a local level.
|
|
| getcomposer |
The getcomposer method ansers the page composer.
|
|
| getelements |
The getelements method answers the elements that currently a place in the composer of the page.
Note that this is different from the self.getnodes(), which answers the nodes in the page node tree.
|
|
| getelementsbyorder |
The getelementsbyorder method answers a list of chronological placed elements of the composer.
|
|
| getfreeindicator |
The getfreeindicator method answers a number that is an indicator for the volume of the page
that is still free in the composer. The value if a float number between 0 (no space left)
and 1 (empty page). Note that only the real free positions are counted, excluding the
reserved space as well. Note that the answered value is based on the current composer level, which may me in simulation state. |
|
| getfreetotal |
The getfreetotal method aswers the total number of free positions (without an indication
for the amount they are scattered or available as one free block). Note that the answered value is based on the current composer level, which may me in simulation state. |
|
| getpagenumber |
The getpagenumber method answers the self._pagenumber.
|
|
| hotextendable | direction |
The hotextendable method is the equivalent of the self.getcomposer().hotextendable(...).
The method answers a tuple of (element, (x, y), (w, h)). The (w, h) is the size
that the element can be expanded to. Depending on the value of the direction attribute, one of
[Composer.VERTICAL, Composer.HORIZONTAL],
it contains respectively the vertical or horizontal grown size. The default direction is Composer.VERTICAL.
If the element cannot be expanded, then the value is None. If the hot element was not set, then the methods answers
None instead of the described tuple. Note that the method does not change the element of the placed slice. The application needs to adjust the element up to the answered available size and then application has to call self.resizeelement(element, width, height) |
| issimulation |
The issimulation method answers the boolean flag if the page is in simulation mode (as started by the call
self.simulate(). The simulation mode ends by either calling self.acceptsimulation() or
self.deletesimulation().
|
|
| newcomposition |
The newcomposition method clears all stacked composers, in case the page was already in simulation mode.
Then an initial Composer instance is pushed on the composers stack.
|
|
| place | element height hot width x y |
The place is the equivalent of the self.getcomposer().place(...).
|
| printdump |
The printdump method prints an overview of all nodes in the composer to the standard output.
|
|
| reserve | height width x y |
The reserve method does reserve the composer position at (x,y)
and optional width and height (default value is 1). Note that the reservation is made the current composer level, which may me in simulation state. |
| simulate |
The simulate method puts the page in simulation mode, relative to the current state of the composer on
top of the self._composers stack. This means that the page may already by in simulation mode on another level of page composition, but we don’t need to know that here. Every stage in the page composition just tries to get get the best result before finishing, while leaving that state as the current composer on top of the stack. A copy of the current composer is made and pushed on stack, so the page can backtrack if the simulation goes wrong. |
|
| unreserve | height width x y |
The unreserve method unreserves the space as the defined by coordinate (x,y) and
optional width and height (default value is 1). Note that it only will
remove any existing composer.RESERVED (also if it the space was not reserved before).
Any other placed elements are unaffected. This method can be used in combination with the self.reserve
method to temporary remove an area from the free space (e.g. for a table of content that will be filled
in the later stage of composing). Note that the unreservation is made the current composer level, which may me in simulation state. |
GalleyGroup
| Method | Attributes | Docstring or default value |
|---|---|---|
| append | height item style width x y |
The append method does behave exactly like it’s superclass GalleyNode.append()
method. Additionally the total width and height values are adjusted.
|
| isgroup |
The isgroup method answers if this node is a group that requires special attention during
the composition of a page or exposing.
|
|
| isplaceable |
The isplaceable method answers the boolean flag True, because
a GalleyGroup instance itself is not something the needs to be placed.
|
GalleyMarker
| Method | Attributes | Docstring or default value |
|---|---|---|
| MARKER_NEWPAGE | 'newpage' | |
| expose | canvas level originx originy |
The expose method does no do anything. Marker are intended to be interpreted on composing level.
|
| iscontainer |
The iscontainer method answers the boolean flag False, because we don’t want the page placement reserve
for free space below the level of a GalleyModule.
|
|
| ismarker |
The ismarker method answers if this node is a marker that requires special attention during
the composition of a page or exposing.
|
|
| isplaceable |
The isplaceable method answers the boolean flag True, because
a GalleyMarker instance itself is not something the needs to be placed, but it needs
to be copied in proofs to mark specific areas or functions such as the location of a NEWPAGE request.
|
GalleyImage
| Method | Attributes | Docstring or default value |
|---|---|---|
| DEBUG | False | |
| DEBUGCOLOR | '#2020C0' | |
| expose | canvas level originx originy |
The expose method does expose the image at its position on the canvas.
The border value is derived from the local style only, no upward parent style search is performed.
If self.get(self.STYLEIMAGESCALE) is more that 0, create a temp scaled image before pasting
it into the PDF on order to reduce the PDF file size. The default value is 2. The values of self.get(self.STYLESTROKE) (thickness of the stroke in pixels) and self.get(self.STYLESTROKECOLOR) (color) make the image draw a frame. if the stroke value renders to False then not frame is drawn. |
| exposeborder | canvas originx originy |
The exposeborder method does expose a border around the image and the given position with a thickness
of self.get(self.STYLESTROKE) and color self.get(self.STYLESTROKECOLOR).
|
| exposeerrorinfo | canvas error originx originy |
|
| exposemetainfo | canvas originx originy |
|
| getfilesize |
The getfilesize method answers the file size of the image file.
|
|
| getleading |
The getleading method implements the exception for images that they answer the vertical height
as leading, instead of the style value.
|
|
| height |
The _get_height method is called by the self.height in the GalleyNode class.
If the height is set as self._height, then answer that. If it does not
exist and there is a self._width defined, then calculate the height proportionally. Otherwise answer the style height
or the original height of the image file.
|
|
| iscontainer |
The iscontainer method answers the boolean flag False, because we don’t want the page placement reserve
for free space below the level of a GalleyModule.
|
|
| width |
The _get_width method is called by the self.width in the GalleyNode class.
If the width is set as self._width, then answer that. If it does not exist and there is a
self._height defined, then calculate the width proportionally. Otherwise answer the style width
or the original width of the image file.
|
GalleyGraphic
| Method | Attributes | Docstring or default value |
|---|---|---|
| RECTANGLETYPE | 1 | |
| expose | canvas level originx originy |
The expose method does expose the instance content on the canvas relative to position (originx, originy).
The border value is derived from the local style only, no upward parent style search is performed. There
is not exposing of a border by this node type.
|
| iscontainer |
The iscontainer method answers the boolean flag False, because we don’t want the page placement reserve
for free space below the level of a GalleyModule.
|
GalleyText
| Method | Attributes | Docstring or default value |
|---|---|---|
| countwordspace |
The countwordspace method counts the word spaces of the contained string. This is used to determine the
amount of spaces in a text line for adjusting it.
|
|
| expose | canvas level originx originy |
The expose method does expose the instance content on the canvas relative to position (originx, originy)
and the style baselineshift. The adjustment of the style defines the position of the origin of the text.
|
| iscontainer |
The iscontainer method answers the boolean flag False, because we don’t want the page placement reserve
for free space below the level of a GalleyModule.
|
|
| iswidow |
The iswidow method answers False.
|
GalleyBuilder
The GalleyBuilder class takes XML content and converts it into a galley. The builder keeps track of the
current (cascading) style. Setting self.SHOWPARAGRAPH to True will show small red
paragraph signs in the output. If self.DEBUG is set to True as well, then the matching
tags for the selected amount of newlines are shown too.
If self.DEBUG is set to True then on various positions in the code, verbose debug information is shown.
If self.SHOWSTYLE is set to True then the style names are shown in the output.
The GalleyBuilder takes an XML/XSL structure and translates it into a Proof and builds a document with pages from it.If self.DEBUG is set to True then on various positions in the code, verbose debug information is shown.
If self.SHOWSTYLE is set to True then the style names are shown in the output.
| Open tag | Close tag | Attributes | Docstring or default value |
|---|---|---|---|
| DEBUG | False | ||
| PRINTRAWXML | False | ||
| PRINTXSLXML | False | ||
| SHOWPARAGRAPH | False | ||
| SHOWPARAGRAPHCODE | False | ||
| SHOWSTYLE | False | ||
| SHOWXMLERROR | True | ||
| UNICODE_NBSP | u'\xa0' | ||
| UNICODE_SHY | u'\xad' | ||
| XSL_XMLCONVERSIONS | ( |
||
| append | node |
The append method appends the node to the galley that is the result of
self.getgalley. The (x, y) is set to the cursor position
self.getcursor(). Note that if the cursor position of galley nodes is already set, then
self.getgalley().append(node) should be used to avoid the overwriting of the (x, y)
position of the node.
|
|
| caption | _caption | style |
The caption method does push the style named caption. We need a method instead of plain
style conversion by XSL, because the newline transformation needs to recognize the tag. The optional style
attribute can define the style name used. Otherwise the style is equal to the tag name.
|
| chapter | _chapter | style |
The chapter method does push the style named by the optional style. Otherwise the tag name
is used as style name. We need a method instead of plain style conversion by XSL, because the newline transformation
needs to recognize the tag.
|
| clear |
The clear does initialize all internal data of the builder. Call this method each
time when starting to build a new document.
|
||
| clearrequiredleading |
The clearrequiredleading method clears the required leading to 0.
|
||
| document | id |
The XSL document method is called from XSL to display a document as image. The tag includes hints on
the size and scale limits of the image.
|
|
| em | _em |
The XSL em method handles the callback from the <em> tag. The style named 'em' is used.
|
|
| error | text |
The error method shows the error in red.
|
|
| galley | _galley | style |
The galley tag is the standard root tag of a galley proof. Default behaviour is to do nothing.
Remember that although this often the root tag of an XML text, there may have been pushed styles already.
So we cannot push the default style here. That must be done by the construction of self.
The optional style attribute can define the style name used. Otherwise the style is equal to the tag name.
|
| getcursor |
The getcursor method answers the cursor.
|
||
| getgalley |
The getgalley method answers the running galley.
|
||
| gethypgenator |
The gethyphenator method answers the current hyphenator. The default behaviour it to answer
self._hyphenator.
|
||
| getimagescale | src |
The getimagescale method answers the scale factor that images should be stored in relation to their
100% placement. This allows the application to make the scale factor for photograph smaller
(e.g. 2)) in order to reduce image size, compared to the infographics of bitmap drawings that need
a factor of 8 or higher if their original size allows that. If the factor is not 1
then a temporary file is created before including it into the document. The standard behaviour of the method is
to answer the result of self.get(self.STYLEIMAGESCALE). In case the inheriting application class
needs to redefined this method, then the src attribute can be used to recognize the requested
image.
|
|
| getlistbullet |
The getlistbullet method answers the the standard bullet characters for ordered lists.
This method is called when the XSL call to self.orderedlist has the type undefined.
The default behaviour is to answer self.get(self.STYLELISTBULLET).
|
||
| getnextbullet | bullet |
The getnextbullet method interprets the bullet attribute and answers the “next” bullet,
depending on the context. If it is a number, then add self.get(self.STYLEBULLETINCREMENT). If the bullet
is equal to the result of self.getlistbullet then do nothing. If the bullet is a string in a-z,
the answer the next letter. @@@ It is not implemented yet what happens if the bullet goes beyond “z”.
|
|
| getproof |
The getproof method answers the current galley as converted to a Proof instance.
|
||
| getrequiredleading |
The getrequiredleading method answers the required leading. The default behaviour is to answer
self._requiredleading
|
||
| getrootgalley |
The getroot method answers the root galley of self.
|
||
| group | _group | id name needsnewpage relevance style type |
The XSL group method allows to create grouped output galley nodes that can be recognized
in the placements on the page. The method creates a new GalleyProof instance that behaves
as a single node (with it's own with and height) in the current proof. This can be thought of
as a “folded” pieces of paper on the original galley proof output. The optional style attribute (that evaluates to a dictionary by XSL) can be used as an overall style definition for the group. The attributes id and needsnewpage and relevance are stored in the group node style and can be used for composing decisions in the composition phase. |
| h1 | _h1 | style |
The h1 method does push the style named h1. We need a method instead of plain
style conversion by XSL, because the newline transformation needs to recognize the tag. The optional style
attribute can define the style name used. Otherwise the style is equal to the tag name.
|
| h2 | _h2 | style |
The h2 method does push the style named h1. We need a method instead of plain
style conversion by XSL, because the newline transformation needs to recognize the tag. The optional style
attribute can define the style name used. Otherwise the style is equal to the tag name.
|
| h3 | _h3 | style |
The h3 method does push the style named h1. We need a method instead of plain
style conversion by XSL, because the newline transformation needs to recognize the tag. The optional style
attribute can define the style name used. Otherwise the style is equal to the tag name.
|
| h4 | _h4 | style |
The h4 method does push the style named h1. We need a method instead of plain
style conversion by XSL, because the newline transformation needs to recognize the tag. The optional style
attribute can define the style name used. Otherwise the style is equal to the tag name.
|
| image | border height image show src style width |
The image methods build an image reference inside the galley. The image behaves like a “big” character inside a textline.
The width and height attributes are interpreted as relative values in the context of the running style.
The style value self.STYLESLICEABLE is set to the maximum of the image height and the running style value
of self.STYLESLICEABLE. The created GalleyImage instance is answered. If neither of the src or image is defined, then ignore the call. If the method is not called from XSL, it may be useful to supply the optional image as GalleyImageM instance, if the image size must be adjusted before adding it to the galley. If the show attribute is False (default True), then ignore the tag. |
|
| inlinecaption | _inlinecaption | style |
The inlinecaption method does push the style named inlinecaption. We need a method instead of plain
style conversion by XSL, because the newline transformation needs to recognize the tag. The optional style
attribute can define the style name used. Otherwise the style is equal to the tag name.
|
| marker | name needsnewpage style type |
The XSL marker method creates the instance of a GalleyMarker in a galley that can
be interpreted during page composition. Markers are not supposed to generate any output on the page with
the expose call. A marker does not contain a block, otherwise a group tag should be used.
The optional style attribute (that evaluates to a dictionary by XSL) can be used as an overall style definition for the group. If the needsnewpage is set to True (probably by a <newpage> tag, then this will initiate a newpage event during proof composition. |
|
| movecursor | dx dy |
The movecursor method moves the builder cursor over dx and dy.
|
|
| newgalley | style |
The newgalley method answers a new instance of Galley as root for a new galley.
Implementing this as a separate method, allows an inheriting application class to answer a different class
as galley root. The style attribute defines the initial style of the galley.
|
|
| newgroup | style |
The newgroup method answers a new instance of GalleyGroup.
|
|
| newhyphenator |
The newhyphenator method answers an instance of the hyphenator to be used for hyphenation.
Default behaviour is to answer an instance of xpyth.xierpa.imaging.hyphenator.HyphenatorDatabase
(which works assumes the database/table xierpa.hyphenatedxx to exist (where the 'xx'
is the defined language code). An alternative is the xpyth.xierpa.imaging.hyphenator.Hyphenator
class that works with the standard plist of word. The application base xpyth.xierpa.applications.hyphenationeditor.HyphenationEditor works on the xierpa.hyphenatedxx database. |
||
| newmarker | style |
The newmarker method answers a new instance of GalleyMarker.
|
|
| nonetag |
The nonetag method is a place holder in case we need a tag that does not display on the output.
This is used in the <newpage/> tag, if it is on the start of a new part. This is kinda hack to
force a non-empty proof here. The period is very small and white.
|
||
| orderedlist | _orderedlist | start style type |
The XSL orderedlist method is called by XSL to initialize the behaviour of an ordered list.
The optional type attribute can hold one of 1, 'a' to make it a numbered list.
Any other content of the type attribute will be used as bullet. If type is not defined,
then call self.getlistbullet() to get the bullet character. Typically this will return self.get(self.STYLELISTBULLET).
|
| orderedlistitem | _orderedlistitem | style |
The XSL orderedlistitem method is called by XSL to show the bullet line of the orderedlist.
If self.get(self.STYLERIGHTBULLETINDENT) is not None and there is a numeric bullet, then
position the bullet right aligned at this position, counting from the position of the first indent. If it is a numbered list, then the increment is defined by the result ofself.getnextbullet(). |
| p | _p |
The XSL em method handles the callback from the <em> tag. The style named 'em' is used.
|
|
| para | cnt code leading |
The XSL para method handles the callback from the <para/> and <br/> tags.
The cnt attribute defines the number of newlines. Default value is 1.
If the self.getrequiredleading() answers a value different larger than the current leading,
this value is built up by other objects on the same line. In that case the first line is using that value
as leading by calling the method recursively. The optional code attribute is the tag coding from XSL why the cnt amount of para’s was defined. The attribute is for debugging purposes only. If the optional leading attribute is defined, then use that value instead of the result of self.getleading(). If leading attribute equals 0, then replace this to the tiny movement 0.000000001 to make sure that the proof orders the lines right. I am not sure yet if this is a hack or a feature. |
|
| preparexml2xsl | xml |
The preparexml2xsl method optionally translate an XML source to translatable XSL source. The
default behaviour is just to unicodify the string. To be redefined by inheriting application classes if needed.
The output of the method must be a valid unicode XML string. To make sure that words are parsed including softhyphen, we do an overall replace of <shy/> and |
|
| ruler | |||
| setcursor | x y |
The setcursor method sets the builder cursor to x and y.
If a value is None then the value remains untouched.
|
|
| setgalley | galley |
The setgalley method set the running galley to galley.
|
|
| setparagraphstart | value |
The setparagraphstart method marks that we started a new paragraph. The values self._paragraphstart
and self._linestart are set to True, mainly by the <para> tag and on initialization of the
galley builder. These values are respectively used to handle the first indent and to omit the output of any whitespace preceding
a new line of text.
|
|
| setrequiredleading | leading |
The setrequiredleading method sets the required leading, that holds the maximum leading value on a
line.
|
|
| style | _style | name |
The XSL style method handles the callback from the <style> tag or any tag that has no template definition
in the current XSL file. Any output should be performed on the self.getgalley() galley that is available at this point.
|
| tab |
The tab method makes the self._cursorx jump to the next available tab value
|
||
| tailhook | text |
The tailhook method is called by XSL for every tail text of a tag block. Remove all white space
from the text before using it.
|
|
| text | text |
The text method of the builder does that actual typesetting of the text nodes. It breaks the string
text into separate GalleyText instances and add them to the running galley. The method
builds the current cascading style for the typographic settings and also passes it to the created textnodes.
Note that since the same style is passed to all nodes it is still efficient, allthough the resulting style
self.getcascadedstyle() includes all the values. If hyphenating, the check if self.UNICODE_SHY “soft-hyphen” is in the word. Then split on these soft-hyphens. Otherwise try to hyphenate the word from the dictionary of the current language. The self.UNICODE_NBSP is considered to be part of the hyphenating word. |
|
| texthook | text |
The texthook method is called by XSL for every block of text. Remove all white space from the
text before using it.
|
|
| tocline | pagenumber style title |
The XSL tocline method is called as a result of toc XML that is generated by the page builder.
The lines of the toc have the XML layout:
<toc> <tocline><title>Title</title><style>h1</style><pagenumber>2</pagenumber></tocline> ... </toc> The method builds the layout of the toc. If another layout is requested, then the method can be redefined by the inheriting application class. The style, pagenumber and title represent the value from the XML tocline. The style stylename is used to build the toc style name as 'toc' + style. The styles need to be defined by the application for the style/tag names that can be expected here. The method stores the last page number in self.tocline_pagenumber to avoid the showing of multiples of the same page number. |
|
| typeset | addheader addroot errormessage tailhook template texthook xml |
The typeset method takes a proof galley attribute and and an xml
attribute string. With XSLT (and the template with path self.get(self.STYLEXSLTEMPLATE) and root
tag self.get(self.STYLEGALLEYROOT)) the xml is typeset on the proof. If
there is an error in the transformation, then the content of errormessage the xml is
sent to the proof using the current style and 'red' as color, followed by the plain
text the xml. If the texthook attribute is defined, then call that method to output
the block text of a tag. Default value for the method is self.texthook. If the tailhook attribute is defined, then call that method to output the tail text of a tag. Default value for the method is self.tailhook. If the optional template attribute is defined, then this XSL path overrules the result of self.getxsltemplate(). |
|
| warning | text |
The warning method shows the warning in green.
|
StyleBuilder
| Open tag | Close tag | Attributes | Docstring or default value |
|---|---|---|---|
| addstyle | name style |
The addstyle adds the style under name to the local dictionary. If
style is a dictionary, then convert it into a style instance before adding it.
|
|
| get | default index name |
The get method answers the name style value of the current style, built from the
cascading value of stacked cascading styles. Recursively it will search for a value. If the value is a number
then answer is. If the value is a string and it starts with one of ['+', '-', '*'] or ends with
['%', 'em', 'u', 'c'] and has the rest of the string evaluate to a number, then evaluate the value
before answering it. If the value is list or tuple, then recursively render all its values and answer a new
list. Any other type of value (such as None and dictionaries) will be answered untouched.
|
|
| getcascadedstyle |
The getcascadedstyle method generates a merged Style instance from the stack of
cascading styles. This way the styles are not hierarchical for all galley nodes but contain the real values. The
style contains all the information that the node need to be exposed. It calls self.getrootstyle()
for the list of available style values.
|
||
| getdebugstyle |
The getdebugstyle method answers current debug style. The default behaviour is to answer
self.getstyle(self.DEBUGSTYLENAME) or self.getdefaultdebugstyle().
|
||
| getdefaultdebugstyle |
The getdefaultdebugstyle method answers the default debug style. Default behaviour is
to answer of self.getstyles()[self.DEFAULTDEBUGSTYLE].
|
||
| getdefaultstyle |
The getdefaultstyle method answers the default style. Default behaviour is
to answer self.getstyles()[self.DEFAULTSTYLE].
|
||
| getrootstyle |
The getrootstyle method answers the root (top) style of the style stack.
|
||
| getstyle | name |
The getstyle method answers a copy of the optional name style of the main pool of
style in self.getstyles() if it exists. Answer None otherwise. The copy is needed,
because in practice the usage of the style is such that application change in the them before applying them. If
the name attribute is None then answer a new empty Style instance.
|
|
| getstyles |
The getstyles method answers the main pool of defined styles. The default behaviour is to answer
self._styles.
|
||
| getstylestack |
The getstylestack method answers the stack of styles representing the current style state. The
default behaviour is to answer self._stylestack.
|
||
| item2style | style |
The item2style method answers a Style instance converted from the dictionary
style. Or if style is a string instance, then answer try to find the style with that
name and answer it. This method can be used to convert the dictionary style or style name from an XSL hook call into a real style instance. If d is not a dict or string instance, then it is ignored. |
|
| makestyle | style |
The makestyle method creates a new style and answers it.
The style attribute can be either a dictionary, a style name of a Style
instance (from self._styles).
|
|
| newstyle |
The newstyle method answers a Style instance with the **args as values.
If there is a stylename attribute defined, then use that to get the style with that name to start
with. If the style is not defined, the create an empty style before adding the **args values.
|
||
| popstyle |
The popstyle pops the current style and makes the next one on the style stack available.
|
||
| pushstyle | style |
The pushstyle method does push the named style on the stack of current cascading styles.
The style attribute can be either a dictionary, a style name of a Style
instance (from self._styles).
|
|
| pushstylevalue | name value |
The pushstylevalue method does push a new style that includes the single name and
value pair. The self.popstyle() call does remove the style from the
style stack.
|
|
| showdebug | s |
If self.SHOWSTYLE is set, then the showstyle method shows the s attribute
in the output, using the style self.getdebugstyle().
|
|
| showstyle |
If self.SHOWSTYLE is set, then the showstyle method shows the content of the current
style in the output using self.showdebug.
|
