src/cm/converters/pandoc_converters.py
changeset 459 a69421197502
parent 458 ba7e05582435
child 517 e7bc083fa9dc
equal deleted inserted replaced
458:ba7e05582435 459:a69421197502
   221     if from_format==to_format=='html':
   221     if from_format==to_format=='html':
   222       # get body content
   222       # get body content
   223       stdoutdata = (content.encode('utf8'))
   223       stdoutdata = (content.encode('utf8'))
   224       soup = BeautifulSoup(stdoutdata)
   224       soup = BeautifulSoup(stdoutdata)
   225       body = soup.body
   225       body = soup.body
   226       stdoutdata = body.renderContents()
   226       if body:
       
   227         stdoutdata = body.renderContents()
   227       # strip leading spaces
   228       # strip leading spaces
   228       stdoutdata = re.sub(r"^\s+", '', stdoutdata)
   229       stdoutdata = re.sub(r"^\s+", '', stdoutdata)
   229       # add new line before closing bracket
   230       # add new line before closing bracket
   230       stdoutdata = re.sub(r"(\/?)>", r"\n\1>", stdoutdata)
   231       stdoutdata = re.sub(r"(\/?)>", r"\n\1>", stdoutdata)
   231       # do not split closing tag with following opening tag
   232       # do not split closing tag with following opening tag