W3C home > Mailing lists > Public > public-html-commits@w3.org > July 2009

html5/spec/tools spec-splitter.py,1.2,1.3

From: Michael Smith via cvs-syncmail <cvsmail@w3.org>
Date: Wed, 22 Jul 2009 14:09:24 +0000
To: public-html-commits@w3.org
Message-Id: <E1MTcVY-00013o-AO@lionel-hutz.w3.org>
Update of /sources/public/html5/spec/tools
In directory hutz:/tmp/cvs-serv2959/tools

Modified Files:
	spec-splitter.py 
Log Message:
[docbuild] sync up to Philip's latest, and add the doohickey that makes fragment links work as expected


Index: spec-splitter.py
===================================================================
RCS file: /sources/public/html5/spec/tools/spec-splitter.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- spec-splitter.py	18 Jul 2009 09:57:15 -0000	1.2
+++ spec-splitter.py	22 Jul 2009 14:09:22 -0000	1.3
@@ -157,11 +157,13 @@
     title = getNodeText(heading)
     name = heading.get('id')
     if name == index_page: name = 'section-%s' % name
-    print '  <%s> %s' % (heading.tag, name)
+    print '  <%s> %s - %s' % (heading.tag, name, title)
 
     page = deepcopy(doc)
     page_body = page.find('body')
 
+    page.find('//title').text = title + u' \u2014 HTML 5'
+
     # Add the header
     page_body.append(deepcopy(short_header))
 
@@ -250,7 +252,8 @@
 
 # Generate the script to fix broken links
 f = open('%s/fragment-links.js' % (file_args[1]), 'w')
-f.write('var fragment_links = { ' + ','.join("'%s':'%s'" % (k.replace("\\", "\\\\").replace("'", "\\'"), v) for (k,v) in id_pages.items()) + ' };\n')
+links = ','.join("'%s':'%s'" % (k.replace("\\", "\\\\").replace("'", "\\'"), v) for (k,v) in id_pages.items())
+f.write('var fragment_links = { ' + re.sub(r"([^\x20-\x7f])", lambda m: "\\u%04x" % ord(m.group(1)), links) + ' };\n')
 f.write("""
 var fragid = window.location.hash.substr(1);
 if (!fragid) { /* handle section-foo.html links from the old multipage version, and broken foo.html from the new version */
Received on Wednesday, 22 July 2009 14:09:36 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 22 July 2009 14:09:38 GMT