Github user riknoll commented on a diff in the pull request: https://github.com/apache/cordova-docs/pull/487#discussion_r52092095 --- Diff: www/static/js/docs.js --- @@ -17,49 +17,81 @@ $(document).ready(function () { - function getAnchorName(i, heading, prefix) { - var name = prefix; + function slugify(text) { + text = text.toLowerCase(); + + // replace unaccepted characters with spaces + // NOTE: + // a better regex would have been /[^\d\s\w]/ug, but the 'u' flag + // (Unicode) is not supported in some browsers, and we support + // many languages that use Unicode characters + text = text.replace(/[\[\]\(\)\=\+\?]/g, ' '); + + // trim whitespace and replace runs of whitespace with single dashes + text = text.trim().replace(/ +/g, '-'); + + return text; + } + + function getIdForHeading(heading) { if (heading.id) { - name += heading.id; + return heading.id; } else if (heading.name) { - name += heading.name; + return heading.name; } else { - name += i; + return slugify(heading.innerText); } - return name; } - var anchorLink = function (id) { - var anchor = document.createElement("a"); + function permalinkTo(id) { + var anchor = document.createElement("a"); anchor.className = "header-link"; anchor.href = "#" + id; anchor.innerHTML = "<i class=\"glyphicon glyphicon-link\"></i>"; return anchor; } + function anchorFor(id) { + var anchor = document.createElement("a"); + anchor.className = "fragment-anchor"; + anchor.id = id; + return anchor; + } + + // go through all headings in the content and add some links + $('#page-toc-source h1, #page-toc-source h2').each(function (i, heading) { --- End diff -- +1 The Android guide definitely requires referencing H3+
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org For additional commands, e-mail: dev-h...@cordova.apache.org