Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions mdview.c
Original file line number Diff line number Diff line change
Expand Up @@ -1421,12 +1421,12 @@ static void build_js(StrBuf* sb) {
"h=h.replace(/(`(?:[^`\\\\]|\\\\.)*?`)/g,'<span class=\"sh-str\">$1</span>');"

/* Numbers */
"h=h.replace(/\\b(\\d+\\.?\\d*(?:e[+-]?\\d+)?|0x[0-9a-fA-F]+)\\b/g,'<span class=\"sh-num\">$1</span>');"
"h=h.replace(/(<[^>]+>)|([^<]+)/g,function(m,tag,text){return tag?tag:text.replace(/\\b(\\d+\\.?\\d*(?:e[+-]?\\d+)?|0x[0-9a-fA-F]+)\\b/g,'<span class=\"sh-num\">$1</span>');});"

/* HTML/XML tags */
"if(lang==='html'||lang==='xml'){"
"h=h.replace(/(&lt;\\/?)([a-zA-Z][a-zA-Z0-9]*)/g,'$1<span class=\"sh-tag\">$2</span>');"
"h=h.replace(/\\s([a-zA-Z-]+)(=)/g,' <span class=\"sh-attr\">$1</span>$2');"
"h=h.replace(/(<[^>]+>)|([^<]+)/g,function(m,tag,text){return tag?tag:text.replace(/\\s([a-zA-Z-]+)(=)/g,' <span class=\"sh-attr\">$1</span>$2');});"
"}else{"

/* Keywords per language family */
Expand All @@ -1445,10 +1445,10 @@ static void build_js(StrBuf* sb) {
"kws='\\\\b(color|background|margin|padding|border|font|display|position|width|height|top|left|right|bottom|flex|grid|none|block|inline|relative|absolute|fixed|inherit|auto|important|solid|transparent)\\\\b';"
"else if(lang==='php')"
"kws='\\\\b(function|return|if|else|elseif|for|foreach|while|do|switch|case|break|continue|class|public|private|protected|static|new|echo|print|null|true|false|array|isset|empty|unset|require|include|use|namespace|try|catch|finally|throw|var)\\\\b';"
"if(kws){var re=new RegExp(kws,'g');h=h.replace(re,'<span class=\"sh-kw\">$1</span>');}"
"if(kws){var re=new RegExp(kws,'g');h=h.replace(/(<[^>]+>)|([^<]+)/g,function(m,tag,text){return tag?tag:text.replace(re,'<span class=\"sh-kw\">$1</span>');});}"

/* Function calls: word followed by ( */
"h=h.replace(/\\b([a-zA-Z_][a-zA-Z0-9_]*)\\s*\\(/g,'<span class=\"sh-fn\">$1</span>(');"
"h=h.replace(/(<[^>]+>)|([^<]+)/g,function(m,tag,text){return tag?tag:text.replace(/\\b([a-zA-Z_][a-zA-Z0-9_]*)\\s*\\(/g,'<span class=\"sh-fn\">$1</span>(');});"
"}"

"el.innerHTML=h;}}"
Expand Down Expand Up @@ -1491,7 +1491,6 @@ static void build_js(StrBuf* sb) {
/* Init */
"window.onload=function(){"
"shAll();initCollapse();"
"shAll();initCollapse();"
"if(ln)tl();" /* apply line numbers if saved */
"up()};"
"</script>");
Expand Down