Emacs's auto-fill mode splits the line to make the document look nice. I need to join the strings read from the document.
For example, (CR is the carriage return, not the real character)
- Blah, Blah, and (CR) Blah, Blah, Blah, (CR) Blah, Blah (CR) - A, B, C (CR) Blah, Blah, Blah, (CR) Blah, Blah (CR)
is read into string buffer array with readlines() function to produce
["Blah, Blah, and Blah, Blah, Blah, Blah, Blah", "A, B, C Blah, Blah, Blah, Blah, Blah"]
I thought about having loop to check '-' to concatenate all the stored strings before it, but I expect Python has efficient way to do this.
ADDED:
Based on kindall's code, I could get what I want as follows.
lines = ["- We shift our gears toward nextGen effort"," contribute the work with nextGen."]
out = [(" " if line.startswith(" ") else "\n") + line.strip() for line in lines]
print out
res = ''.join(out).split('\n')[1:]
print res
The result is as follows.
['\n- We shift our gears toward nextGen effort', ' contribute the work with nextGen.'] ['- We shift our gears toward nextGen effort contribute the work with nextGen.']