import string.markdown;
var markdown = string.markdown();
var htmlTitle,htmlBody;
if(string.endsWith(request.path,".html",true)){
request.path = string.left(request.path,-6) + ".md"
}
if(string.endsWith(request.path,".md",true)){
if(request.path == "/search-results.md"){
var md = thread.get("doc://search-results.html") : "搜索结果为空!";
htmlTitle = string.match(md,"\n\s*\#\s+(\N+)") || string.match(md,"\n\s*\#\#\s+(\N+)") || "aardio 文档" ;
htmlBody = markdown.render(md);
}
elseif( string.startsWith(request.path,"/library-reference/") ){
var libPath = string.replace(request.path,"^/library-reference/","~/lib/");
libPath = fsys.path.replaceExt(libPath,".aardio");
import ide.doc.libraryMd;
var md = ide.doc.libraryMd(libPath);
if(!md){
htmlBody = "找不到文件:" + request.path;
}
else {
md = tostring( md );
htmlTitle = string.match(md,"!\N\s*\#\s+(\N+)") || string.match(md,"!\N\s*\#\#\s+(\N+)") || request.htmlTitle || "aardio 文档" ;
htmlBody = markdown.render(md);
}
}
elseif( string.startsWith(request.path,"/example/") ){
request.path = string.left(request.path,-4) + ".aardio"
htmlTitle = "范例"
var code = string.load("~"+request.path );
if(code){
code = ..string.replace(code,"@@file://~/example/","doc://example/");
htmlBody = `在代码编辑器中打开`
for title,link in string.gmatch(code,"!\N\s*/>\s*(\N+?)<<:>|\:>?\s+/\s*>?(||\://[^\s()]+)") {
if(string.find(title,":") && !string.find(title,"\a\.\a\w+\(") && !string.indexOf(title,"//")){
title = string.match(title,"《\s*(.+)\s*》") || title;
htmlBody = htmlBody ++ ` | `+title+``
}
}
for title,link in string.gmatch(code,"!\N\s*/>?!(\N+?)<<:>|\:>?\s+(||\://[^\s()]+)") {
if(string.find(title,":" )&& !string.find(title,"\a\.\a\w+\(") && !string.indexOf(title,"//") ){
title = string.match(title,"《\s*(.+)\s*》") || title;
htmlBody = htmlBody ++ ` | `+title+``
}
}
htmlBody = htmlBody ++ markdown.renderCode(code,"aardio");
}
}
else {
var md = string.load(request.path);
//doc://library-guide/builtin/io/io.file.html
if(!md){
htmlBody = "找不到文件:" + request.path;
}
else{
htmlTitle = string.match(md,"\n\s*\#\s+(\N+)") || string.match(md,"\n\s*\#\#\s+(\N+)") || "aardio 文档" ;
htmlBody = markdown.render(md);
}
}
}
elseif( string.startsWith(request.path,"/example/") ){
htmlTitle = "范例"
var code = string.load("~"+request.path );
if(code){
code = ..string.replace(code,"@@file://~/example/","doc://example/");
htmlBody = `在代码编辑器中打开`
for title,link in string.gmatch(code,"!\N\s*/>\s*(\N+?)<<:>|\:>?\s+/\s*>?(||\://[^\s()]+)") {
if(string.find(title,":") && !string.find(title,"\a\.\a\w+\(") && !string.indexOf(title,"//") ){
title = string.match(title,"《\s*(.+)\s*》") || title;
htmlBody = htmlBody ++ ` | `+title+``
}
}
for title,link in string.gmatch(code,"!\N\s*/>?!(\N+?)<<:>|\:>?\s+(||\://[^\s()]+)") {
if(string.find(title,":") && !string.find(title,"\a\.\a\w+\(") && !string.indexOf(title,"//") ){
title = string.match(title,"《\s*(.+)\s*》") || title;
htmlBody = htmlBody ++ ` | `+title+``
}
}
htmlBody = htmlBody ++ markdown.renderCode(code,"aardio");
}
}
htmlBody = string.replace(htmlBody
,"\(<@@Ctrl@>|<@@Shift@>|<@@Alt@>||<[Ff]\d>!\W.*?)\"
,function(kbd){
var items = string.splitEx(kbd,"\s*\+\s*");
for(i,v in items){
items[i] = ""+v+""
}
return string.join(items,"+");
}
)
if(request.path == "/guide/ide/ai.md"){
var js = /****
****/
htmlBody = string.replace(htmlBody,"@AI 编程指南
",`AARDIO 编程指南
`);
htmlBody = htmlBody ++ js;
}
?>
aardio 编程语言文档 - =htmlTitle?>
=htmlBody?>