]> khamidou — GitHub mirrors - rfcspot.git/commitdiff
starting from scratch with RFC conversion
authorKarim Hamidou <karim@MacBook.local>
Thu, 3 Mar 2016 04:09:55 +0000 (20:09 -0800)
committerKarim Hamidou <karim@MacBook.local>
Thu, 3 Mar 2016 04:09:55 +0000 (20:09 -0800)
rfc.css
src/render_rfc.py [new file with mode: 0644]
templates/index.html

diff --git a/rfc.css b/rfc.css
index 186ac79522287b73c104250b4f38e4d36c071242..0b9087cb990b8b9af77674c8dc81471fd337732a 100644 (file)
--- a/rfc.css
+++ b/rfc.css
@@ -120,9 +120,18 @@ table td {
     }
 
 
-.homepage > input  {
-    font-size: 16px;
-    width: 40%;
+.homepage {
+    display: flex;
+    align-items: center;
+    justify-content: center;
+}
+
+.homepage .centered {
+  position: relative;
+  top: 50%;
+  -webkit-transform: translateY(-50%);
+  -ms-transform: translateY(-50%);
+  transform: translateY(-50%);
 }
 
 /*---------------------- Syntax Highlighting -----------------------------*/
diff --git a/src/render_rfc.py b/src/render_rfc.py
new file mode 100644 (file)
index 0000000..a763dfa
--- /dev/null
@@ -0,0 +1,35 @@
+# render_rfc: convert an RFC from text to HTML.
+# Does the following things:
+# 1. remove page breaks and signatures
+# 2. add links to the table of contents
+import re
+import sys
+
+
+def remove_top_space(data):
+    topspace_regexp = re.compile(r"^(\n){4,}", re.MULTILINE)
+    data = topspace_regexp.sub('', data, count=1)
+    return data
+
+def remove_page_breaks(data):
+    pagebreak_regexp = re.compile(r"((\n){2,}^.*$\n\f$\n^.*$(\n){3,})", re.MULTILINE)
+    data = pagebreak_regexp.sub(r'\n', data)
+    return data
+
+
+def render_rfc(filename):
+    with open(filename) as fd:
+        data = fd.read()
+
+    for fn in [remove_top_space, remove_page_breaks]:
+        out = fn(data)
+
+    return out
+
+
+def main():
+    print render_rfc(sys.argv[1])
+
+
+if __name__ == '__main__':
+    main()
index ba794654bfaa785e1be94d77c420d30a7c4a6df4..dd308b6e98b8464440eb6268fb6a0b6eb6b80b73 100644 (file)
@@ -1,24 +1,18 @@
 <!DOCTYPE html>
-<html style='height: 100%;'>
+<html>
 <head>
   <meta http-equiv="content-type" content="text/html;charset=utf-8">
   <title>RFC Czar: RFC for the rest of us.</title>
   <link rel="stylesheet" href="rfc.css">
 </head>
-<body style="height: 100%;" class="homepage">
-<table style="width: 100%;">
-    <tr>
-        <td style="text-align: center; vertical-align: middle; top: 40%;">
-            <center>
-                <h2>
-                    RFCs for <a href="rfc7231.html">rest of us</a>.<br>
-                </h2>
-                <div>
-                    <input type="text" placeholder="Type an RFC name or keywords"></input>
-                </div>
-            </center>
-        </td>
-    </tr>
-</table>
+<body>
+    <div class="homepage">
+        <h2 class="centered">
+            RFCs for the rest of us.<br>
+        </h2>
+        <div>
+            <input type="text" placeholder="Type an RFC name or keywords"></input>
+        </div>
+    </div>
 </body>
 </html>