Browse Source

table fix

main
Cailean Finn 5 months ago
parent
commit
1ca7f9290e
  1. 17
      app.py
  2. BIN
      static/assets/images/favicon.png
  3. 2
      templates/base.html

17
app.py

@ -1,7 +1,7 @@
from flask import Flask, render_template, Response
import requests
import re
from bs4 import BeautifulSoup
from bs4 import BeautifulSoup, Comment
from datetime import datetime
from dateutil.relativedelta import relativedelta
@ -358,6 +358,21 @@ class WikiApp(Flask):
file_link.unwrap()
soup = self.remove_thumbnail_img(soup)
# Locate the table and the comment
table = soup.find('table')
# Remove inline styles by deleting the 'style' attribute
if table and 'style' in table.attrs:
del table['style']
# Add the class 'table-cont' to the table
if table:
table['class'] = table.get('class', []) + ['table-cont']
comments = soup.find_all(string=lambda text: isinstance(text, Comment))
comment = comments[-1] if comments else None
# Insert the table before the comment
if comment:
comment.insert_before(table.extract())
return soup.prettify()

BIN
static/assets/images/favicon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

2
templates/base.html

@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}{% endblock %}</title>
<link rel="stylesheet" href="{{ url_for('static', filename='assets/styles.css') }}">
<link rel="icon" type="image/x-icon" href="{{ url_for('static', filename='assets/images/favicon.ico') }}">
<link rel="icon" type="image/x-icon" href="{{ url_for('static', filename='assets/images/favicon.png') }}">
<body>
<div class='main-cont'>
<div class='nav-cont'>

Loading…
Cancel
Save