aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuis R. Rodriguez <mcgrof@do-not-panic.com>2012-10-24 15:50:06 -0700
committerLuis R. Rodriguez <mcgrof@do-not-panic.com>2012-10-24 15:50:06 -0700
commiteaf794dce10f3c5517eb4e9b5fb300390f8b2f11 (patch)
tree61fb0590c87f9d2608d368575433467cb15243a2
parentacdad1603c6229b89d73b6ef162260ee769894a7 (diff)
downloadrel-html-eaf794dce10f3c5517eb4e9b5fb300390f8b2f11.tar.gz
rel-html: add HTML generator based on input index.html file
Right now this will just parse index.html and spit the same file out. The class will be modified soon after an import of a shiny HTML5 base template to let us add our content. Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
-rwxr-xr-xrel-html.py60
1 files changed, 57 insertions, 3 deletions
diff --git a/rel-html.py b/rel-html.py
index d07e15f..b5478c0 100755
--- a/rel-html.py
+++ b/rel-html.py
@@ -104,6 +104,54 @@ class index_parser(HTMLParser):
self.changelog = url
+# Example full html output parser, this can be used to
+# simply read and output a full HTML file, you can modify
+# this class to help you modify the contents. We do that
+# later.
+class html_base(HTMLParser):
+ "HTML 5 generator from parsed index parser content."
+ def parse(self, html):
+ "Parse the given string 's'."
+ self.feed(html)
+ self.close()
+ def handle_decl(self, decl):
+ sys.stdout.write('<!%s>' % decl)
+ def handle_starttag(self, tag, attributes):
+ sys.stdout.write('<%s' % tag)
+ for name, value in attributes:
+ sys.stdout.write(' %s="%s"' % (name, value))
+ sys.stdout.write('>')
+ def handle_endtag(self, tag):
+ sys.stdout.write('</%s>' % tag)
+ def handle_data(self, data):
+ sys.stdout.write('%s' % data)
+ def handle_comment(self, data):
+ sys.stdout.write('<!--%s-->' % data)
+ def __init__(self):
+ HTMLParser.__init__(self)
+
+class rel_html_gen(HTMLParser):
+ "HTML 5 generator from parsed index parser content."
+ def parse(self, html):
+ "Parse the given string 's'."
+ self.feed(html)
+ self.close()
+ def handle_decl(self, decl):
+ sys.stdout.write('<!%s>' % decl)
+ def handle_starttag(self, tag, attributes):
+ sys.stdout.write('<%s' % tag)
+ for name, value in attributes:
+ sys.stdout.write(' %s="%s"' % (name, value))
+ sys.stdout.write('>')
+ def handle_endtag(self, tag):
+ sys.stdout.write('</%s>' % tag)
+ def handle_data(self, data):
+ sys.stdout.write('%s' % data)
+ def handle_comment(self, data):
+ sys.stdout.write('<!--%s-->' % data)
+ def __init__(self):
+ HTMLParser.__init__(self)
+
def main():
parser = index_parser()
@@ -127,9 +175,15 @@ def main():
sys.exit(1)
# Write HTML5 base page
- for rel in parser.rels:
- print rel
- print parser.changelog
+ #for rel in parser.rels:
+ # print rel
+ #print parser.changelog
+
+ gen = rel_html_gen()
+ f = open('index.html', 'r')
+ html = f.read()
+
+ gen.parse(html)
if __name__ == "__main__":
main()