Skip to content

Commit

Permalink
Some minor enhancements make md expressions more flexbile
Browse files Browse the repository at this point in the history
  • Loading branch information
rrg92 committed Sep 16, 2024
1 parent caec743 commit 08a4f26
Showing 1 changed file with 26 additions and 20 deletions.
46 changes: 26 additions & 20 deletions util/doc.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function ParseRun($str,$vars){
return (ReplaceVars @($Expr) $Vars)
}

return [regex]::Replace($str,'\<\!\-\-\!(?<Expr>.*?)\-\-\>',$Replacer, "Singleline" );
return [regex]::Replace($str,'<!--!(?<Expr>.*?)!?-->',$Replacer, "Singleline" );

}

Expand Down Expand Up @@ -260,31 +260,37 @@ Function ParseFile($Source,$Target,$Vars){

#Parse functiomns!
if($Line -match '<@f>(.*?)</@f>'){

$Expr = $matches[1];

switch -Regex ($Expr){
"^(=\s*)?@#(.+)" {

if($Expr[0] -eq "="){
$NewLines += $Expr -replace '^=[\s\t]*','';
}
$HeaderName = $matches[2];

if($Expr[0] -eq "@"){
switch -Regex ($Expr){
"^\@#(.+)" {
$HeaderName = $matches[1];

$HeaderValue = $HEADERS[$HeaderName];

if(!$HeaderValue){
throw "INVALID_HEADER: $HeaderName";
continue;
}

$HeaderValue = $HEADERS[$HeaderName];

$NewLines += "# $HeaderValue";
}
if(!$HeaderValue){
throw "INVALID_HEADER: $HeaderName";
continue;
}

default {
throw "FunctionNotRecognized"
$HeaderHashs = "##";
if($line -match '^(#+)'){
$HeaderHashs = $matches[1];
}

$NewLines += $HeaderHashs+" $HeaderValue";
break;
}

"^=\s+([^@])" {
$NewLines += $matches[1];
break;
}

default {
throw "FunctionNotRecognized"
}
}

Expand Down

0 comments on commit 08a4f26

Please sign in to comment.