def to_md(journal):
 out = []
 (year, month) = ((-1), (-1))
 for e in journal.entries:
  if (not (e.date.year == year)):
   year = e.date.year
   out.append(str(year))
   out.append(((u'=' * len(str(year))) + u'\n'))
  if (not (e.date.month == month)):
   month = e.date.month
   out.append(e.date.strftime(u'%B'))
   out.append(((u'-' * len(e.date.strftime(u'%B'))) + u'\n'))
  out.append(e.to_md())
 result = u'\n'.join(out)
 return result

def to_md ( journal ) : out = [ ] ( year , month ) = ( ( - 1 ) , ( - 1 ) ) for e in journal . entries : if ( not ( e . date . year == year ) ) : year = e . date . year out . append ( str ( year ) ) out . append ( ( ( u'=' * len ( str ( year ) ) ) + u'\n' ) ) if ( not ( e . date . month == month ) ) : month = e . date . month out . append ( e . date . strftime ( u'%B' ) ) out . append ( ( ( u'-' * len ( e . date . strftime ( u'%B' ) ) ) + u'\n' ) ) out . append ( e . to_md ( ) ) result = u'\n' . join ( out ) return result
returns a markdown representation of the journal .