fix bold text

This commit is contained in:
iou1name 2022-09-01 12:41:22 -04:00
parent ff7bb5e3e8
commit 48a9242d89
2 changed files with 40 additions and 1 deletions

View File

@ -38,7 +38,26 @@ def scrape_posts(root_dir):
post_body = post.find(class_='postMessage') post_body = post.find(class_='postMessage')
for br in post_body.find_all('br'): for br in post_body.find_all('br'):
br.replace_with('\n') br.replace_with('\n')
post_body_txt = post_body.get_text() #post_body_txt = post_body.get_text()
post_body_txt = ''
for child in post_body.children:
if not child.name: # text element
post_body_txt += child.get_text()
elif child.name == 'b':
post_body_txt += '<b>' + child.get_text() + '</b>'
elif child.name == 'span' and child['class'][0] == 'mu-s':
post_body_txt += '<span class="bold">' + child.get_text() + '</span>'
elif child.name == 'span' and child['class'][0] == 'mu-i':
post_body_txt += '<span class="italic">' + child.get_text() + '</span>'
elif child.name == 'span' and child['class'][0] == 'mu-r':
post_body_txt += '<span class="red">' + child.get_text() + '</span>'
elif child.name == 'span' and child['class'][0] == 'mu-g':
post_body_txt += '<span class="green">' + child.get_text() + '</span>'
elif child.name == 'span' and child['class'][0] == 'mu-b':
post_body_txt += '<span class="blue">' + child.get_text() + '</span>'
else:
post_body_txt += child.get_text()
cur.execute( cur.execute(
"UPDATE post SET body = (%s) WHERE id = (%s)", "UPDATE post SET body = (%s) WHERE id = (%s)",

View File

@ -74,6 +74,26 @@ body {
text-decoration: line-through; text-decoration: line-through;
} }
.bold {
font-weight: bold;
}
.italic {
font-style: italic;
}
.red {
color: red;
}
.green {
color: green;
}
.blue {
color: blue;
}
#visibility_menu_toggle { #visibility_menu_toggle {
cursor: pointer cursor: pointer
} }