diff --git a/.kettext.pl.swp b/.kettext.pl.swp
deleted file mode 100644
index b5d72b4..0000000
Binary files a/.kettext.pl.swp and /dev/null differ
diff --git a/documentation/kettext_rules.ktx b/documentation/kettext_rules.ktx
index 20aff5f..3aa51f7 100644
--- a/documentation/kettext_rules.ktx
+++ b/documentation/kettext_rules.ktx
@@ -1,6 +1,6 @@
.imply(header.ids)
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
-kettext Rules
+Syntax
````````````````````````````````
As is the case with most any syntax, the best way to learn is to view the end product and the syntax used to generate it.
@@ -10,7 +10,7 @@ However, so as to avoid creating examples of every syntax permutation possible,
* Special rules
* Example(s) and Source(s)
,,,,,,,,,,,,,,,,,,,,,,,,
-Formatting rules
+1. Formatting rules
````````````````````````
,,,,,,,,,,,,,,,,
.imply
@@ -25,6 +25,7 @@ This line must start at the end and/or the beginning of the document and contain
* //header.ids// -- create ids for every header from header text. Replaces spaces with underscores.
* //header.depth// -- set the starting depth of headers. Defaults to 0.
* //header.reverse// -- sets smaller headers to be considered as greater, e.g., "==== header ====" is greater than "====== header ======"
+ * //header.numbering// -- automatically number headers relative to a parent header and prepend this value to the header content.
* //version.hide// -- embeds the version of kettext used to create the document in a hidden format. Otherwise is added as a footer.
* //version.none// -- completely removes version information from the output.
@@ -42,7 +43,7 @@ The placement of formatters varies between the elements, but the general syntax
# .some_option(some_value).other_option(other_value)
,,,,,,,,,,,,,,,,,,,,,,,,
-Font styling and anchors
+2. Font styling and anchors
````````````````````````
Font may be styled in any of the following manners:
@@ -80,7 +81,7 @@ If using an HTML convertor, you can pass CSS styling directly:
[[link]].href(http://kettek.exoss.net).style(border:1px solid red)
,,,,,,,,,,,,,,,,,,,,,,,,
-Headers
+3. Headers
````````````````````````
A header is some prominently formatted text that precedes a larger section of text and acts as a demarker. Headers are sized in order of precedence, with larger visual headers being considered the parent of smaller headers contained within.
@@ -152,7 +153,7 @@ Formatters are placed at the end of the content line:
Big Header .class(big_alt)
````````````
,,,,,,,,,,,,,,,,,,,,,,,,
-Text Blocks
+4. Text Blocks
````````````````````````
Text blocks are a larger collection of text that may or may not span multiple lines. kettext uses 4 unique text blocks: **paragraph**, **preformatted**, **code**, and **block quote**.
,,,,,,,,,,,,,,,,
diff --git a/kettext.pl b/kettext.pl
index 75e6a3c..1daf2dc 100755
--- a/kettext.pl
+++ b/kettext.pl
@@ -320,6 +320,13 @@ for (my $h_i = 0; $h_i < scalar @headers; $h_i++) {
}
}
+# set up our array for header numbering. The first element
+my @header_numbers;
+for (my $h_i = 0; $h_i < scalar @headers; $h_i++) {
+ $header_numbers[$h_i] = 0;
+}
+my $header_number = 0; # at which numbering depth are we
+
# print 'em out
if ($settings{'toc'}) {
foreach (@elements) {
@@ -334,9 +341,17 @@ if ($settings{'toc'}) {
if ($_->{type} == TYPE_HEADER) {
my $hsize = $header_map{$_->{size}};
my $htext = $_->{text};
+ if ($settings{"header.numbering"}) {
+ $header_number = $hsize;
+ for (my $h_i = $header_number+1; $h_i < scalar @headers; $h_i++) {
+ $header_numbers[$h_i] = 0;
+ }
+ $header_numbers[$header_number]++;
+ $htext = ($settings{"header.numbering"} ? $header_numbers[$header_number].'. ' : '') . $htext;
+ }
my $hid = $_->{text};
$hid =~ s/ /_/g;
- print("{opts} ? $_->{opts} : '').($settings{'header.ids'} ? " id=\"".$hid."\"" : '').">$_->{text}\n");
+ print("{opts} ? $_->{opts} : '').($settings{'header.ids'} ? " id=\"".$hid."\"" : '').">$htext\n");
} elsif ($_->{type} == TYPE_BREAK) {
if ($previous_type == TYPE_BREAK) {
print("
\n");