]> khamidou — GitHub mirrors - rfcspot.git/commitdiff
rendering looks prettier now.
authorKarim Hamidou <karim@MacBook.local>
Sun, 31 Jan 2016 06:39:34 +0000 (22:39 -0800)
committerKarim Hamidou <karim@MacBook.local>
Sun, 31 Jan 2016 06:39:34 +0000 (22:39 -0800)
rfc.css
src/format-rfc.py
src/template.py

diff --git a/rfc.css b/rfc.css
index d015694544815766c1150737e269d7d859aed214..388a9fc3c22aa68a619b5d970933f336a9a0aa75 100644 (file)
--- a/rfc.css
+++ b/rfc.css
@@ -27,8 +27,6 @@ h1, h2, h3, h4, h5, h6 {
 #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 {
@@ -72,8 +70,8 @@ table td {
   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;
@@ -81,7 +79,9 @@ table td {
   }
     .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;
index 0a174e652ec0a5381fbfb793262f72ae0e0a0d15..13c33a7bae0d5e0b20004154326e36c100c75007 100644 (file)
@@ -2,9 +2,10 @@
 # -*- 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):
@@ -20,8 +21,25 @@ def process_file(infile, outfile):
     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')
 
@@ -30,6 +48,7 @@ def process_file(infile, outfile):
 
     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'))
 
index 4a7a9fdb46ae7974e18bccdfad6093cd31c63667..3ca912d3ae4a1cd6b11e630ceca7968e74e0fd9c 100644 (file)
@@ -19,9 +19,6 @@ html_template = """\
   <tbody>
     <tr id='section-{{ num }}'>
       <td class=docs>
-        <div class="octowrap">
-          <a class="octothorpe" href="#section-{{ num }}">#</a>
-        </div>
         {{{ rfc }}}
       </td>
       <td class=code>