Small header check now must be at beginning of string without any spaces. Match text now surrounded by \Q and \E so the match is not read as regex. Lightly modified documentation
parent
9bc47652d7
commit
275ec64dd1
|
@ -2,6 +2,7 @@
|
|||
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
kettext...
|
||||
````````````````````````````````
|
||||
* **is a markup language**
|
||||
* **is for the design-inclined programmer**
|
||||
* **is easy to write with**
|
||||
* **looks nice in a terminal**
|
||||
|
|
|
@ -3,12 +3,12 @@ A Brief History of kettext
|
|||
````````````````````````````````
|
||||
From a linguistics perspective, kettext is the formal definition of a more loose internal documentation/note format I've used for many of my projects. However, the reason it came to be a formal syntax is a bit more involved.
|
||||
|
||||
When I released the procedural generation library, [[proclib]].href(../proclib/), I wrote some brief documentation for it on its [[itch.io page]].href(http://kts_kettek.itch.io/proclib). Due to preferring self-hosting, I wanted to have the same documentation under my webserver as was on the itch.io page. However, this led to some formatting issues, as itch.io's HTML source output tended towards breakage when modifying lists and similar - it also meant that the original source would be itch.io.
|
||||
When I released the procedural generation library, [[proclib]].href(proclib/), I wrote some brief documentation for it on its [[itch.io page]].href(http://kts_kettek.itch.io/proclib). Due to preferring self-hosting, I wanted to have the same documentation under my webserver as was on the itch.io page. However, this led to some formatting issues, as itch.io's HTML source output tended towards breakage when modifying lists and similar - it also meant that the original source would be itch.io.
|
||||
|
||||
From this, I figured I would convert the documentation into a markup language and convert from that to both itch.io and my own page. However, after trying various markup languages, such as markdown and textile, I found them to be quite limiting when wanting to implement some HTML-centric options (such as class, name, and similar).
|
||||
|
||||
As a result, I decided to format the source text into the documentation/note format that I had become accustomed to using. This meant that I would have to write a parser and converter -- something I did not initially feel inclined to do due to other projects.
|
||||
|
||||
However, given that I use this private format for internal documentation and my own notes, it seemed to be the logical thing to do. Furthermore, it gave me an excuse to pick up Perl(((after over 5 years!))) and actually learn to use regular expressions.
|
||||
However, given that I use this private format for internal documentation and my own notes, it seemed to be the logical thing to do. Furthermore, it gave me an excuse to pick up Perl ((after over 5 years!)) and actually learn to use regular expressions.
|
||||
|
||||
What was born from this was a codified version of my internal documentation format -- //kettext// -- and the accompanying parser/converter, **kettext.pl**.
|
||||
|
|
|
@ -185,7 +185,7 @@ for (my $i = 0; $i <= $#lines; $i++) {
|
|||
}
|
||||
}
|
||||
# 3. check for small headers
|
||||
if ($lines[$i] =~ m/(\S)\1{2,}/) {
|
||||
if ($lines[$i] =~ m/^(\S)\1{2,}/) {
|
||||
my $size = $+[0];
|
||||
my $match = substr($lines[$i], $-[0], $+[0]-$-[0]);
|
||||
my $post = substr($lines[$i], $+[0]);
|
||||
|
@ -194,7 +194,7 @@ for (my $i = 0; $i <= $#lines; $i++) {
|
|||
# e.g., ==== header ====
|
||||
# otherwise match if there is some text following
|
||||
# e.g., ==== header
|
||||
if ($post =~ m/(\t*|\s*|)(.*)$match$/g) {
|
||||
if ($post =~ m/(\t*|\s*|)(.*)\Q$match\E$/g) {
|
||||
if (%block) { push @elements, {%block}; %block=() }
|
||||
if ($2 =~ m/^(.*?)(\..*\))/) {
|
||||
push @elements, {
|
||||
|
|
Loading…
Reference in New Issue