示例#1
0
    def export_document(self, document):
        tag = HtmlTag('document')
        if not 'footnotes' in dir(
                self
        ):  #plik parsowany jest dwukrotnie (parz first_pass w base.py)
            self.footnotes = {
            }  #przed drugim przejściem nie chcemy stracić wyników

        if not 'endnotes' in dir(self):
            self.endnotes = {}

        results = super(PyDocXHTMLExporter, self).export_document(document)
        sequence = []
        #head = self.head()
        #if head is not None:
        #  sequence.append(head)
        if len(self.footnotes) > 0:
            sequence.append(self.export_footnote_texts())

        if len(self.endnotes) > 0:
            sequence.append(self.export_endnote_texts())

        if results is not None:
            sequence.append(results)

        return tag.apply(chain(*sequence))
示例#2
0
文件: doc.py 项目: leedarHawk/laoqi
    def style(self):
        styles = {
            'body': {
                'margin': '0px auto',
            },
            'img': {
                'width': '100%',
                'height': 'auto'
            }
        }

        if self.page_width:
            width = self.page_width / constants.POINTS_PER_EM
            styles['body']['width'] = '%.2fem' % width

        result = []
        for name, definition in sorted(constants.PYDOCX_STYLES.items()):
            result.append('.pydocx-%s {%s}' % (
                name,
                convert_dictionary_to_style_fragment(definition),
            ))

        for name, definition in sorted(styles.items()):
            result.append('%s {%s}' % (
                name,
                convert_dictionary_to_style_fragment(definition),
            ))

        tag = HtmlTag('style')
        return tag.apply(''.join(result))
示例#3
0
 def export_numbering_span(self, numbering_span):
     results = super(PyDocXHTMLExporter,
                     self).export_numbering_span(numbering_span)
     attrs = {}
     tag_name = 'ul'
     if not numbering_span.numbering_level.is_bullet_format():
         attrs[
             'list-style-type'] = numbering_span.numbering_level.num_format
         tag_name = 'ol'
     tag = HtmlTag(tag_name, **attrs)
     return tag.apply(results)
示例#4
0
    def export_bookmark(self, bookmark):
        # Check if this method is implement in parent classes
        results = getattr(super, 'export_bookmark', None)

        attrs = {}

        bookmark_name = self.get_bookmark_name(bookmark)

        if bookmark_name:
            attrs['id'] = bookmark_name

            tag = HtmlTag('a', **attrs)

            return tag.apply(results, allow_empty=True)
示例#5
0
    def export_textbox(self, textbox):
        results = super(PyDocXHTMLExporterNotesMixin, self).export_textbox(textbox)

        tag = HtmlTag(self.NOTES_WRAPPER_TAG_NAME, **self.get_textbox_attributes(textbox))

        return tag.apply(results)