summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsiddharth <rsd@gnu.org>2017-05-29 21:53:35 +0000
committerrsiddharth <rsd@gnu.org>2017-05-29 21:53:35 +0000
commit59b9d5c3c3ab0ef280e151dc21d201e911261ecc (patch)
tree938a85316086eb54056ece8469d6cfe80fd9056a
parentcab6a8877c4d56799e42aed7c90dd29c8ed66310 (diff)
lps_gen: Add LPSRenderer._check_session_title_exists.
* lps_gen.py (LPSRenderer._check_session_title_exists): New method. (LPSRenderer.header, LPSRenderer.paragraph): Update methods.
-rw-r--r--lps_gen.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/lps_gen.py b/lps_gen.py
index 74d34c0..42e36ff 100644
--- a/lps_gen.py
+++ b/lps_gen.py
@@ -326,6 +326,34 @@ class LPSRenderer(Renderer):
return False
+ def _check_session_title_exists(self):
+ """Checks if :py:attr:`.last_session` is set.
+
+ If :py:attr:`.last_session` is not set and first paragraph is
+ encountered, then it is assumed that the current timeslot is in
+ the following format::
+
+ ### 9:00 - 10:45: Opening Keynote - Beyond unfree...
+
+ [Cory Doctorow][doctorow]
+
+ Room 32-123
+
+ Software has eaten the world...
+
+ This method is meant to be called from the
+ :py:method:`.paragraph` method.
+ """
+ if not self.last_session and self.no_paragraph == 0:
+ # Current timeslot has only one session and there
+ # no session title.
+ #
+ # st-from-ts -> session title from time slot.
+ lps_dict[self.last_day][self.last_time_slot][
+ 'st-from-ts'] = OrderedDict()
+ self.last_session = 'st-from-ts'
+
+
def link(self, link, title, text):
# Here, we catch speaker names that have to be autolinked and
# autolink them if there is an id available for the speaker.
@@ -356,6 +384,10 @@ class LPSRenderer(Renderer):
# Add new timeslot
lps_dict[self.last_day][text] = OrderedDict()
self.last_time_slot = text
+ # New timeslot, reset paragraphs processed and
+ # last session.
+ self.no_paragraph = 0
+ self.last_session = None
elif level == 4:
# Add new session
lps_dict[self.last_day][self.last_time_slot][text] = OrderedDict()
@@ -370,6 +402,7 @@ class LPSRenderer(Renderer):
def paragraph(self, text):
global lps_dict
+ self._check_session_title_exists()
p = super(LPSRenderer, self).paragraph(text)
if self.no_paragraph == 0: