diff --git a/documentation/kettext_define.ktx b/documentation/kettext_define.ktx
index a1042bf..77c91ae 100644
--- a/documentation/kettext_define.ktx
+++ b/documentation/kettext_define.ktx
@@ -8,7 +8,7 @@ kettext...
* **is easy to write with**
* **looks nice in a terminal**
* **formats wonderfully to HTML5**
- * **provides support for modern video and audio embedding**
+ * **provides native support for modern video and audio embedding**
* **supports writing out to other popular markup formats such as //markdown// or //textile//**
* **is a growing language that is not afraid of change**
* **contributions and enhancements are //promoted//**
diff --git a/documentation/kettext_formatting.ktx b/documentation/kettext_formatting.ktx
new file mode 100644
index 0000000..c665ccf
--- /dev/null
+++ b/documentation/kettext_formatting.ktx
@@ -0,0 +1,97 @@
+,,,,,,,,,,,,,,,,,,,,,,,,
+Formatting in Brief
+````````````````````````
+kettext's general text formatting is styled after standard online communications. Those familiar with Markdown will note that similarity, and this is for good reason -- it works well.
+
+This section only covers the basic and non-processing features of kettext, and as such, is more of the stylistic definition.
+
+,,,,,,,,,,,,,,,,
+Text Formatting
+````````````````
+Within a [[text block]](#Text_Blocks), sections of text may be surrounded by styling indicators. These lexical indicators use the following patterns:
+
+ #*emphasis*
+ #**bold**
+ #_underline_
+ #//italic//
+ #((note))
+ #[[link]]
+ #``code``
+,,,,,,,,,,,,,,,,
+Text Blocks
+````````````````
+Text blocks are sections of text that are organized into the follow categories:
+
+ * **paragraph**
+ * **preformatted**
+ * **code**
+ * **blockquote**
+
+A text block continues until a completely empty line is found _or_ a differing block type, [[List]](#Lists), or [[Header]](#Headers) is found. [[Text formatting]](#Text_Formatting) is assumed to only work in paragraphs, and only conditionally in blockquotes (see: [[Block Formatters]](#Block_Formatters)).
+
+Paragraph text blocks are very straight-forward:
+
+ #This is a paragraph.
+ #It can span multiple lines.
+ #
+ #This is a separate paragraph.
+
+Preformatted text blocks must have every line indented via a tab or 2 spaces:
+
+ # This is a preformatted text block.
+ # It can also span multiple lines.
+ #
+ # This is the same preformatted text block due to the above line using indentation.
+
+Code text blocks are intended as per preformatted text, but must have a "#" immediately following indentation:
+
+ # # This is a code text block.
+ # # It also spans multiple lines.
+ # #
+ # # This is also the same code text block due to the above indentation and "#" sign.
+
+Blockquote text blocks are signified by having every line begin with ">".
+
+ # > Blockquotes can also span
+ # > multiple lines!
+ # >
+ # > and can be considered as one quote if empty lines are indented properly.
+
+,,,,,,,,,,,,,,,,
+Lists
+````````````````
+Lists are organized outlines of items. Lists are indicated by a tab or 2 spaces followed by any of the following:
+ #*
+ #~
+ #-
+ #+
+ #3 characters followed by a "."
+
+List depth is controlled by the level of indentation provided:
+
+ # * Item 1
+ # * Sub-item 1
+ # * Item 2
+
+,,,,,,,,,,,,,,,,
+Headers
+````````````````
+Headers come in two styles. The first is the single-line header, indicated by a non-space character repeating at least 2 times:
+
+ # ==== Header
+
+Single-line headers may have an optional close indicator, providing it exactly matches the opening indicator:
+
+ # ==== Header ====
+
+The level of character repitition provides the level of depth, with larger repititions indicating a higher precedence as a header. This behavior can be reversed, as indicated in [[Header Formatting]](#Header_Formatters).
+
+Multi-line headers are indicated by three lines: a start line, containing non-space characters repeating at least 2 times, a heading line, and a closing line operating under the same rules as the start line.
+
+ # ,,,,,,,,
+ # Header
+ # ````````
+
+The start line indicates the precedence of the header, which larger repititions indicating higher precedence. As per single-line headers, this behavior can optionally be reversed.
+
+Start and close lines do not have to have the same characters, nor do they have to have the same length.
diff --git a/documentation/kettext_rules.ktx b/documentation/kettext_rules.ktx
index 880f00c..5f9c72a 100644
--- a/documentation/kettext_rules.ktx
+++ b/documentation/kettext_rules.ktx
@@ -1,10 +1,10 @@
.imply(header.ids)
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
-Syntax
+Complete 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.
-However, so as to avoid creating examples of every syntax permutation possible, this section is organized in the following manner:
+To avoid creating examples of every syntax permutation possible, this section is organized in the following manner:
* Type of Element
* General description
* Special rules
@@ -19,7 +19,7 @@ However, so as to avoid creating examples of every syntax permutation possible,
imply rules influence the parsing and conversion of markup on a document-wide level. Through these rules, you can change header sizing behaviors, output tables of contents, create logical sections of converted elements for use in visual styling, and much more.
-This line must start at the end and/or the beginning of the document and contains the rules inside the ".imply()" formatter. An example would be:
+This line must start at the end and/or the beginning of the document and contains the rules inside the ".imply()" formatter.
**Possible .imply values:**
* //header.ids// -- create ids for every header from header text. Replaces spaces with underscores.
@@ -103,7 +103,7 @@ Small headers are similar to other markup languages' headers, but allow for more
----
-Headers may use any character to signify their lead or close:
+Small headers may use any character to signify their lead or close. A space is also required after the lead:
**example**:
@@ -112,7 +112,7 @@ Headers may use any character to signify their lead or close:
----
-Headers do not require a close:
+Small headers do not require a close:
**example**:
@@ -179,7 +179,9 @@ Big Header .class(big_alt)
,,,,,,,,,,,,,,,,,,,,,,,,
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**.
+Text blocks are a larger collection of text that may span multiple lines. kettext uses 4 unique text blocks: **paragraph**, **preformatted**, **code**, and **block quote**.
+
+Universal to all text blocks is the special ".include" command. This command searches for the given file relative to the file being parsed and includes it. For **preformatted** and **code** this file is __unparsed__. For **paragraph** it replaces the paragraph block with the parsed file. //.imply// rules are inherited from the parent kettext file being parsed.
,,,,,,,,,,,,,,,,
Paragraph
````````````````
diff --git a/kettext.pm b/kettext.pm
index 4bc3294..ecbda9b 100644
--- a/kettext.pm
+++ b/kettext.pm
@@ -219,7 +219,7 @@ sub parseFile {
}
}
# 3. check for small headers
- if ($lines[$i] =~ m/^(\S)\1{2,}/) {
+ if ($lines[$i] =~ m/^(\S)\1{2,}\s/) {
my $size = $+[0];
my $match = substr($lines[$i], $-[0], $+[0]-$-[0]);
my $post = substr($lines[$i], $+[0]);
@@ -427,7 +427,7 @@ sub HTML {
if ($settings{'toc'}) {
foreach (@elements) {
if ($_->{type} == kettext::TYPE_HEADER) {
-
+ # TODO: collect and organize TYPE_HEADER elements into TYPE_LIST element. Use header IDs and surround in anchors appropriately.
}
}
} else {
@@ -513,7 +513,8 @@ sub HTML {
my $open = $text_patterns[$p];
my $close = $text_patterns[$p+1];
#while ($new_text =~ m/($open)([^$close]*)($close)(\.\S*\(.*?\)|)/g) {
- while ($new_text =~ m/($open)([^$close]*)($close)((?:\()(.*?)(?:\))|)(\.\S*\(.*?\)|)/g) {
+ #while ($new_text =~ m/($open)([^$close]*)($close)((?:\()(.*?)(?:\))|)(\.\S*\(.*?\)|)/g) {
+ while ($new_text =~ m/(?:\s|)($open)(.*?)($close)((?:\()(.*?)(?:\))|)(\.\S*\(.*?\)|)/g) {
my $converted_text;
if ($p == 4) {
my @media = convertLink($2);
@@ -523,8 +524,17 @@ sub HTML {
if ($5) {
$opts->{$default_opts[$i]} = $5;
}
- $converted_text = $ts.convertOpts($opts).$te.$media[1];
- $new_text =~ s/\Q$1$2$3$4$6\E/$converted_text/g;
+ # FIXME: dirty hack to allow [[img:image]](url) or [[img:image]].href(url) to expand to
+ if ($opts->{'href'} && !($media[0] eq "")) {
+ $converted_text = "{'href'}."\">";
+ delete $opts->{'href'};
+ $converted_text .= $ts.convertOpts($opts).$te.$media[1];
+ $converted_text .= "";
+ $new_text =~ s/\Q$1$2$3$4$6\E/$converted_text/g;
+ } else {
+ $converted_text = $ts.convertOpts($opts).$te.$media[1];
+ $new_text =~ s/\Q$1$2$3$4$6\E/$converted_text/g;
+ }
} else {
my $ts = substr($text_replace[$p], 0, -1);
my $te = substr($text_replace[$p], -1);
diff --git a/test/media_url.ktx b/test/media_url.ktx
index b01a503..752a5e8 100644
--- a/test/media_url.ktx
+++ b/test/media_url.ktx
@@ -4,4 +4,10 @@
[[img:my_image.png]]
+[[img:my_image.png]](test)
+
+[[img:my_image.png]].href(test)
+
+[[my link]](test2)
+
[[my link]].href(lol)
diff --git a/test/text.ktx b/test/text.ktx
index 05a6ae1..c349b0b 100644
--- a/test/text.ktx
+++ b/test/text.ktx
@@ -1,4 +1,14 @@
-Okay **test**.name(yo).class(hi) //balls//.name(it) **lol**
-This is [[a link]].href(#classics). I like to //fly//.
+Okay **test**.name(yo).class(hi) //bold//.name(it) **lol**
+This is [[a link]].href(#classics).
+
+**bold//italics//**
+
+**//both//**
+
+//italics**bold**//
+
+//**both**//
+
+**[[my bold link]](yep)**.class(boldclass)
okay