From 6e8347ede76c54163312e71eab5c7e60b81ee893 Mon Sep 17 00:00:00 2001 From: Will Budic Date: Sat, 29 Jul 2023 22:08:53 +1000 Subject: [PATCH] dev. --- .../PerlCNF/Specifications_For_CNF_ReadMe.md | 43 ++++++------ htdocs/cgi-bin/index.cgi | 8 +-- .../cgi-bin/system/modules/MarkdownPlugin.pm | 67 ++++++++++++------- 3 files changed, 67 insertions(+), 51 deletions(-) diff --git a/htdocs/cgi-bin/docs/PerlCNF/Specifications_For_CNF_ReadMe.md b/htdocs/cgi-bin/docs/PerlCNF/Specifications_For_CNF_ReadMe.md index 2d63d09..5360754 100644 --- a/htdocs/cgi-bin/docs/PerlCNF/Specifications_For_CNF_ReadMe.md +++ b/htdocs/cgi-bin/docs/PerlCNF/Specifications_For_CNF_ReadMe.md @@ -421,7 +421,7 @@ CNF supports basic SQL Database structure statement generation. This is done via So deeply nesting a large property body is not recommended and also not suitable for encapsulating in there data. 3. An opening tag is opened being surrounded with the same signifier into the direction of the property body. 4. The closing tag is in the opposite direction same signifiers. - - **[sesame[** I am an open and closed value now, nothing you can do about it (X|H)TML! **]sesame]** + - **[sesame[** I am an open and closed value now, nothing you can do about it (X|H)TML! **]sesame]** 3. The node characteristic is that each sub property is linked to its parent property 1. This is contained in the ' **@** ' attribute. 2. Node characteristic is also the tree can be searched via path. @@ -437,9 +437,9 @@ CNF supports basic SQL Database structure statement generation. This is done via 1. The value of a property is delimited with an [ **#** ] tag as start, end [ **/#** ] as the ending. 1. Each property's start and end tag must stand and be on its own line, withing the body, except for the value or array attributes. 2. A value tagged property section is its text and can't contain further nested tree notes. - Invalid: ```[#[<**>]#] ``` + Invalid: ```[#[<**>]#]``` 3. Tree can contain links to other various properties, anons, that means also to other trees then the current one. - 1. A link (pointer) to an outside anon or property is specified in form of ⇾ ``` [*[ {path/name} ]*] ```. + 1. A link (pointer) to an outside anon or property is specified in form of ⇾ ```cnf [*[ {path/name} ]*]```. 1. The link can read only point to: - A repository anon or constant value. - A tree path value. @@ -451,25 +451,24 @@ CNF supports basic SQL Database structure statement generation. This is done via 2. This is currently a TREE instruction only inbuilt option in Perl CNF, for the CNF Nodes individuals scripts order of processing. 4. Links in the root parent node of the tree are assigned as attributes or unique values. In subroperties they are set as own nodes. 4. Tree Format Example: - - ```CNF - <> - - < - <**> - thread: 28 - title = My Application - client> - >> - ``` + ```cnf + <> + + < + <**> + thread: 28 + title = My Application + client> + >> + ``` ## Sample Perl Language Usage diff --git a/htdocs/cgi-bin/index.cgi b/htdocs/cgi-bin/index.cgi index de3a8dc..d8c475d 100755 --- a/htdocs/cgi-bin/index.cgi +++ b/htdocs/cgi-bin/index.cgi @@ -28,8 +28,6 @@ BEGIN { set_message(\&handle_errors); } - - use lib "system/modules"; require CNFParser; require CNFNode; @@ -45,9 +43,9 @@ sub HTMLPageBuilderFromCNF { $script_path."index.cnf",{ DO_ENABLED => 1, HAS_EXTENSIONS=>1, ANONS_ARE_PUBLIC => 1, - PAGE_HEAD => "

Index Page of Docs Directory

", - PAGE_CONTENT => $html, - PAGE_FOOT => "" + PAGE_HEAD => "

Index Page of Docs Directory

", + PAGE_CONTENT => $html, + PAGE_FOOT => "" } ); my $ptr = $cnf->data(); diff --git a/htdocs/cgi-bin/system/modules/MarkdownPlugin.pm b/htdocs/cgi-bin/system/modules/MarkdownPlugin.pm index 7166cc0..b025d9f 100644 --- a/htdocs/cgi-bin/system/modules/MarkdownPlugin.pm +++ b/htdocs/cgi-bin/system/modules/MarkdownPlugin.pm @@ -175,11 +175,17 @@ try{ my $pret = ""; $pret = $1 if $1; my $post = ""; $post = $4 if $4; $tag = 'code'; $tag =$2 if $2; - my $inline = $3; $inline = inlineCNF($inline,""); + my $inline = $3; + $inline = inlineCNF($inline,""); my @code_tag = @{ setCodeTag($tag, "") }; $ln = qq($pret<$code_tag[1] class='$code_tag[0]'>$inline$post\n); + undef $tag; if(!$pret && !$post){ $buff .= $ln; next; + }elsif($list_item){ + my $new = HTMLListItem->new('dt', $ln, $list_item->{spc}); + $list_item ->add($new); + next; } } elsif($ln =~ /^\s*```(\w*)(.*)/){ @@ -189,7 +195,7 @@ try{ $class = $code_tag[0]; $tag = $code_tag[1] if !$tag; } - if($code){ + if($code>0){ if($para){ $bfCode .= "$para\n" } @@ -477,7 +483,13 @@ sub inlineCNF($v,$spc){ if(!$body){ $oo=$cc=""; $body=$v;$v=~/^(<+)/;$oo=$1 if$1; if($v=~m/\[\#\[/){ - return "$spc[#[" + my $r = "[#["; + $v =~ s/\[\#\[/$r/g; + if($v =~ m/\]\#\]/){ + $r = "]#]"; + $v =~ s/\]\#\]/$r/g; + } + return "$spc$v" } elsif($v=~m/\]\#\]/){ return "$spc]#]" @@ -502,9 +514,10 @@ sub inlineCNF($v,$spc){ elsif($v eq '>>'){ return "$spc>>\n" } else{ - $v=~/(>+\s*)$/;if($1){ - $v = $1; $v =~ s/>/>/g; - return "$spc$v" + $v=~/(.*)(>+\s*)$/; + if(!$1 && $2){ + $v = $2; $v =~ s/>/>/g; + return "$spc$v" }else{ $oo =~ s/>>/){ @@ -512,15 +525,19 @@ sub inlineCNF($v,$spc){ }elsif($v=~m/<<<(.*)/){ return "$spc$oo$1" }elsif($v=~m/^(<{2,3})(.*?)([><])(.*)/){ - if($4){ - if($PARSER -> isReservedWord($4)){ - $v = "$4" + my $t = "$1$2$3"; + my $var = $2; + my $im = $3; + my $r = $4; + my $end =$4; + if($end){ + my $changed = ($end =~ s/(>|<)$//g); + if($PARSER -> isReservedWord($end)){ + $v = "$end"; $v .= "".($1 eq '<'?"<":">")."" if $changed }else{ - if (!$2){$v = "$4"}else{$v=""} + if (!$var){$v = "$r"}else{$v=""} } - my $t = "$1$2$3"; - my $r = $4; - if($2 =~ /[@%]/){ + if($var =~ /[@%]/){ if($r =~ /(.*)([><])(.*)/){ $v = "$spc$t$1"; $v .= "$2"; @@ -528,7 +545,7 @@ sub inlineCNF($v,$spc){ return $v; } }else{ - $v = "$spc$oo$2$3$v"; + $v = "$spc$oo$var$im$v"; if($r =~ /(\w*)\s(.*)/){ return "$v$1 $2$cc" }else{ @@ -545,7 +562,8 @@ sub inlineCNF($v,$spc){ } } } -elsif(!$oo && !$cc){ + +if(!$oo && !$cc){ $body =~ m/ ^([\[<\#\*\[<]+) (.*?) ([\]>\#\*\]>]+)$ /gmx; if($1&&$2&&$3){ @@ -565,7 +583,7 @@ elsif(!$oo && !$cc){ $oo =~ s//>/g; } - $body =~ m/ ([@%<]) ([\$@%]?\w+)? ([<>]) (.*) | + $body =~ m/ ([@%<]+) ([\$@%]?\w+)? ([<>]) (.*) | ([^<>]+) ([><])? (.*) /gmx; @@ -634,24 +652,25 @@ elsif(!$oo && !$cc){ $oo =~ s/<])(.*)/; if($1 && $2 && $3){ - $v = "$oo$1$2$3$cc" + $v = "$oo$1$2$3$cc" }else{ - $v = "$oo$body$cc" + $v = "$oo$body$cc" } - } + }elsif($2){$v = "$v"} return $spc.$v.$restIfAny } sub propValCNF($v){ - my @match = ($v =~ m/(.*)([=:])(.*)/gs); + my @match = ($v =~ m/([^:]+)([=:]+)(.*)/gs); if(@match){ + return " $1$2$3" if $2 eq '::'; return " $1$2$3" } elsif($v =~ /[><]/){ return "$v" }else{ - return "$v" + return "$v" } return $v; } @@ -659,9 +678,9 @@ sub propValCNF($v){ sub style ($script){ MarkdownPluginException->throw(error=>"Invalid argument passed as script!",show_trace=>1) if !$script; #Links - $script =~ s/<(http[:\/\w.]*)>/$1<\/a>/g; - $script =~ s/(\*\*([^\*]*)\*\*)/\$2<\/em\>/gs; - if($script =~m/[<\[]\*[<\[](.*)[\]>]\*[\]>]/){#It is a CNF link not part of standard Markup. + $script =~ s/<(http[:\/\w.]*)>/$1<\/a>/g; + $script =~ s/(\*\*([^\*]*)\*\*)/\$2<\/em\>/gs; + if($script =~ m/[<\[]\*[<\[](.*)[\]>]\*[\]>]/){#It is a CNF link not part of standard Markup. my $link = $1; my $find = $PARSER->obtainLink($link); $find = $link if(!$find); -- 2.34.1