Update tref to use @href to refer to external definitions.
authorGregg Kellogg <gregg@kellogg-assoc.com>
Mon, 18 Feb 2013 14:31:11 -0800
changeset 1302 f140b3b61344
parent 1301 16d7a4bc1309
child 1303 5ccce3b97b0a
Update tref to use @href to refer to external definitions.
spec/latest/respec-w3c-extensions.js
--- a/spec/latest/respec-w3c-extensions.js	Mon Feb 18 14:14:33 2013 -0500
+++ b/spec/latest/respec-w3c-extensions.js	Mon Feb 18 14:31:11 2013 -0800
@@ -94,7 +94,7 @@
                 ref = item.textContent ;
             }
             if (ref) {
-                ref = ref.replace(/\s+/g, '_').toLowerCase() ;
+                ref = ref.replace(/\s+/g, '-').toLowerCase() ;
             }
 
             if ( tdefs[ref]) {
@@ -102,9 +102,10 @@
             }
 
             var sp = document.createElement( 'dfn' ) ;
-            tdefs[ref] = sp ;
             sp.title = ref ;
             sp.innerHTML = con ;
+            sp.id = 'T-'+ref;
+            tdefs[ref] = '#' + sp.id ;
             p.replaceChild(sp, item) ;
         }
         // now term references
@@ -119,9 +120,12 @@
                 ref = item.textContent ;
             }
             if (ref) {
-                ref = ref.replace(/\s+/g, '_').toLowerCase() ;
+                ref = ref.replace(/\s+/g, '-').toLowerCase() ;
             }
-
+            var href = item.getAttribute('href');
+            if (href) {
+              tdefs[ref] = href;
+            }
             if ( !tdefs[ref]) {
               throw "Reference to undefined term '" + ref + "'" ;
             }
@@ -130,6 +134,7 @@
             sp.className = 'tref' ;
             sp.title = ref ;
             sp.innerHTML = con ;
+            sp.href= tdefs[ref] ;
             p.replaceChild(sp, item) ;
         }
     }