summaryrefslogtreecommitdiff
path: root/FBGM.py
diff options
context:
space:
mode:
Diffstat (limited to 'FBGM.py')
-rw-r--r--FBGM.py33
1 files changed, 20 insertions, 13 deletions
diff --git a/FBGM.py b/FBGM.py
index 92c9772..150b9d1 100644
--- a/FBGM.py
+++ b/FBGM.py
@@ -3,19 +3,23 @@ import os, sys
def paragraph_parser(contents):
paragraph_end = [".\n", "?\n", "!\n", '"\n', "|*E"]
+ article_end = '\n'
paragraph_index = [0]
paragraph_number = 1
paragraph = []
x = 0
- count = 0
- contents=contents.rstrip()
- contents+="|*END"
+ paragraph_count = 0
+ article_count = 0
+ contents=contents.strip()
+ contents+="|*E"
while x in range (len(paragraph_end)):
if contents.find(paragraph_end[x]) == -1:
paragraph_end.pop(x)
else:
- count += contents.count(paragraph_end[x])
+ paragraph_count += contents.count(paragraph_end[x])
x += 1
+ article_count = contents.count(article_end)-paragraph_count
+
while paragraph_end:
minimum = contents[paragraph_index[paragraph_number-1]:].index(paragraph_end[0]) +paragraph_index[paragraph_number-1]
for x in paragraph_end:
@@ -27,9 +31,7 @@ def paragraph_parser(contents):
if contents[paragraph_index[paragraph_number]:].find(x) == -1:
paragraph_end.remove(x)
paragraph_number +=1
- print(len(paragraph_end))
- print(paragraph)
- return
+ return paragraph
@@ -41,8 +43,7 @@ def txthandler(path, htmlfile):
contents = f.read()
title = filename
main_header = contents[0:contents.find('\n')]
- paragraph_parser(contents)
-
+ paragraph = paragraph_parser(contents[contents.find('\n'):])
htmlfile.write('<!DOCTYPE html>'
'<html lang ="en">'
'<head>'
@@ -56,9 +57,15 @@ def txthandler(path, htmlfile):
'<article class="introduction">'
'<h2>&nbsp Introduction &nbsp</h2>'
'<p>''</p>'
- '</article>'
- '</body>'
-'</html>')
+ '</article>')
+ for x in paragraph:
+ htmlfile.write('<article class="bodyparagraph">' + x + '</article>')
+
+
+
+
+ htmlfile.write('</body>'
+ '</html>')
print(f.read())
return 0
@@ -76,7 +83,7 @@ def dochandler(path):
#Attempting to pass txt file in path
-path = 'C:/Users/Josh/Desktop/porkandbeans/texttohtml/memes.txt'
+path = 'C:/Users/a big fuck/Documents/beansandtoast.txt'
extension = path[path.rfind('.')+1: len(path)]