1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
#!python3
import textwrap
from itertools import chain
def getParagraph (sText):
"generator: returns paragraphs of text"
iStart = 0
iEnd = sText.find("\n", iStart)
while iEnd != -1:
yield sText[iStart:iEnd]
iStart = iEnd + 1
iEnd = sText.find("\n", iStart)
yield sText[iStart:]
|
>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
#!python3
import textwrap
from itertools import chain
def getParagraph (sText):
"generator: returns paragraphs of text"
iStart = 0
sText = sText.replace("\r\n", "\n").replace("\r", "\n")
iEnd = sText.find("\n", iStart)
while iEnd != -1:
yield sText[iStart:iEnd]
iStart = iEnd + 1
iEnd = sText.find("\n", iStart)
yield sText[iStart:]
|