diff --git a/pydown/pydown.py b/pydown/pydown.py index 11149556..f5b80c01 100755 --- a/pydown/pydown.py +++ b/pydown/pydown.py @@ -71,6 +71,8 @@ class DocInfo: mode = line continue if line.strip() == '': + if mode == 'code': + self.description += '```\n' mode = '' continue if mode == 'Parameters': @@ -84,9 +86,16 @@ class DocInfo: elif mode == 'Values': self.ProcessEnumValue(line) elif mode == '': + if re.match(r'^\s*>>>', line): + mode = 'code' + self.description += '```\n' + self.description += line + '\n' + elif mode == 'code': self.description += line + '\n' else: raise Exception('Unknown mode = "{}"'.format(mode)) + if mode == 'code': + self.description += '```\n' def ProcessEnumValue(self, line): m = re.match(r'^\s*([A-Za-z][A-Za-z0-9_]+)\s*:\s*(.*)$', line) diff --git a/source/python/README.md b/source/python/README.md index 1f493296..6b5a0d08 100644 --- a/source/python/README.md +++ b/source/python/README.md @@ -144,8 +144,10 @@ as seen by an observer on the surface of the Earth. **Finds the Body enumeration value, given the name of a body.** +``` >>> astronomy.BodyCode('Mars')