fix url anchors into markdown docs
This commit is contained in:
parent
c2f4090318
commit
cebac523dc
@ -6409,6 +6409,14 @@ function show_md(md, name, div, url, depth) {
|
|||||||
els[a].setAttribute('href', '#md-' + href.slice(1));
|
els[a].setAttribute('href', '#md-' + href.slice(1));
|
||||||
}
|
}
|
||||||
set_tabindex();
|
set_tabindex();
|
||||||
|
var hash = location.hash;
|
||||||
|
if (hash.startsWith('#md-'))
|
||||||
|
setTimeout(function () {
|
||||||
|
try {
|
||||||
|
QS(hash).scrollIntoView();
|
||||||
|
}
|
||||||
|
catch (ex) { }
|
||||||
|
}, 1);
|
||||||
}
|
}
|
||||||
catch (ex) {
|
catch (ex) {
|
||||||
toast.warn(10, errmsg + ex);
|
toast.warn(10, errmsg + ex);
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var dom_toc = ebi('toc');
|
var dom_toc = ebi('toc'),
|
||||||
var dom_wrap = ebi('mw');
|
dom_wrap = ebi('mw'),
|
||||||
var dom_hbar = ebi('mh');
|
dom_hbar = ebi('mh'),
|
||||||
var dom_nav = ebi('mn');
|
dom_nav = ebi('mn'),
|
||||||
var dom_pre = ebi('mp');
|
dom_pre = ebi('mp'),
|
||||||
var dom_src = ebi('mt');
|
dom_src = ebi('mt'),
|
||||||
var dom_navtgl = ebi('navtoggle');
|
dom_navtgl = ebi('navtoggle'),
|
||||||
|
hash0 = location.hash;
|
||||||
|
|
||||||
|
|
||||||
// chrome 49 needs this
|
// chrome 49 needs this
|
||||||
@ -35,12 +36,12 @@ var dbg = function () { };
|
|||||||
|
|
||||||
// add navbar
|
// add navbar
|
||||||
(function () {
|
(function () {
|
||||||
var parts = get_evpath().split('/'), link = '', o;
|
var parts = (get_evpath().slice(0, -1).split('?')[0] + '?v').split('/'), link = '', o;
|
||||||
for (var a = 0, aa = parts.length - 2; a <= aa; a++) {
|
for (var a = 0, aa = parts.length - 1; a <= aa; a++) {
|
||||||
link += parts[a] + (a < aa ? '/' : '');
|
link += parts[a] + (a < aa ? '/' : '');
|
||||||
o = mknod('a');
|
o = mknod('a');
|
||||||
o.setAttribute('href', link);
|
o.setAttribute('href', link);
|
||||||
o.textContent = uricom_dec(parts[a]) || 'top';
|
o.textContent = uricom_dec(parts[a].split('?')[0]) || 'top';
|
||||||
dom_nav.appendChild(o);
|
dom_nav.appendChild(o);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
@ -256,7 +257,7 @@ function convert_markdown(md_text, dest_dom) {
|
|||||||
var html = dom_li.innerHTML;
|
var html = dom_li.innerHTML;
|
||||||
dom_li.innerHTML =
|
dom_li.innerHTML =
|
||||||
'<span class="todo_' + clas + '">' + char + '</span>' +
|
'<span class="todo_' + clas + '">' + char + '</span>' +
|
||||||
html.substr(html.indexOf('>') + 1);
|
html.slice(html.indexOf('>') + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// separate <code> for each line in <pre>
|
// separate <code> for each line in <pre>
|
||||||
@ -328,6 +329,15 @@ function convert_markdown(md_text, dest_dom) {
|
|||||||
catch (ex) {
|
catch (ex) {
|
||||||
md_plug_err(ex, ext[1]);
|
md_plug_err(ex, ext[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hash0)
|
||||||
|
setTimeout(function () {
|
||||||
|
try {
|
||||||
|
QS(hash0).scrollIntoView();
|
||||||
|
hash0 = '';
|
||||||
|
}
|
||||||
|
catch (ex) { }
|
||||||
|
}, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ var dom_md = ebi('mt');
|
|||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
var n = document.location + '';
|
var n = document.location + '';
|
||||||
n = n.substr(n.indexOf('//') + 2).split('?')[0].split('/');
|
n = (n.slice(n.indexOf('//') + 2).split('?')[0] + '?v').split('/');
|
||||||
n[0] = 'top';
|
n[0] = 'top';
|
||||||
var loc = [];
|
var loc = [];
|
||||||
var nav = [];
|
var nav = [];
|
||||||
@ -15,7 +15,7 @@ var dom_md = ebi('mt');
|
|||||||
if (a > 0)
|
if (a > 0)
|
||||||
loc.push(n[a]);
|
loc.push(n[a]);
|
||||||
|
|
||||||
var dec = uricom_dec(n[a]).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
var dec = uricom_dec(n[a].split('?')[0]).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
||||||
|
|
||||||
nav.push('<a href="/' + loc.join('/') + '">' + dec + '</a>');
|
nav.push('<a href="/' + loc.join('/') + '">' + dec + '</a>');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user