diff --git a/README.md b/README.md
index a064bf6..461ffc6 100644
--- a/README.md
+++ b/README.md
@@ -13,17 +13,15 @@ Headline 5: (l5: Headline5)
Headline 6: (l6: Headline6)
##Additional Options
-The following are additional options for formatting the table of contents and the contained links
+The following are additional options for formatting the table of contents and the contained links. All parameters go into the (toc) tag.
- levelchar: Allows to change the character used to separate different levels in the table of contents, usage: *levelchar: >* or *levelchar: space*
-
-Note that the following options change the link behavior and thus need to be added to all tags that are supposed to work together, so the (toc), as well as all (l1), (l2), etc.
- split: Allows to change the replacement character for a space, example usage: *split: -*
- lowercase: Allows to change all letters in the link to lowercase, usage: *lowercase: 1*
###Example
(toc:6 split: - lowercase: 1 levelchar: >)
-(l2: Test test�? split: - lowercase: 1)
-(l3: Test2 test�? split: - lowercase: 1)
+(l2: Test test�?)
+(l3: Test2 test�?)
##Installation
copy to your kirby/site/tags folder
diff --git a/site/tags/sections.php b/site/tags/sections.php
index 55445c3..adc1eb8 100644
--- a/site/tags/sections.php
+++ b/site/tags/sections.php
@@ -2,15 +2,42 @@
kirbytext::$tags['l1'] = array(
'attr' => array(
- 'split',
- 'lowercase'
),
'html' => function($tag) {
- $link = $tag->attr('l1');
+
+ foreach($tag->page()->content() as $link) {
+ $cnt+=1;
+ if($cnt==3) {
+ preg_match_all("/\(toc: .*\)/", $link, $tocs);
+ foreach ($tocs[0] as $toc) {
+ preg_match_all("/lowercase:(\ )?[0,1]?/", $toc, $parameters);
+ foreach ($parameters[0] as $param) {
+ $param = preg_replace("/lowercase:/", "", $param);
+ $param = preg_replace("/\ /", "", $param);
+ if($param==1)
+ {
+ $lowercase=1;
+ }
+ else
+ {
+ $lowercase=0;
+ }
+ }
+ $splitchar = '%20';
+ preg_match_all("/split:(\ )?./", $toc, $parameters);
+ foreach ($parameters[0] as $param) {
+ $param = preg_replace("/split:(\ )?/", "", $param);
+ $param = preg_replace("/\ ./", "", $param);
+ $splitchar = $param;
+ }
+ }
+ }
+ }
+
+ $link = $tag->attr('l1');
$link = preg_replace("/[^ \w]+/", "", $link);
- $splitchar = $tag->attr('split', "%20");
$link = str_replace(" ", $splitchar, $link);
- if($tag->attr('lowercase')==1) {
+ if($lowercase==1) {
$link = strtolower($link);
}
return '
';
@@ -23,11 +50,40 @@
'lowercase'
),
'html' => function($tag) {
+
+ foreach($tag->page()->content() as $link) {
+ $cnt+=1;
+ if($cnt==3) {
+ preg_match_all("/\(toc: .*\)/", $link, $tocs);
+ foreach ($tocs[0] as $toc) {
+ preg_match_all("/lowercase:(\ )?[0,1]?/", $toc, $parameters);
+ foreach ($parameters[0] as $param) {
+ $param = preg_replace("/lowercase:/", "", $param);
+ $param = preg_replace("/\ /", "", $param);
+ if($param==1)
+ {
+ $lowercase=1;
+ }
+ else
+ {
+ $lowercase=0;
+ }
+ }
+ $splitchar = '%20';
+ preg_match_all("/split:(\ )?./", $toc, $parameters);
+ foreach ($parameters[0] as $param) {
+ $param = preg_replace("/split:(\ )?/", "", $param);
+ $param = preg_replace("/\ ./", "", $param);
+ $splitchar = $param;
+ }
+ }
+ }
+ }
+
$link = $tag->attr('l2');
$link = preg_replace("/[^ \w]+/", "", $link);
- $splitchar = $tag->attr('split', "%20");
$link = str_replace(" ", $splitchar, $link);
- if($tag->attr('lowercase')==1) {
+ if($lowercase==1) {
$link = strtolower($link);
}
return '';
@@ -40,11 +96,40 @@
'lowercase'
),
'html' => function($tag) {
+
+ foreach($tag->page()->content() as $link) {
+ $cnt+=1;
+ if($cnt==3) {
+ preg_match_all("/\(toc: .*\)/", $link, $tocs);
+ foreach ($tocs[0] as $toc) {
+ preg_match_all("/lowercase:(\ )?[0,1]?/", $toc, $parameters);
+ foreach ($parameters[0] as $param) {
+ $param = preg_replace("/lowercase:/", "", $param);
+ $param = preg_replace("/\ /", "", $param);
+ if($param==1)
+ {
+ $lowercase=1;
+ }
+ else
+ {
+ $lowercase=0;
+ }
+ }
+ $splitchar = '%20';
+ preg_match_all("/split:(\ )?./", $toc, $parameters);
+ foreach ($parameters[0] as $param) {
+ $param = preg_replace("/split:(\ )?/", "", $param);
+ $param = preg_replace("/\ ./", "", $param);
+ $splitchar = $param;
+ }
+ }
+ }
+ }
+
$link = $tag->attr('l3');
$link = preg_replace("/[^ \w]+/", "", $link);
- $splitchar = $tag->attr('split', "%20");
$link = str_replace(" ", $splitchar, $link);
- if($tag->attr('lowercase')==1) {
+ if($lowercase==1) {
$link = strtolower($link);
}
return '';
@@ -57,11 +142,40 @@
'lowercase'
),
'html' => function($tag) {
+
+ foreach($tag->page()->content() as $link) {
+ $cnt+=1;
+ if($cnt==3) {
+ preg_match_all("/\(toc: .*\)/", $link, $tocs);
+ foreach ($tocs[0] as $toc) {
+ preg_match_all("/lowercase:(\ )?[0,1]?/", $toc, $parameters);
+ foreach ($parameters[0] as $param) {
+ $param = preg_replace("/lowercase:/", "", $param);
+ $param = preg_replace("/\ /", "", $param);
+ if($param==1)
+ {
+ $lowercase=1;
+ }
+ else
+ {
+ $lowercase=0;
+ }
+ }
+ $splitchar = '%20';
+ preg_match_all("/split:(\ )?./", $toc, $parameters);
+ foreach ($parameters[0] as $param) {
+ $param = preg_replace("/split:(\ )?/", "", $param);
+ $param = preg_replace("/\ ./", "", $param);
+ $splitchar = $param;
+ }
+ }
+ }
+ }
+
$link = $tag->attr('l4');
$link = preg_replace("/[^ \w]+/", "", $link);
- $splitchar = $tag->attr('split', "%20");
$link = str_replace(" ", $splitchar, $link);
- if($tag->attr('lowercase')==1) {
+ if($lowercase==1) {
$link = strtolower($link);
}
return '';
@@ -74,11 +188,40 @@
'lowercase'
),
'html' => function($tag) {
+
+ foreach($tag->page()->content() as $link) {
+ $cnt+=1;
+ if($cnt==3) {
+ preg_match_all("/\(toc: .*\)/", $link, $tocs);
+ foreach ($tocs[0] as $toc) {
+ preg_match_all("/lowercase:(\ )?[0,1]?/", $toc, $parameters);
+ foreach ($parameters[0] as $param) {
+ $param = preg_replace("/lowercase:/", "", $param);
+ $param = preg_replace("/\ /", "", $param);
+ if($param==1)
+ {
+ $lowercase=1;
+ }
+ else
+ {
+ $lowercase=0;
+ }
+ }
+ $splitchar = '%20';
+ preg_match_all("/split:(\ )?./", $toc, $parameters);
+ foreach ($parameters[0] as $param) {
+ $param = preg_replace("/split:(\ )?/", "", $param);
+ $param = preg_replace("/\ ./", "", $param);
+ $splitchar = $param;
+ }
+ }
+ }
+ }
+
$link = $tag->attr('l5');
$link = preg_replace("/[^ \w]+/", "", $link);
- $splitchar = $tag->attr('split', "%20");
$link = str_replace(" ", $splitchar, $link);
- if($tag->attr('lowercase')==1) {
+ if($lowercase==1) {
$link = strtolower($link);
}
return '';
@@ -91,11 +234,40 @@
'lowercase'
),
'html' => function($tag) {
+
+ foreach($tag->page()->content() as $link) {
+ $cnt+=1;
+ if($cnt==3) {
+ preg_match_all("/\(toc: .*\)/", $link, $tocs);
+ foreach ($tocs[0] as $toc) {
+ preg_match_all("/lowercase:(\ )?[0,1]?/", $toc, $parameters);
+ foreach ($parameters[0] as $param) {
+ $param = preg_replace("/lowercase:/", "", $param);
+ $param = preg_replace("/\ /", "", $param);
+ if($param==1)
+ {
+ $lowercase=1;
+ }
+ else
+ {
+ $lowercase=0;
+ }
+ }
+ $splitchar = '%20';
+ preg_match_all("/split:(\ )?./", $toc, $parameters);
+ foreach ($parameters[0] as $param) {
+ $param = preg_replace("/split:(\ )?/", "", $param);
+ $param = preg_replace("/\ ./", "", $param);
+ $splitchar = $param;
+ }
+ }
+ }
+ }
+
$link = $tag->attr('l6');
$link = preg_replace("/[^ \w]+/", "", $link);
- $splitchar = $tag->attr('split', "%20");
$link = str_replace(" ", $splitchar, $link);
- if($tag->attr('lowercase')==1) {
+ if($lowercase==1) {
$link = strtolower($link);
}
return '';
@@ -125,28 +297,27 @@
$name = preg_split("/\(l[1-6]?: /",$heading);
$name = preg_split("/\)/",$name[1]);
$link = $name[0];
- $link = preg_replace("/\ split: ./", "", $link);
- $link = preg_replace("/\ lowercase: \d/", "", $link);
- // $link = normalizer_normalize( $name[0], Normalizer::FORM_C );
+
$link = preg_replace("/[^ \w]+/", "", $link);
$link = str_replace(" ", $splitchar, $link);
$link = htmlentities($link);
- if($tag->attr('lowercase')==1) {
- $link = strtolower($link);
- }
$number = preg_split("/\(l/",$heading);
$number = preg_split("/: .*\)/",$number[1]);
$number = $number[0];
+ if($tag->attr('lowercase')==1) {
+ $link = strtolower($link);
+ }
+
if($number <= $tag->attr('toc'))
{
for ($x = 2; $x < $number; $x++) {
$html .= $levelchar.' ';
}
- $name = preg_replace("/\ split: ./", "", $name[0]);
- $name = preg_replace("/\ lowercase: \d/", "", $name);
+ $name = preg_replace("/\ split:(\ )?./", "", $name[0]);
+ $name = preg_replace("/\ lowercase:(\ )?\d/", "", $name);
$html .= '