diff --git a/.gitignore b/.gitignore index a6f976c..1a9965b 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ raku-pod-render.iml /.sass-cache/ /problems/ /check/ +/dump diff --git a/lib/ProcessedPod.rakumod b/lib/ProcessedPod.rakumod index 3825aed..2f0934f 100644 --- a/lib/ProcessedPod.rakumod +++ b/lib/ProcessedPod.rakumod @@ -40,6 +40,25 @@ grammar FC { # TODO: use "make" to pull inside-quotes value to meta } +#| Class for setting numeration of headings and items +class Numeration { + has Int @!counters is default(0); + method Str () { @!counters>>.Str.join('.') ~ '.' } + method inc ($level) { + @!counters[$level - 1]++; + @!counters.splice($level); + self + } + method reset () { + @!counters = Nil; + self + } + method set ( $level, $value ) { + @!counters[ $level - 1 ] = $value; + self + } +} + #| the name of the anchor at the top of a source file constant DEFAULT_TOP = '___top'; @@ -178,9 +197,14 @@ class ProcessedPod does SetupTemplates { # variables to manage Pod state, where rendering is dependent on local context #| for multilevel lists has @.itemlist; + #| item counter + has Numeration $.item-counter .= new; #| used to register state when processing a definition list has Bool $!in-defn-list = False; + #| for numbered headings + has Numeration $.header-counter .=new; + #| the Config stack has @.config-stack ; #| contains the configuration for the outer pod/rakudoc block @@ -597,15 +621,16 @@ class ProcessedPod does SetupTemplates { my $template = $node.config