1+ // console.log("Debugging github-linkify-cmssw");
12// the lines of code are stored in a table
23table = document . getElementsByClassName ( "js-file-line-container" ) [ 0 ] ;
34
@@ -12,7 +13,7 @@ rootURL = url.substr(0, url.search(pattern)+cmssw.length);
1213
1314// pattern to do #include matching
1415var cpp_pattern = / # i n c l u d e / ;
15- var cpp_header_pattern = / [ < \" ] .* [ > \" ] / ; // does "myheader.h" or <myheader>
16+ var cpp_header_pattern = / [ < \" ] .* [ > \" ] / ; // does "myheader.h" or <myheader.h >
1617
1718// pattern to do python matching
1819var py_pattern1 = / i m p o r t / ;
@@ -32,20 +33,20 @@ for (var i = 0; i < rows.length; i++) {
3233 var line = cell . textContent ;
3334
3435 // check line has a C++ #include, if so pull the header path
35- // TODO: check it's not a STL include, like iostream
36- if ( cpp_pattern . test ( line ) ) {
36+ // ensure it has a ".h", and a "/", to exclude STL
37+ if ( cpp_pattern . test ( line ) && ( / \. h / . test ( line ) ) && ( / \/ / . test ( line ) ) ) {
3738 var path = cpp_header_pattern . exec ( line ) [ 0 ] ;
3839 path = path . replace ( / [ < > \" ] / g, "" ) ; //g inmportant - global so replaces all instances
3940 var link = rootURL . concat ( path ) ;
4041
4142 // let's replace the text with a link
4243 // TODO keep same styling as before
43- for ( var k = 0 ; k < cell . childNodes . length ; k ++ ) {
44- if ( cell . childNodes [ k ] . textContent . indexOf ( path ) != - 1 ) {
45- var cell_html = cell . childNodes [ k ] . innerHTML ;
46- cell . childNodes [ k ] . innerHTML = cell_html . replace ( path , "<a href=\"" + link + "\">" + path + "</a>" ) ;
47- }
48- }
44+ cell . innerHTML = cell . innerHTML . replace ( path , "<a href=\"" + link + "\">" + path + "</a>" ) ;
45+ // for (var k = 0; k < cell.childNodes.length; k++ ) {
46+ // if ( cell.childNodes[k].textContent.indexOf(path) != -1) {
47+ // var cell_html = cell.childNodes[k].innerHTML;
48+ // }
49+ // }
4950 }
5051 // test for python
5152 else if ( py_pattern1 . test ( line ) || py_pattern3 . test ( line ) || py_pattern4 . test ( line ) ) {
0 commit comments