Skip to content

Commit 4be0d1d

Browse files
committed
adding #__debug__ to any url will
- make invisible <a/> tags visible in magenta - warn on the javascript console for duplicated id and name attrs As soon as Pod::To::HTML is updated on docs.perl6.org we can start hunting for duplicated X<> tags and get the search function to actually link to X<> generated anchors.
1 parent d1340a0 commit 4be0d1d

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

html/js/main.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ $(function(){
22
setup_search_box();
33
setup_auto_title_anchors();
44
setup_collapsible_TOC();
5+
setup_debug_mode();
56
$(window).resize(setup_search_box);
67
});
78

@@ -61,6 +62,33 @@ function setup_collapsible_TOC() {
6162
el.text('[hide]');
6263
}
6364

64-
return false;x
65+
return false;
6566
});
6667
}
68+
69+
function setup_debug_mode(){
70+
if ( window.location.href.endsWith('#__debug__') ) {
71+
console.info("checking for duplicated name and id attrs");
72+
73+
var seen_name_or_id = [];
74+
75+
$('#content').css('overflow', 'visible');
76+
77+
$('html').find('a').each( function(i, el){
78+
if ( el.name ) {
79+
if ( seen_name_or_id.includes(el.name) ) {
80+
console.log("found duplicate name attr in", el);
81+
}
82+
seen_name_or_id.push(el.name);
83+
84+
$(el).after('<span><a href="#' + el.name + '" style="color: magenta;">«#'+el.name+'»</a> </span>');
85+
}
86+
if ( el.id ) {
87+
if ( seen_name_or_id.includes(el.id) ) {
88+
console.log("found duplicate id attr in", el);
89+
}
90+
seen_name_or_id.push(el.id);
91+
}
92+
})
93+
}
94+
}

0 commit comments

Comments
 (0)