def test_it(self):
        from sphinxjp.themes.revealjs import compat
        dummyself = self._get_dummy_self()
        dummynode = self._get_dummy_node()

        self._call_fut(dummyself, dummynode)
        assert [
            compat.text("<section id='id'>"),
            compat.text('<h1>title</h1>\n'),
            compat.text('<h2>subtitle</h2>\n')
        ] == dummyself.body.content
    def test_it(self):
        from sphinxjp.themes.revealjs import compat

        dummyself = self._get_dummy_self()
        dummynode = self._get_dummy_node()

        self._call_fut(dummyself, dummynode)
        assert [
            compat.text("<section id='id'>"),
            compat.text("<h1>title</h1>\n"),
            compat.text("<h2>subtitle</h2>\n"),
        ] == dummyself.body.content
    def test_markdown(self):
        from sphinxjp.themes.revealjs import compat
        dummyself = self._get_dummy_self()
        dummynode = self._get_dummy_node(**{"data-markdown": "hoge"})

        self._call_fut(dummyself, dummynode)
        assert ["<section data-markdown='hoge' id='id'>"] ==\
            dummyself.body.content

        dummyself = self._get_dummy_self()
        dummynode = self._get_dummy_node(**{"data-markdown": ""})

        self._call_fut(dummyself, dummynode)
        assert [
            compat.text("<section data-markdown='' id='id'>"),
            compat.text("<script type='text/template'>\n"),
            compat.text('# title \n'),
            compat.text('## subtitle \n'),
            compat.text('rawsource'),
            compat.text('</script>\n')
        ] == dummyself.body.content
    def test_markdown(self):
        from sphinxjp.themes.revealjs import compat

        dummyself = self._get_dummy_self()
        dummynode = self._get_dummy_node(**{"data-markdown": "hoge"})

        self._call_fut(dummyself, dummynode)
        assert ["<section data-markdown='hoge' id='id'>"] == dummyself.body.content

        dummyself = self._get_dummy_self()
        dummynode = self._get_dummy_node(**{"data-markdown": ""})

        self._call_fut(dummyself, dummynode)
        assert [
            compat.text("<section data-markdown='' id='id'>"),
            compat.text("<script type='text/template'>\n"),
            compat.text("# title \n"),
            compat.text("## subtitle \n"),
            compat.text("rawsource"),
            compat.text("</script>\n"),
        ] == dummyself.body.content
Пример #5
0
def visit_revealjs(self, node):
    """ build start tag for revealjs """
    section_attr = {}
    markdown_headings = {"h1": "#", "h2": "##", "h3": "###",
                         "h4": "####", "h5": "#####", "h6": "######"}

    if node.get("id"):
        section_attr.update({"ids": [node.get("id")]})

    attr_list = (
        'data-autoslide',
        'data-transition',
        'data-transition-speed',
        'data-background',
        'data-background-repeat',
        'data-background-size',
        'data-background-transition',
        'data-state',
        'data-markdown',
        'data-separator',
        'data-separator-vertical',
        'data-separator-notes',
        'data-charset',
    )
    for attr in attr_list:
        if node.get(attr) is not None:
            section_attr.update({attr: node.get(attr)})

    title = None
    if node.get("title") and not node.get('noheading'):
        title = node.get("title")

    title_heading = node.get('title-heading', 'h2')
    subtitle = node.get("subtitle")
    subtitle_heading = node.get('subtitle-heading', 'h3')
    if node.get("data-markdown") is not None:

        title_base = compat.text("%(heading)s %(title)s \n")
        title_text = None
        if title:
            title_text = title_base % dict(
                heading=markdown_headings.get(title_heading),
                title=title
            )

        subtitle_text = None
        if subtitle:
            subtitle_text = title_base % dict(
                heading=markdown_headings.get(subtitle_heading),
                title=subtitle
            )
    else:
        title_base = compat.text("<%(heading)s>%(title)s</%(heading)s>\n")
        title_text = None
        if title:
            title_text = title_base % dict(
                title=title,
                heading=title_heading)

        subtitle_text = None
        if subtitle:
            subtitle_text = title_base % dict(
                title=subtitle,
                heading=subtitle_heading)

    if node.get("data-markdown") is not None:
        self.body.append(self.starttag(node, 'section', **section_attr))
        if node.get("data-markdown") == compat.text(""):
            self.body.append("<script type='text/template'>\n")
            if title_text:
                self.body.append(title_text)
            if subtitle_text:
                self.body.append(subtitle_text)
            self.body.append(node.rawsource)
            self.body.append("</script>\n")
    else:
        self.body.append(self.starttag(node, 'section', **section_attr))
        if title_text:
            self.body.append(title_text)
        if subtitle_text:
            self.body.append(subtitle_text)
        self.set_first_last(node)
def visit_revealjs(self, node):
    """ build start tag for revealjs """
    section_attr = {}
    markdown_headings = {
        "h1": "#",
        "h2": "##",
        "h3": "###",
        "h4": "####",
        "h5": "#####",
        "h6": "######"
    }

    if node.get("id"):
        section_attr.update({"ids": [node.get("id")]})

    attr_list = (
        'data-autoslide',
        'data-transition',
        'data-transition-speed',
        'data-background',
        'data-background-repeat',
        'data-background-size',
        'data-background-transition',
        'data-state',
        'data-markdown',
        'data-separator',
        'data-separator-vertical',
        'data-separator-notes',
        'data-charset',
    )
    for attr in attr_list:
        if node.get(attr) is not None:
            section_attr.update({attr: node.get(attr)})

    title = None
    if node.get("title") and not node.get('noheading'):
        title = node.get("title")

    title_heading = node.get('title-heading', 'h2')
    subtitle = node.get("subtitle")
    subtitle_heading = node.get('subtitle-heading', 'h3')
    if node.get("data-markdown") is not None:

        title_base = compat.text("%(heading)s %(title)s \n")
        title_text = None
        if title:
            title_text = title_base % dict(
                heading=markdown_headings.get(title_heading), title=title)

        subtitle_text = None
        if subtitle:
            subtitle_text = title_base % dict(
                heading=markdown_headings.get(subtitle_heading),
                title=subtitle)
    else:
        title_base = compat.text("<%(heading)s>%(title)s</%(heading)s>\n")
        title_text = None
        if title:
            title_text = title_base % dict(title=title, heading=title_heading)

        subtitle_text = None
        if subtitle:
            subtitle_text = title_base % dict(title=subtitle,
                                              heading=subtitle_heading)

    if node.get("data-markdown") is not None:
        self.body.append(self.starttag(node, 'section', **section_attr))
        if node.get("data-markdown") == compat.text(""):
            self.body.append("<script type='text/template'>\n")
            if title_text:
                self.body.append(title_text)
            if subtitle_text:
                self.body.append(subtitle_text)
            self.body.append(node.rawsource)
            self.body.append("</script>\n")
    else:
        self.body.append(self.starttag(node, 'section', **section_attr))
        if title_text:
            self.body.append(title_text)
        if subtitle_text:
            self.body.append(subtitle_text)
        self.set_first_last(node)