Skip to content

Commit 7681076

Browse files
committed
Add title attribute in table of contents
Right now the full title of an element is may not shown as the space of the ToC is limited. With this path it'll be shower on hover and this way provide more useful information. Signed-off-by: Sheogorath <sheogorath@shivering-isles.com>
1 parent 57c47a6 commit 7681076

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

public/vendor/md-toc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
var j = i + 1
5555
this._elTitleElement = this.elTitleElements[i]
5656
this._elTitleElementName = this._elTitleElement.tagName
57+
this._elTitleElementTitle = this._elTitleElement.textContent.replace(/"/g, '&quot;')
5758
this._elTitleElementText = (typeof this.process === 'function' ? this.process(this._elTitleElement) : this._elTitleElement.innerHTML).replace(/<(?:.|\n)*?>/gm, '')
5859
var id = this._elTitleElement.getAttribute('id')
5960
if (!id) {
@@ -63,7 +64,7 @@
6364
id = '#' + id
6465
}
6566

66-
this.tocContent += '<li><a href="' + id + '">' + this._elTitleElementText + '</a>'
67+
this.tocContent += '<li><a href="' + id + '" title="'+ this._elTitleElementTitle +'">' + this._elTitleElementText + '</a>'
6768

6869
if (j !== this._elTitleElementsLen) {
6970
this._elNextTitleElementName = this.elTitleElements[j].tagName

0 commit comments

Comments
 (0)