Browse Source

Updated code to work with code blocks when there are new lines in it.

pull/18/head
jrtechs 5 years ago
parent
commit
fe145214b1
1 changed files with 10 additions and 2 deletions
  1. +10
    -2
      other/markdownParagraphFormatter.py

+ 10
- 2
other/markdownParagraphFormatter.py View File

@ -70,15 +70,23 @@ def wrapMarkdownParagraphsToColLimit(fileName, charLimit):
""" """
result = "" result = ""
tempResult = "" tempResult = ""
inCodeBlock = False
with open(fileName) as file: with open(fileName) as file:
for line in file: for line in file:
if line.strip(" ") == "\n":
if line.startswith("```"):
inCodeBlock = not inCodeBlock
result = result + line
elif inCodeBlock:
result = result + line
elif line.strip(" ") == "\n":
result = result + formatChunk(tempResult, charLimit) result = result + formatChunk(tempResult, charLimit)
tempResult = "" tempResult = ""
result = result + "\n" result = result + "\n"
else: else:
tempResult = tempResult + line tempResult = tempResult + line
print(line)
if tempResult != "": if tempResult != "":
result = result + formatChunk(tempResult, charLimit) result = result + formatChunk(tempResult, charLimit)
return result return result

Loading…
Cancel
Save