Exemplo n.º 1
0
    def visit_slide(self, node):

        from hieroglyph import builder

        self.section_count += 1
        slide_level = node.attributes.get('level', self.section_level)

        if slide_level > self.builder.config.slide_levels:
            # dummy for matching div's
            self.body.append(
                self.starttag(
                    node, 'div', CLASS='section level-%s' % slide_level)
            )
            node.tag_name = 'div'
        else:
            slide_conf = slideconf.get_conf(self.builder, node.document)
            if (builder.building_slides(self.builder.app) and
                    slide_conf['autoslides'] and
                    isinstance(node.parent, nodes.section) and
                    not getattr(node.parent, 'closed', False)):

                # we're building slides and creating slides from
                # sections; close the previous section, if needed
                self.depart_slide(node.parent)

            node.closed = False
            self.body.append(
                self.starttag(
                    node, 'article',
                    CLASS='slide level-%s' % slide_level
                )
            )
            node.tag_name = 'article'
Exemplo n.º 2
0
    def apply(self, *args, **kwargs):

        from hieroglyph import builder

        app = self.document.settings.env.app
        is_slides = builder.building_slides(app)

        self.apply_to_document(self.document, env=self.document.settings.env, building_slides=is_slides)
Exemplo n.º 3
0
    def apply(self, *args, **kwargs):

        app = self.document.settings.env.app
        from hieroglyph import builder

        is_slides = builder.building_slides(app)

        for node in self.document.traverse(nextslide):
            self.visit_nextslide(node, is_slides)
Exemplo n.º 4
0
    def apply(self, *args, **kwargs):

        app = self.document.settings.env.app
        from hieroglyph import builder

        is_slides = builder.building_slides(app)

        for node in self.document.traverse(nextslide):
            self.visit_nextslide(node, is_slides)
Exemplo n.º 5
0
    def visit_slide(self, node):

        from hieroglyph import builder

        slide_level = node.attributes.get("level", self.section_level)

        if slide_level > self.builder.config.slide_levels:
            # dummy for matching div's
            self.body.append(self.starttag(node, "div", CLASS="section level-%s" % slide_level))
            node.tag_name = "div"
        else:

            slide_conf = slideconf.get_conf(self.builder, node.document)
            if (
                builder.building_slides(self.builder.app)
                and slide_conf["autoslides"]
                and isinstance(node.parent, nodes.section)
                and not getattr(node.parent, "closed", False)
            ):

                # we're building slides and creating slides from
                # sections; close the previous section, if needed
                self.depart_slide(node.parent)

            # don't increment section_count until we've (potentially)
            # closed the previous slide
            self.section_count += 1

            node.closed = False

            classes = node.get("classes")
            if not classes:
                classes = slide_conf["slide_classes"]

            # self.body.append(
            #     self.starttag(
            #         node, 'article',
            #         CLASS='%s slide level-%s' % (
            #             ' '.join(classes),
            #             slide_level,
            #         ),
            #     )
            # )
            node.tag_name = "article"

            slide_id = node.get("ids")
            if slide_id:
                slide_id = slide_id[0]
            else:
                slide_id = ""

            assert self.current_slide is None
            self.current_slide = SlideData(
                self, id=slide_id, level=slide_level, classes=classes, slide_number=self.section_count
            )
            self.push_body()
Exemplo n.º 6
0
def process_slideconf_nodes(app, doctree, docname):

    from hieroglyph import builder

    is_slides = builder.building_slides(app)

    # if autoslides is disabled and we're building slides,
    # replace the document tree with only explicit slide nodes
    if is_slides and not slideconf.get_conf(app.builder, doctree)['autoslides']:
        filter_doctree_for_slides(doctree)
Exemplo n.º 7
0
def process_slideconf_nodes(app, doctree, docname):

    from hieroglyph import builder

    is_slides = builder.building_slides(app)

    # if autoslides is disabled and we're building slides,
    # replace the document tree with only explicit slide nodes
    if (is_slides
            and not slideconf.get_conf(app.builder, doctree)['autoslides']):
        filter_doctree_for_slides(doctree)
Exemplo n.º 8
0
def process_slideconf_nodes(app, doctree, docname):

    from hieroglyph import builder

    is_slides = builder.building_slides(app)

    # if autoslides is disabled and we're building slides,
    # replace the document tree with only explicit slide nodes
    if is_slides and not slideconf.get_conf(app.builder, doctree)["autoslides"]:

        for child in doctree.children:
            child.replace_self(child.traverse(no_autoslides_filter))
Exemplo n.º 9
0
def process_slide_nodes(app, doctree, docname):

    from hieroglyph import builder

    supports_slide_nodes = builder.building_slides(app) or isinstance(app.builder, builder.AbstractInlineSlideBuilder)

    if supports_slide_nodes:
        return

    # this builder does not understand slide nodes; remove them
    for node in doctree.traverse(slide):
        node.replace_self(nodes.inline())
