aboutsummaryrefslogtreecommitdiffstats
path: root/docs/src/dom.js
diff options
context:
space:
mode:
Diffstat (limited to 'docs/src/dom.js')
-rw-r--r--docs/src/dom.js16
1 files changed, 12 insertions, 4 deletions
diff --git a/docs/src/dom.js b/docs/src/dom.js
index ccfee7ac..11330a02 100644
--- a/docs/src/dom.js
+++ b/docs/src/dom.js
@@ -77,10 +77,18 @@ DOM.prototype = {
h: function(heading, content, fn){
if (content==undefined || (content instanceof Array && content.length == 0)) return;
this.headingDepth++;
- this.tag('h' + this.headingDepth, heading);
- var className = typeof heading == 'string'
- ? {'class': heading.toLowerCase().replace(/[^\d\w_]/mg, '-').replace(/-+/gm, '-')}
- : null;
+ var className = null,
+ anchor = null;
+ if (typeof heading == 'string') {
+ var id = heading.
+ replace(/\(.*\)/mg, '').
+ replace(/[^\d\w]/mg, '.').
+ replace(/-+/gm, '-').
+ replace(/-*$/gm, '');
+ anchor = {'id': id};
+ className = {'class': id.toLowerCase().replace(/[._]/mg, '-')};
+ }
+ this.tag('h' + this.headingDepth, anchor, heading);
if (content instanceof Array) {
this.ul(content, className, fn);
} else if (fn) {