Quotes
\n\n' + '\n' + 'reStructuredText quotes are automatically converted\n' + '\n\n\n\n
diff --git a/src/hieroglyph/tests/test_translator.py b/src/hieroglyph/tests/test_translator.py
index 85e0329..71a2901 100644
--- a/src/hieroglyph/tests/test_translator.py
+++ b/src/hieroglyph/tests/test_translator.py
@@ -374,3 +374,68 @@ def test_rst_quote_makes_quote_slide(self):
'\n\n\n\n\n',
],
)
+
+ def test_unattributed_rst_quote_makes_quote_slide(self):
+ document = util.make_document(
+ 'quoted',
+ """\
+.. slide:: Quotes
+ :level: 2
+
+ reStructuredText quotes are automatically converted
+
+""",
+ )
+ translator = SlideTranslator(
+ self.builder,
+ document,
+ )
+
+ document.walkabout(translator)
+
+ self.assertEqual(
+ translator.body,
+ [
+ u'\n This text is over indented. As is this text. They look like quotes but they\'re not.Quotes
\n\n'
+ '\n'
+ 'reStructuredText quotes are automatically converted
\n'
+ '\n\n\n\nIndented RST
\n\n'
+ '\n'
+ '
\n'
+ '\n\n\n\n element
- p = node.children[0]
- if p.tagname != 'paragraph':
- raise ValueError("The first child of a quote must be a paragraph")
- self.body.append(self.starttag(node, 'q'))
- for text_item in p:
- text_item.walkabout(self)
- self.body.append('
\n')
-
- if len(node.children) > 2:
- raise ValueError("A quote can only have 2 children, the quote text"
- " and an attribution")
- # optional second child must be an attribution, processing as a
- if len(node.children) > 1: - attr = node.children[1] - if attr.tagname != 'attribution': - raise ValueError("The second child of a quote must be" - " an attribution") - - self.body.append(self.starttag(attr, 'div', CLASS="author")) - for text_item in attr: + quote_slide_tags = ['paragraph', 'attribution'] + + # see if this looks like a quote slide + if (len(node.children) <= 2 and + [c.tagname for c in node.children] == quote_slide_tags[:len(node.children)]): + + # process this as a quote slide + + # first child must be a paragraph, process it as aelement + p = node.children[0] + self.body.append(self.starttag(node, 'q')) + for text_item in p: text_item.walkabout(self) - self.body.append('
+ if len(node.children) > 1: + attr = node.children[1] + + self.body.append(self.starttag(attr, 'div', CLASS="author")) + for text_item in attr: + text_item.walkabout(self) + self.body.append('