Skip to content

Commit

Permalink
Use render (themes/../slide.html) again. For slide_theme='slides' goo…
Browse files Browse the repository at this point in the history
…d slides are producted.

With H3 levels (even with slide_levels=2). This fixes nyergler#100
Have to test for other themes and more complex slides
Notice: the  slide-directive is not supported with this set-up
Some cleanup may be needed
  • Loading branch information
Albert Mietus authored and Albert Mietus committed Jul 15, 2015
1 parent a7d3904 commit 6524056
Showing 1 changed file with 19 additions and 32 deletions.
51 changes: 19 additions & 32 deletions src/hieroglyph/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@
from __future__ import print_function

from docutils import nodes
from sphinx.locale import _
from docutils.writers.html4css1 import HTMLTranslator as BaseTranslator
from sphinx.writers.html import HTMLTranslator

from hieroglyph import html
from hieroglyph.directives import (
slide,
slideconf,
)
from hieroglyph.directives import slideconf


import hack

Expand All @@ -32,7 +28,7 @@ def __init__(self, translator, **kwargs):
self.classes = []

# set after init (direct write)
self.title = ''
self.title = None
self.content = ''

# no other attr are used then above!
Expand Down Expand Up @@ -60,7 +56,7 @@ def _get_slide_context(self):
"""Return the context dict for rendering this slide."""

return {
'title': self.title,
'title': "" if self.title is None else self.title,
'level': self.level,
'content': self.content,
'classes': self.classes,
Expand Down Expand Up @@ -133,7 +129,7 @@ def slide_end(self, node): #GAM: renamed
self.pop_body()

slide = self.current_slide
slide.content = ''.join(slide_body) # OR copy the []??
slide.content = u''.join(slide_body)

rendered_slide = self.builder.templates.render('slide.html', slide._get_slide_context())
self.body.append(rendered_slide)
Expand All @@ -142,35 +138,26 @@ def slide_end(self, node): #GAM: renamed

@hack.TRACE
def visit_title(self, node):
HTMLTranslator.visit_title(self, node)

## self.push_body()
if (self.current_slide is not None) and (self.current_slide.title is None):
self.current_slide.title = node.astext().strip()
hack.show_body_stack(self, label="visit_title -> set current_slide.title")
raise nodes.SkipNode # will skip depart_title!
else:
HTMLTranslator.visit_title(self, node)

## if (isinstance(node.parent, slide) or node.parent.attributes.get('include-as-slide', False)):
## slide_level = node.parent.attributes.get('level', self.section_level)
## self.current_slide.level = max(slide_level + self.initial_header_level - 1, 1)

## if self.current_slide and isinstance(node.parent, (nodes.section, slide)):
## self.current_slide.title = node.astext().strip()
## else:
## HTMLTranslator.visit_title(self, node)

@hack.TRACE
def depart_title(self, node):
print("XXX", self.body)
def depart_title(self, node): # Not called when title of current_slide is set!
HTMLTranslator.depart_title(self, node)
print("XXX", self.body)
if self.current_slide and self.current_slide.title == None:
self.current_slide.title == "".join(self.body)

## title = self.body
## self.pop_body()

## if self.current_slide and isinstance(node.parent, (nodes.section, slide)):
## self.current_slide.title = ''.join(self.body)
## self.pop_body()

## self.current_slide.title = "".join(title)
## else:
## HTMLTranslator.depart_title(self, node)
## title = ''.join(self.body)
## self.pop_body()
## self.body.append(title)
## self.body.extend(title) # Nicer as `self.body.append("".join(title))`, but functionally the same


def visit_block_quote(self, node):
quote_slide_tags = ['paragraph', 'attribution']
Expand Down

0 comments on commit 6524056

Please sign in to comment.