Exemplo n.º 10
0
    def apply(self, *args, **kwargs):

        app = self.document.settings.env.app

        from hieroglyph import builder

        is_slides = builder.building_slides(app)

        return self.apply_to_document(
            self.document,
            env=self.document.settings.env,
            building_slides=is_slides,
        )
Exemplo n.º 11
0
def process_slideconf_nodes(app, doctree, docname):

    from hieroglyph import builder

    is_slides = builder.building_slides(app)

    if is_slides:
        return

    # if we're not building slides, remove slideconf
    for node in doctree.traverse(slideconf):

        node.replace_self([])
Exemplo n.º 12
0
def process_slidecond_nodes(app, doctree, docname):

    from hieroglyph import builder

    is_slides = builder.building_slides(app)

    # this is a slide builder, remove notslides nodes
    for node in doctree.traverse(if_slides):

        keep_content = is_slides == node.attributes.get('ifslides', False)

        if keep_content:
            node.replace_self(node.children)
        else:
            node.replace_self([])
Exemplo n.º 13
0
def process_slide_nodes(app, doctree, docname):

    from hieroglyph import builder

    is_slides = builder.building_slides(app)

    # this is a slide builder, remove notslides nodes
    for node in doctree.traverse(slides):

        keep_content = is_slides == node.slides

        if keep_content:
            node.replace_self(node.children)
        else:
            node.replace_self([])
Exemplo n.º 14
0
def process_slidecond_nodes(app, doctree, docname):

    from hieroglyph import builder

    is_slides = builder.building_slides(app)

    # this is a slide builder, remove notslides nodes
    for node in doctree.traverse(if_slides):

        keep_content = is_slides == node.attributes.get('ifslides', False)

        if keep_content:
            node.replace_self(node.children)
        else:
            node.replace_self([])
Exemplo n.º 15
0
    def apply(self, *args, **kwargs):

        app = self.document.settings.env.app
        from hieroglyph import builder

        is_slides = builder.building_slides(app)

        # this is a slide builder, remove notslides nodes
        for node in self.document.traverse(if_slides):

            keep_content = is_slides == node.attributes.get('ifslides', False)

            if keep_content:
                node.replace_self(node.children)
            else:
                node.replace_self([])
Exemplo n.º 16
0
def process_slide_nodes(app, doctree, docname):

    from hieroglyph import builder

    supports_slide_nodes = (builder.building_slides(app) or isinstance(
        app.builder, builder.AbstractInlineSlideBuilder))

    if supports_slide_nodes:
        return

    # this builder does not understand slide nodes; remove them
    for node in doctree.traverse(slide):
        if node.attributes.get('inline-contents', False):
            node.replace_self(node.children[1:])
        else:
            node.replace_self(nodes.inline())
Exemplo n.º 17
0
    def apply(self, *args, **kwargs):

        app = self.document.settings.env.app
        from hieroglyph import builder

        is_slides = builder.building_slides(app)

        # this is a slide builder, remove notslides nodes
        for node in self.document.traverse(if_slides):

            keep_content = is_slides == node.attributes.get('ifslides', False)

            if keep_content:
                node.replace_self(node.children)
            else:
                node.replace_self([])
Exemplo n.º 18
0
def get_pages(app):

    if building_slides(app):

        # include the slide console
        context = __fix_context(app.builder.globalcontext.copy())
        context['css_files'].append('_static/console.css')
        context['script_files'].append('_static/common.js')
        context['script_files'].append('_static/console.js')
        context['title'] = 'Presenter Console'

        return [
            ('console', context, 'console.html',),
        ]

    return []
Exemplo n.º 19
0
def slide_context(app, pagename, templatename, context, doctree):
    """Update the context when building Slides."""

    if building_slides(app):

        # make a copy so we don't pollute the shared context
        context = __fix_context(context)

        if pagename not in EXTRA_PAGES:

            context['script_files'].append('_static/common.js')
            context['script_files'].append('_static/slides.js')
            context['script_files'].append('_static/sync.js')
            context['script_files'].append('_static/controller.js')
            context['script_files'].append('_static/init.js')

    return context
Exemplo n.º 20
0
def slide_context(app, pagename, templatename, context, doctree):
    """Update the context when building Slides."""

    if building_slides(app):

        # make a copy so we don't pollute the shared context
        context = __fix_context(context)

        if pagename not in EXTRA_PAGES:

            context['script_files'].append('_static/common.js')
            context['script_files'].append('_static/slides.js')
            context['script_files'].append('_static/sync.js')
            context['script_files'].append('_static/controller.js')
            context['script_files'].append('_static/init.js')

    return context
