#background {
position: fixed;
top: 0; left: 580px; right: 0; bottom: 0;
- background: #f5f5ff;
- border-left: 1px solid #e5e5ee;
z-index: -1;
}
#jump_to, #jump_page {
outline: 0;
}
td.docs, th.docs {
- max-width: 500px;
- min-width: 500px;
+ max-width: 600px;
+ min-width: 600px;
min-height: 5px;
padding: 10px 25px 1px 50px;
vertical-align: top;
}
.docs pre {
margin: 15px 0 15px;
- padding-left: 15px;
+ font-size: 16px;
+ line-height: 24px;
+ font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;
}
.docs p tt, .docs p code {
background: #f8f8ff;
# -*- coding: utf-8 -*-
# This script takes an HTML RFC as input and formats it in a prettier
# format.
+import re
import sys
import pystache
-from bs4 import BeautifulSoup
+from bs4 import BeautifulSoup, Tag
from template import html_template
class ProcessingException(Exception):
title = soup.head.title.text
# Remove useless formatting:
[node.extract() for node in soup('span', class_='grey')]
- # [node.extract() for node in soup('hr', class_='noprint')]
+ [node.extract() for node in soup('style')]
+ [node.extract() for node in soup('script')]
+ # Remove the first <h1> tag --- we're already showing the title
+ node = soup.find('h1')
+ if node is not None:
+ node.extract()
+
+ # Remove <hr> tags:
+ for match in soup.findAll('hr'):
+ match.replaceWithChildren()
+
+ # Once we've got rid of everything, remove consecutive blank lines:
+ new_lines = re.compile('(\w*\n){3,99}')
+ re_serialized = soup.prettify()
+ contents = re.sub(new_lines, '\n\n', re_serialized)
+ soup = BeautifulSoup(contents, 'html.parser')
+
+ # Find the first pre tag and extract
# Finally, extract the body:
body_contents = soup.body.find('div', class_='content')
dct = dict(rfc=body_contents.prettify(), title=title)
rendered = pystache.render(html_template, dct)
+
with open(outfile, 'w+') as fd:
fd.write(rendered.encode('utf-8'))