def gather_elements(self, client, node, style): if node['classes']: style = client.styles.combinedStyle(['code'] + node['classes']) else: style = client.styles['table'] return [Spacer(0, client.styles['table'].spaceBefore)] + \ client.gather_elements(node, style=style) +\ [Spacer(0, client.styles['table'].spaceAfter)]
def gather_elements(self, client, node, style): if isinstance(node.parent, docutils.nodes.line_block): qstyle = copy(style) qstyle.leftIndent += client.styles.adjustUnits("1.5em") else: qstyle = copy(client.styles['lineblock']) # Fix Issue 225: no space betwen line in a lineblock, but keep # space before the lineblock itself return [Spacer(0, client.styles['lineblock'].spaceBefore) ] + client.gather_elements(node, style=qstyle) + [ Spacer(0, client.styles['lineblock'].spaceAfter) ]
def gather_elements(self, client, node, style): st = client.styles[node['desctype']] if st == client.styles['normal']: st = copy(client.styles['desc']) st.spaceBefore = 0 pre = [Spacer(0, client.styles['desc'].spaceBefore)] return pre + client.gather_elements(node, st)
def gather_elements(self, client, node, style): # It seems a footnote contains a label and a series of elements ltext = client.gather_pdftext(node.children[0]) if len(node['backrefs']) > 1 and client.footnote_backlinks: backrefs = [] i = 1 for r in node['backrefs']: backrefs.append('<a href="#%s" color="%s">%d</a>' % (r, client.styles.linkColor, i)) i += 1 backrefs = '(%s)' % ', '.join(backrefs) if ltext not in client.targets: label = Paragraph( '<a name="%s"/>%s' % (ltext, ltext + backrefs), client.styles["normal"]) client.targets.append(ltext) elif len(node['backrefs']) == 1 and client.footnote_backlinks: if ltext not in client.targets: label = Paragraph('<a name="%s"/>'\ '<a href="%s" color="%s">%s</a>' % ( ltext, node['backrefs'][0], client.styles.linkColor, ltext), client.styles["normal"]) client.targets.append(ltext) else: if ltext not in client.targets: label = Paragraph('<a name="%s"/>%s' % (ltext, ltext), client.styles["normal"]) client.targets.append(ltext) contents = client.gather_elements(node, style)[1:] if client.inline_footnotes: st = client.styles['endnote'] t_style = TableStyle(st.commands) colWidths = client.styles['endnote'].colWidths node.elements = [ Spacer(0, st.spaceBefore), DelayedTable([[label, contents]], style=t_style, colWidths=colWidths), Spacer(0, st.spaceAfter) ] else: client.decoration['endnotes'].append([label, contents]) node.elements = [] return node.elements
def gather_elements(self, client, node, style): if node['classes']: style = client.styles[node['classes'][0]] else: style = client.styles["item_list"] node.elements = client.gather_elements(node, style=style) # Here we need to separate the list from the previous element. # Calculate by how much: sb = style.spaceBefore # list separation sa = style.spaceAfter # list separation node.elements.insert(0, Spacer(0, sb)) node.elements.append(Spacer(0, sa)) return node.elements
def gather_elements(self, client, node, style): # This should work, but doesn't look good inside of # table cells (see Issue 173) #node.elements = [MyIndenter(left=client.styles['blockquote'].leftIndent)]\ #+ client.gather_elements( node, style) + \ #[MyIndenter(left=-client.styles['blockquote'].leftIndent)] # Workaround for Issue 173 using tables leftIndent = client.styles['blockquote'].leftIndent rightIndent = client.styles['blockquote'].rightIndent spaceBefore = client.styles['blockquote'].spaceBefore spaceAfter = client.styles['blockquote'].spaceAfter data = [['', client.gather_elements(node, style)]] if client.splittables: node.elements = [ Spacer(0, spaceBefore), SplitTable(data, colWidths=[leftIndent, None], style=TableStyle([ ["TOPPADDING", [0, 0], [-1, -1], 0], ["LEFTPADDING", [0, 0], [-1, -1], 0], ["RIGHTPADDING", [0, 0], [-1, -1], rightIndent], ["BOTTOMPADDING", [0, 0], [-1, -1], 0], ])), Spacer(0, spaceAfter) ] else: node.elements = [ Spacer(0, spaceBefore), DelayedTable( data, colWidths=[leftIndent, None], style=TableStyle([ ["TOPPADDING", [0, 0], [-1, -1], 0], ["LEFTPADDING", [0, 0], [-1, -1], 0], ["RIGHTPADDING", [0, 0], [-1, -1], rightIndent], ["BOTTOMPADDING", [0, 0], [-1, -1], 0], ])), Spacer(0, spaceAfter) ] return node.elements
def gather_elements(self, client, node, style): if node.children and isinstance(node.children[0], docutils.nodes.title): title = [] else: title = [ Paragraph(client.text_for_label(node.tagname, style), style=client.styles['%s-heading' % node.tagname]) ] rows = title + client.gather_elements(node, style=style) st = client.styles[node.tagname] if 'commands' in dir(st): t_style = TableStyle(st.commands) else: t_style = TableStyle() t_style.add("ROWBACKGROUNDS", [0, 0], [-1, -1], [st.backColor]) t_style.add("BOX", [0, 0], [-1, -1], st.borderWidth, st.borderColor) if client.splittables: node.elements = [ Spacer(0, st.spaceBefore), SplitTable([['', rows]], style=t_style, colWidths=[0, None], padding=st.borderPadding), Spacer(0, st.spaceAfter) ] else: padding, p1, p2, p3, p4 = tablepadding(padding=st.borderPadding) t_style.add(*p1) t_style.add(*p2) t_style.add(*p3) t_style.add(*p4) node.elements = [ Spacer(0, st.spaceBefore), DelayedTable([['', rows]], style=t_style, colWidths=[0, None]), Spacer(0, st.spaceAfter) ] return node.elements
def gather_elements(self, client, node, style): el = client.gather_elements(node, style=client.styles["bodytext"]) b, t = client.bullet_for_node(node) # FIXME: this is really really not good code if not el: el = [Paragraph(u"<nobr>\xa0</nobr>", client.styles["bodytext"])] bStyle = copy(style) bStyle.alignment = 2 # FIXME: use different unicode bullets depending on b if b and b in "*+-": b = getattr(bStyle, 'bulletText', u'\u2022') # The style has information about the bullet: # # bulletFontSize # bulletFont # This is so the baselines of the bullet and the text align extra_space = bStyle.bulletFontSize - bStyle.fontSize bStyle.fontSize = bStyle.bulletFontSize bStyle.fontName = bStyle.bulletFontName if t == 'bullet': item_st = client.styles['bullet_list_item'] else: item_st = client.styles['item_list_item'] idx = node.parent.children.index(node) if idx == 0: # The first item in the list, so doesn't need # separation (it's provided by the list itself) sb = 0 else: # Not the first item, so need to separate from # previous item. Account for space provided by # the item's content, too. sb = item_st.spaceBefore - style.spaceBefore if extra_space > 0: # The bullet is larger, move down the item text sb += extra_space sbb = 0 else: # The bullet is smaller, move down the bullet sbb = -extra_space bStyle.spaceBefore = 0 if (idx + 1) == len(node.parent.children): #Not the last item # The last item in the list, so doesn't need # separation (it's provided by the list itself) sa = 0 else: sa = item_st.spaceAfter - style.spaceAfter t_style = TableStyle(style.commands) #colWidths = map(client.styles.adjustUnits, #client.styles['item_list'].colWidths) colWidths = style.colWidths if client.splittables: node.elements = [ Spacer(0, sb), SplitTable([[Paragraph(b, style=bStyle), el]], style=t_style, colWidths=colWidths), Spacer(0, sa) ] else: node.elements = [ Spacer(0, sb), DelayedTable([[Paragraph(b, style=bStyle), el]], style=t_style, colWidths=colWidths), Spacer(0, sa) ] return node.elements
def gather_elements(self, client, node, style): return [Spacer(0,client.styles['field_list'].spaceBefore)]+\ client.gather_elements(node, style=style)