Rename to root

This commit is contained in:
Aoran Zeng 2025-07-16 00:23:09 +08:00
parent 676089ee7a
commit 4e5003f36e
No known key found for this signature in database
GPG Key ID: 8F8BA8488E10ED98
3 changed files with 10 additions and 11 deletions

View File

@ -1,8 +1,8 @@
- global-prefix = `GLOBAL_` - root-prefix = `GLOBAL_`
- global-output = `:terminal` - root-output = `:terminal`
```c ```c
int global_code_block = 1; int root_code_block = 1;
``` ```
some comments some comments

View File

@ -11,8 +11,8 @@
use lib '../lib'; use lib '../lib';
use Parser; use Parser;
my $test-file1 = './fixture/test-hierarchy-with-global.md'.IO; my $test-file1 = './fixture/test-hierarchy-with-root.md'.IO;
my $test-file2 = './fixture/test-hierarchy-without-global.md'.IO; my $test-file2 = './fixture/test-hierarchy-without-root.md'.IO;
my $parser1 = Parser::Parser.new($test-file1); my $parser1 = Parser::Parser.new($test-file1);
my $parser2 = Parser::Parser.new($test-file2); my $parser2 = Parser::Parser.new($test-file2);
@ -24,9 +24,9 @@ sub print-sections-flatly($parser)
{ {
say "====== sections ======"; say "====== sections ======";
for $parser.sections.kv -> $i, $section { for $parser.sections.kv -> $i, $section {
my $title = $section.title || "(Global)"; my $title = $section.title || "(Root)";
my $has-config = $section.config.keys ?? "" !! ""; my $has-config = $section.config.keys ?? "" !! "";
my $has-code = $section.raw-string ?? "" !! ""; my $has-code = $section.codeblock ?? "" !! "";
say " [$i] Level {$section.level}: $title - $has-config, $has-code"; say " [$i] Level {$section.level}: $title - $has-config, $has-code";
} }
} }
@ -40,7 +40,7 @@ sub print-sections-hierarchyly($parser) {
sub format-section($section, $level) { sub format-section($section, $level) {
my $prefix = ' ' x $level; my $prefix = ' ' x $level;
my $title = $section.title // '(Global)'; my $title = $section.title // '(Root)';
return "{$prefix}- {$title} (level {$section.level})"; return "{$prefix}- {$title} (level {$section.level})";
} }
@ -54,9 +54,8 @@ sub print-sections-hierarchyly($parser) {
} }
} }
# 从parser的global section开始打印 my $root = $parser.root-section();
my $global = $parser.global-section(); print-section-tree($root, $indent);
print-section-tree($global, $indent);
} }