MCPcopy Create free account
hub / github.com/PageBot/PageBot / getNodeStyle

Method getNodeStyle

Lib/pagebot/base/typesetter.py:533–550  ·  view source on GitHub ↗

Makes a copy of the top of the style graphics state and mew *style* into it. Answer the new style. This can be used to match custom tag names (such as ... to a style with the same name.

(self, tag)

Source from the content-addressed store, hash-verified

531 return {}
532
533 def getNodeStyle(self, tag):
534 """Makes a copy of the top of the style graphics state and mew *style*
535 into it. Answer the new style. This can be used to match custom tag
536 names (such as <dropcap>...</dropcap> to a style with the same name.
537 """
538 if self.peekStyle() is None: # Not an initialized stack, use doc.rootStyle as default.
539 # Happens if calling directly, without check on e or non-existing style for a node.
540 self.pushStyle(self.getRootStyle())
541 mergedStyle = copy.copy(self.peekStyle())
542 # Find the best matching style for tag on order of relevance,
543 # considering the possible HTML tag parents and the history.
544 for styleName in self.getMatchingStyleNames(tag):
545 nodeStyle = self.getNamedStyle(styleName)
546 if nodeStyle: # Not None and not empty
547 for name, value in nodeStyle.items():
548 mergedStyle[name] = value
549 break
550 return mergedStyle
551
552 def append(self, bs):
553 """Append the string (or BabelString instance) to the last textbox in

Callers 1

typesetNodeMethod · 0.95

Calls 6

peekStyleMethod · 0.95
pushStyleMethod · 0.95
getRootStyleMethod · 0.95
getMatchingStyleNamesMethod · 0.95
getNamedStyleMethod · 0.95
copyMethod · 0.45

Tested by

no test coverage detected