File size: 1,301 Bytes
a99c2b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import mistune
from mistune.plugins.table import table
import re


def md_to_html(md_text):
    renderer = mistune.HTMLRenderer()
    markdown_renderer = mistune.Markdown(renderer, plugins=[table])
    html_content = markdown_renderer(md_text)

    top = """<!DOCTYPE html>

  <html lang="en">

  <head>

      <meta charset="UTF-8">

      <meta name="viewport" content="width=device-width, initial-scale=1.0">

  </head>

  <style>

      /* Add your Streamlit-like CSS styles here */

      body {

          font-family: Arial, sans-serif;

          line-height: 1.6;

          padding: 20px;

          background-color: #f0f2f6;

          color: #262730;

      }

      h1, h2, h3 {

          color: #262730;

          margin-bottom: 20px;

      }

      table {

          width: 100%;

          border-collapse: collapse;

          margin-bottom: 20px;

      }

      th, td {

          padding: 10px;

          text-align: left;

          border-bottom: 1px solid #ddd;

      }

      th {

          background-color: #f2f2f2;

      }

      tr:nth-child(even) {

          background-color: #f2f2f2;

      }

  </style>

  <body>"""

    bottom = """</body>

    </html>"""

    html_report = top+html_content+bottom

    return html_report.replace('\n', '')