Exemplo n.º 21
0
def process_slide_nodes(app, doctree, docname):

    from hieroglyph import builder

    supports_slide_nodes = (
        builder.building_slides(app) or
        isinstance(app.builder, builder.AbstractInlineSlideBuilder)
    )

    if supports_slide_nodes:
        return

    # this builder does not understand slide nodes; remove them
    for node in doctree.traverse(slide):
        if node.attributes.get('inline-contents', False):
            node.replace_self(node.children[1:])
        else:
            node.replace_self(nodes.inline())
Exemplo n.º 22
0
    def visit_slide(self, node):

        from hieroglyph import builder

        slide_level = node.attributes.get('level', self.section_level)

        if slide_level > self.builder.config.slide_levels:
            # dummy for matching div's
            self.body.append(
                self.starttag(node,
                              'div',
                              CLASS='section level-%s' % slide_level))
            node.tag_name = 'div'
        else:
            slide_conf = slideconf.get_conf(self.builder, node.document)
            if (builder.building_slides(self.builder.app)
                    and slide_conf['autoslides']
                    and isinstance(node.parent, nodes.section)
                    and not getattr(node.parent, 'closed', False)):

                # we're building slides and creating slides from
                # sections; close the previous section, if needed
                self.depart_slide(node.parent)

            # don't increment section_count until we've (potentially)
            # closed the previous slide
            self.section_count += 1

            node.closed = False

            classes = []
            if not node.get('classes'):
                classes = slide_conf['slide_classes']

            self.body.append(
                self.starttag(
                    node,
                    'article',
                    CLASS='%s slide level-%s' % (
                        ' '.join(classes),
                        slide_level,
                    ),
                ))
            node.tag_name = 'article'
Exemplo n.º 23
0
def get_pages(app):

    if building_slides(app):

        # include the slide console
        context = __fix_context(app.builder.globalcontext.copy())
        context['css_files'].append('_static/console.css')
        context['script_files'].append('_static/common.js')
        context['script_files'].append('_static/console.js')
        context['title'] = 'Presenter Console'

        return [
            (
                'console',
                context,
                'console.html',
            ),
        ]

    return []
Exemplo n.º 24
0
    def visit_slide(self, node):

        from hieroglyph import builder

        slide_level = node.attributes.get("level", self.section_level)

        if slide_level > self.builder.config.slide_levels:
            # dummy for matching div's
            self.body.append(self.starttag(node, "div", CLASS="section level-%s" % slide_level))
            node.tag_name = "div"
        else:
            slide_conf = slideconf.get_conf(self.builder, node.document)
            if (
                builder.building_slides(self.builder.app)
                and slide_conf["autoslides"]
                and isinstance(node.parent, nodes.section)
                and not getattr(node.parent, "closed", False)
            ):

                # we're building slides and creating slides from
                # sections; close the previous section, if needed
                self.depart_slide(node.parent)

            # don't increment section_count until we've (potentially)
            # closed the previous slide
            self.section_count += 1

            node.closed = False

            classes = []
            if not node.get("classes"):
                classes = slide_conf["slide_classes"]

            self.body.append(
                self.starttag(node, "article", CLASS="%s slide level-%s" % (" ".join(classes), slide_level))
            )
            node.tag_name = "article"
Exemplo n.º 25
0
    def visit_slide(self, node):

        from hieroglyph import builder

        slide_level = node.attributes.get('level', self.section_level)

        if slide_level > self.builder.config.slide_levels:
            # dummy for matching div's
            self.body.append(
                self.starttag(node,
                              'div',
                              CLASS='section level-%s' % slide_level))
            node.tag_name = 'div'
        else:

            slide_conf = slideconf.get_conf(self.builder, node.document)
            if (builder.building_slides(self.builder.app)
                    and slide_conf['autoslides']
                    and isinstance(node.parent, nodes.section)
                    and not getattr(node.parent, 'closed', False)):

                # we're building slides and creating slides from
                # sections; close the previous section, if needed
                self.depart_slide(node.parent)

            # don't increment section_count until we've (potentially)
            # closed the previous slide
            self.section_count += 1

            node.closed = False

            classes = node.get('classes')
            if not classes:
                classes = slide_conf['slide_classes']

            # self.body.append(
            #     self.starttag(
            #         node, 'article',
            #         CLASS='%s slide level-%s' % (
            #             ' '.join(classes),
            #             slide_level,
            #         ),
            #     )
            # )
            node.tag_name = 'article'

            slide_id = node.get('ids')
            if slide_id:
                slide_id = slide_id[0]
            else:
                slide_id = ''

            continue_tag = node.get('continue_tag')
            if not continue_tag:
                continue_tag = ''

            assert self.current_slide is None
            self.current_slide = SlideData(
                self,
                id=slide_id,
                level=slide_level,
                classes=classes,
                slide_number=self.section_count,
                continue_tag=continue_tag,
            )
            self.push_body()