text: from markdown import markdown
  
  #<tr>
  		#<th>Month</th>
  		#<th>Savings</th>
  		#<th>Spending</th>
  #</tr>
  def hyperlinks(line):
      start = line.find('[')
      end = line.find(']')
      startround = line.find('(', start)
      endround = line.find(')', startround)
      
      if start == -1 or end == -1 or startround == -1 or endround == -1:
          return line
      
      text = line[start+1:end]
      link = line[startround+1:endround]
      return '<p>' + line[:start] + '<a href="' + link + '">' + text + '</a>' + line[endround+1:] + '</p>\n'
  
  def table2html(table):
      if len(table) == 0:
          return ''
  
      html = '<table>\n'
      
      for row in table:
          if row.startswith('|:-:|'):
              continue
          html += '<tr>\n'
          for col in row.split('|'):
              html += '<th>' + hyperlinks(col) + '</th>\n'
          html += '</tr>\n'
      html += '</table>\n'
      return html
  
  if __name__ == '__main__':
      fullhtml = '<!DOCTYPE html>\n' \
                 '<html>\n' \
                 '<head>\n' \
                 '<title>Jakob Jung</title>\n' \
                 '<link rel="shortcut icon" type="image/jpg" href="JJ.png"/>\n' \
                 '<meta charset="utf-8">\n' \
                 '<meta name="viewport" content="width=device-width, initial-scale=1.0">\n' \
                 '<link rel="stylesheet" type="text/css" href="steinbock.css">\n' \
                 '<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.css"/>\n' \
                 '<style>\n' \
                 '/* unvisited link */\n' \
                 'a:link {color: #ccc;}\n' \
                 '/* visited link */\n' \
                 'a:visited {color: #095484;}\n' \
                 '/* mouse over link */\n' \
                 'a:hover {color: #8ebf42;}\n' \
                 ' /* selected link */\n' \
                 'a:active {color: #800000;}\n' \
                 '</style>\n' \
                 '</head>\n' \
                 '<body>\n'
      with open('README.md', 'r') as f:
          lines = f.readlines()
      
      table = []
  
      
      for line in lines:
          if line.startswith('|') and line.endswith('|\n'):
              table.append(line)
  
          else:
              htmltable = table2html(table)
              table = []
  
              if htmltable != "":
                  fullhtml += htmltable + "\n"
  
              else:
                  fullhtml += markdown(line) + "\n"
  
      fullhtml += '</body>\n' \
                  '</html>\n'
      with open('index.html', 'w') as f:
          f.write(fullhtml)
  