Add support for building other specs.
authorCameron McCormack <cam@mcc.id.au>
Sat, 06 Apr 2013 13:15:48 +1100
changeset 74 f14102592e40
parent 73 5e950c7b185a
child 75 499d59804682
Add support for building other specs.
publish/config.js
publish/processing.js
spec.mk
--- a/publish/config.js	Sat Apr 06 12:27:17 2013 +1100
+++ b/publish/config.js	Sat Apr 06 13:15:48 2013 +1100
@@ -65,8 +65,14 @@
 
   function gather(n) {
     if (n.nodeType == 1) {
-      if (/^h[2-6]$/.test(n.nodeName) && n.getAttributeNS(namespaces.edit, 'toc') != 'no') {
-        var id = n.getAttribute("id");
+      var id = n.getAttribute("id");
+      if (/^h[2-6]$/.test(n.nodeName) &&
+          n.getAttributeNS(namespaces.edit, 'toc') != 'no' &&
+          id != 'pagetitle' &&
+          id != 'pagesubtitle' &&
+          id != 'abstract' &&
+          id != 'status' &&
+          id != 'toc') {
         var level = n.nodeName.substring(1) - 1;
         if (section.length >= level - 1) {
           if (section.length == level - 1) {
@@ -239,7 +245,7 @@
   },
 
   get isSingleChapter() {
-    return this.pages.length == 1;
+    return this.pageOrder.length == 1;
   },
 
   getPageDocument: function(page) {
--- a/publish/processing.js	Sat Apr 06 12:27:17 2013 +1100
+++ b/publish/processing.js	Sat Apr 06 13:15:48 2013 +1100
@@ -44,15 +44,18 @@
     }
   }
 
+  var isSVG2 = conf.shortTitle == 'SVG 2';
   // Add a link to the default style sheet.
   doc.head.appendChild(utils.parse('<link rel="stylesheet" title="Default" href="{{href}}" type="text/css" media="screen"/>',
-                                   { href: conf.maturity == 'ED' ? 'style/default_svg.css' : 'style/default_no_maturity.css' }));
+                                   { href: conf.maturity == 'ED' && !isSVG2 ? 'style/default_svg.css' : 'style/default_no_maturity.css' }));
 
-  // Add a link to alternate style sheet to hide background colors
-  // if this is an Editor's Draft, or to show them otherwise.
-  doc.head.appendChild(utils.parse('<link rel="alternate stylesheet" title="{{title}}" href="{{href}}" type="text/css" media="screen"/>',
-                                   { href: conf.maturity == 'ED' ? 'style/default_no_maturity.css' : 'style/default_svg.css',
-                                     title: conf.maturity == 'ED' ? 'Only annotations for publication' : 'All annotations' }));
+  if (isSVG2) {
+    // Add a link to alternate style sheet to hide background colors
+    // if this is an Editor's Draft, or to show them otherwise.
+    doc.head.appendChild(utils.parse('<link rel="alternate stylesheet" title="{{title}}" href="{{href}}" type="text/css" media="screen"/>',
+                                     { href: conf.maturity == 'ED' ? 'style/default_no_maturity.css' : 'style/default_svg.css',
+                                       title: conf.maturity == 'ED' ? 'Only annotations for publication' : 'All annotations' }));
+  }
 
   // Add a link to the "no issues/annotations" style sheet.
   doc.head.appendChild(utils.parse('<link rel="alternate stylesheet" title="No issues/annotations" href="style/default_no_issues.css" type="text/css" media="screen"/>'));
@@ -116,7 +119,7 @@
 // -- Add header and footer links to next/previous chapter, etc. --------------
 
 exports.addHeaderFooter = function(conf, page, doc) {
-  if (conf.pageOrder.length == 1) {
+  if (conf.isSingleChapter) {
     return;
   }
 
@@ -194,12 +197,13 @@
   function generate(ul, children) {
     for (var i = 0; i < children.length; i++) {
       var item = children[i];
-      var li = utils.parse('<li><a href="{{page}}.html#{{id}}"></a></li>',
-                           { page: page,
+      var li = utils.parse('<li><a href="{{url}}#{{id}}"></a></li>',
+                           { url: conf.isSingleChapter ? '' : page + '.html',
                              id: item.section.id });
       var a = li.firstChild;
       if (conf.pages[page].type == 'chapter' || 
-          conf.pages[page].type == 'appendix') {
+          conf.pages[page].type == 'appendix' ||
+          conf.isSingleChapter) {
         a.appendChild(utils.parse('<span class="secno">{{number}}{{section}}.</span> ',
                                   { number: conf.isSingleChapter ? '' : conf.pages[page].formattedNumber + '.',
                                     section: item.section.number }));
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/spec.mk	Sat Apr 06 13:15:48 2013 +1100
@@ -0,0 +1,16 @@
+# Makefile for specs under http://svgwg.org/hg/svg2/specs/.
+
+TOOLS=../../../svg2-tools
+
+all-with-tools-check : tools-check all
+
+tools-check :
+	@bash -c "REMOTE_REV=$$(hg id -i http://svgwg.org/hg/svg2-tools); [ \$$? = 0 -o \"\$$REMOTE_REV\" != \"\" ] || exit 0; LOCAL_REV=$$(hg id -i $(TOOLS)); [ \"\$$LOCAL_REV\" = \"\$$REMOTE_REV\" -o \"\$$LOCAL_REV\" = \"\$$REMOTE_REV\"+ ] || (echo \"You must update your svg2-tools repository! (Remote repository has revision \$$REMOTE_REV, but you are at \$$LOCAL_REV.)\"; exit 1)"
+
+all :
+	@$(TOOLS)/build.py
+
+clean :
+	@$(TOOLS)/build.py -c
+
+.PHONY : all-with-tools-check tools-check all clean