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

Method node_div

Lib/pagebot/base/typesetter.py:255–287  ·  view source on GitHub ↗

MarkDown generates ... and ... as output at the end of the HTML export. We will handle them separately by looking them up in the XML-tree. So we'll skip them in the regular flow process.

(self, node, e)

Source from the content-addressed store, hash-verified

253 self.typesetNode(node, e)
254
255 def node_div(self, node, e):
256 """MarkDown generates <div class="footnote">...</div> and <div
257 class="literature">...</div> as output at the end of the HTML export.
258 We will handle them separately by looking them up in the XML-tree. So
259 we&#x27;ll skip them in the regular flow process."""
260
261 if node.attrib.get('class') == 'footnote':
262 # Find the content of the footnotes. Store the content and add marker.
263 footnotes = self.getFootnotes(e)
264 if footnotes is not None:
265 for index, p in enumerate(node.findall('./ol/li/p')):
266 if index+1 in footnotes:
267 # Store the content as node, so we can process it with a Typesetter in case of child nodes.
268 footnotes[index+1]['p'] = p
269 else:
270 print('### Warning: %d footnote reference not found. %s' % (index+1, footnotes.keys()))
271 result = None # Nothing to return, we handled the references
272
273 elif node.attrib.get('class') == 'literature':
274 literatureRefs = self.getLiteratureRefs(e)
275 if literatureRefs:
276 for index, p in enumerate(node.findall('./ol/li/p')):
277 if index+1 in literatureRefs:
278 # Store the content as node, so we can process it with
279 # a Typesetter in case of child nodes. Splitting fields
280 # inside the `p` content will be done by the calling
281 # application or Composer.
282 literatureRefs[index+1]['p'] = p
283 else:
284 print('### Warning: %d literature reference not found. %s' % (index+1, literatureRefs.keys()))
285
286 else:
287 self.typesetNode(node, e)
288
289 def node_ul(self, node, e):
290 context = self.galley.context

Callers

nothing calls this directly

Calls 5

getFootnotesMethod · 0.95
getLiteratureRefsMethod · 0.95
typesetNodeMethod · 0.95
getMethod · 0.45
keysMethod · 0.45

Tested by

no test coverage detected