Overview
Comment:feat(skin/js/toc.js): add option to not include top-level heading in slug text
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 96285315e24092e5d4e6fd3b1f1b2fd7930c2518a54ffed3c992ef608733e40d
User & Date: dbohdan on 2020-08-24 09:06:32
Other Links: manifest | tags
Context
2020-08-24
10:32
style(skin/js/toc.js): rename parameter "skipRootInSlug" "skipH1sInSlug" check-in: 0d626b8241 user: dbohdan tags: trunk
09:06
feat(skin/js/toc.js): add option to not include top-level heading in slug text check-in: 96285315e2 user: dbohdan tags: trunk
08:58
feat(music/render.tcl): add page tag "list" check-in: 12cefb242c user: dbohdan tags: trunk
Changes

Modified skin/js/bottom.js from [22153e3516] to [2b13b61405].

1
2
3
// ------
tocGen.addToC();
hljs.initHighlightingOnLoad();

|

1
2
3
// ------
tocGen.addToC(true);
hljs.initHighlightingOnLoad();

Modified skin/js/toc.js from [b0bdaf6660] to [f315bd9963].

39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
..
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
..
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
    li.appendChild(a);
    
    return li;
};

// Set unique fragement ids on headings and return an element containing the
// ToC.  The ToC consists of nested <ul>s.
tocGen.createToC = function(headings) {
    var prevLevel = 0;
    var stack = [null, null, null, null, null, null];

    var f = function(heading) {
        var level = +heading.tagName[1];
        var i, ul;

................................................................................
                stack[i - 1].list.appendChild(li);
            }

            stack[i] = {'list': ul, 'text': ''};
        }
        stack[level - 1].text = heading.innerText;
       
        var slug = stack.slice(0, level).map(function(x) {
            return tocGen.slugify(x.text);
        }).join('--');
        heading.id = slug;        
        var liA = tocGen.createLiA('#' + slug, heading.innerText);

        stack[level - 1].list.appendChild(liA);

................................................................................

// Insert el into the document after ref.
tocGen.insertAfter = function(ref, el) {
    ref.parentNode.insertBefore(el, ref.nextSibling);
}

// Add a ToC to the current wiki page.
tocGen.addToC = function() {
    var headings = tocGen.headings();

    var contentsHeading = tocGen.contentsHeading(headings);
    if (!contentsHeading) return;

    var toc = tocGen.createToC(headings);
    tocGen.insertAfter(contentsHeading, toc);
};







|







 







|







 







|





|


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
..
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
..
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
    li.appendChild(a);
    
    return li;
};

// Set unique fragement ids on headings and return an element containing the
// ToC.  The ToC consists of nested <ul>s.
tocGen.createToC = function(headings, skipRootInSlug) {
    var prevLevel = 0;
    var stack = [null, null, null, null, null, null];

    var f = function(heading) {
        var level = +heading.tagName[1];
        var i, ul;

................................................................................
                stack[i - 1].list.appendChild(li);
            }

            stack[i] = {'list': ul, 'text': ''};
        }
        stack[level - 1].text = heading.innerText;
       
        var slug = stack.slice(1 * skipRootInSlug, level).map(function(x) {
            return tocGen.slugify(x.text);
        }).join('--');
        heading.id = slug;        
        var liA = tocGen.createLiA('#' + slug, heading.innerText);

        stack[level - 1].list.appendChild(liA);

................................................................................

// Insert el into the document after ref.
tocGen.insertAfter = function(ref, el) {
    ref.parentNode.insertBefore(el, ref.nextSibling);
}

// Add a ToC to the current wiki page.
tocGen.addToC = function(skipRootInSlug) {
    var headings = tocGen.headings();

    var contentsHeading = tocGen.contentsHeading(headings);
    if (!contentsHeading) return;

    var toc = tocGen.createToC(headings, skipRootInSlug);
    tocGen.insertAfter(contentsHeading, toc);
};