allow dokuwiki syntax links. this update is adhoc, might need to streamline later..
This commit is contained in:
36
index.html
36
index.html
@@ -102,6 +102,10 @@ function make_link(md) {
|
||||
if (match != null) {
|
||||
return "<li>"+match[1]+"<a class=\"link\" href=\""+match[3]+"\">"+match[2]+"</a>"+match[4];
|
||||
}
|
||||
var match=dwLinkReg.exec(md);
|
||||
if (match != null) {
|
||||
return "<li><a class=\"link\" href=\""+match[2]+"\">"+match [3]+"</a>"+match[4];
|
||||
}
|
||||
match=linkPlain.exec(md);
|
||||
if (match != null) {
|
||||
return "<li>"+match[1]+"<a class=\"link\" href=\""+match[2]+"\">"+match[2]+"</a>"+match[3];
|
||||
@@ -110,8 +114,8 @@ function make_link(md) {
|
||||
}
|
||||
|
||||
function make_head(c,index="") {
|
||||
var name=c.substring(1).trim();
|
||||
var head=c.replace(/ /g," ");
|
||||
var name=parse_header(c);
|
||||
var head=name.replace(/ /g," ");
|
||||
var id=name.replace(/ /g,"")+"_"+index;
|
||||
return '<a name="'+name+'" id="anchor_'+id+'" class="nolink" onclick="fold_toggle(\''+id+'\')">'+
|
||||
'<div class=head align=center id="head_'+id+'">'+head+'</div></a>'+
|
||||
@@ -139,9 +143,11 @@ function make_menu() {
|
||||
sel.appendChild(opt);
|
||||
var anchor_index = 0;
|
||||
for (c=0; c<linkList.length; c++) {
|
||||
if ( linkList[c].substring(0,2) == "# " ) {
|
||||
var match=parse_header(linkList[c]);
|
||||
if (match != null) {
|
||||
//if ( linkList[c].substring(0,2) == "# " ) {
|
||||
var opt=document.createElement("option");
|
||||
var name=linkList[c].substring(1).trim().replace(/ /g,"");
|
||||
var name=match[2].trim().replace(/ /g,"");
|
||||
opt.innerHTML=linkList[c].trim();
|
||||
opt.value="anchor_" + name.replace(/^#/,"") + "_" + anchor_index;
|
||||
sel.appendChild(opt);
|
||||
@@ -181,8 +187,9 @@ function search_hits(needle) {
|
||||
hitList=[];
|
||||
var headName="";
|
||||
for (l=0; l<linkList.length; l++) {
|
||||
if ( linkList[l].substring(0,2) == "# " ) {
|
||||
headName=linkList[l].substring(1).trim().replace(/ /g,"").toLowerCase();
|
||||
var match=parse_header(linkList[l]);
|
||||
if (match != null) {
|
||||
headName=match.replace(/ /g,"").toLowerCase();
|
||||
}
|
||||
if (needle.substring(0,1)=="#") {
|
||||
/* search for header */
|
||||
@@ -228,8 +235,9 @@ function print_results(hitList) {
|
||||
var cat=0;
|
||||
cats=[];
|
||||
for (c=0; c<linkList.length; c++) {
|
||||
if ( linkList[c].substring(0,2) == "# " ) {
|
||||
var name=linkList[c].substring(1).trim().replace(/ /g,"");
|
||||
var match=parse_header(linkList[c]);
|
||||
if ( match != null ) {
|
||||
var name=match.replace(/ /g,"");
|
||||
var td=document.createElement("td");
|
||||
td.id="td_"+name+"_"+cat;
|
||||
var td_content = document.createElement("div");
|
||||
@@ -288,6 +296,16 @@ function read_links() {
|
||||
}
|
||||
}
|
||||
|
||||
function parse_header(s) {
|
||||
if (s.substring(0,2) == "# ") {
|
||||
return s.substring(2).trim()
|
||||
}
|
||||
if (s.substring(0,7) == "====== ") {
|
||||
return s.replaceAll("=","").trim()
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
function parse_links(s) {
|
||||
var linkRows=s.split("\n");
|
||||
var links=[];
|
||||
@@ -490,7 +508,9 @@ document.onmouseclick = resetTimer;
|
||||
document.onkeypress = resetTimer;
|
||||
document.onkeyup = keyboard_entry;
|
||||
document.onscroll = scroll_save;
|
||||
|
||||
var linkReg=/([^\[]*)\[([^\]]+)\]\(([^\)]+)\)(.*)/;
|
||||
var dwLinkReg=/([ *-]*)\[\[([^\|]+)\|([^\]]+)\]\](.*)/;
|
||||
var linkPlain=/(.*)(http[^\s]+)(.*)/;
|
||||
var linkList=[];
|
||||
var hitList=[];
|
||||
|
||||
Reference in New Issue
Block a user