Forgot to commit stuff ages past.

master
kts 2015-03-21 04:41:29 -07:00
parent a3b57bb001
commit ddd1e8bd63
6 changed files with 139 additions and 14 deletions

View File

@ -8,7 +8,7 @@ kettext...
* **is easy to write with** * **is easy to write with**
* **looks nice in a terminal** * **looks nice in a terminal**
* **formats wonderfully to HTML5** * **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//** * **supports writing out to other popular markup formats such as //markdown// or //textile//**
* **is a growing language that is not afraid of change** * **is a growing language that is not afraid of change**
* **contributions and enhancements are //promoted//** * **contributions and enhancements are //promoted//**

View File

@ -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.

View File

@ -1,10 +1,10 @@
.imply(header.ids) .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. 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 * Type of Element
* General description * General description
* Special rules * 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. 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:** **Possible .imply values:**
* //header.ids// -- create ids for every header from header text. Replaces spaces with underscores. * //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**: **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**: **example**:
@ -179,7 +179,9 @@ Big Header .class(big_alt)
,,,,,,,,,,,,,,,,,,,,,,,, ,,,,,,,,,,,,,,,,,,,,,,,,
4. 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**. 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 Paragraph
```````````````` ````````````````

View File

@ -219,7 +219,7 @@ sub parseFile {
} }
} }
# 3. check for small headers # 3. check for small headers
if ($lines[$i] =~ m/^(\S)\1{2,}/) { if ($lines[$i] =~ m/^(\S)\1{2,}\s/) {
my $size = $+[0]; my $size = $+[0];
my $match = substr($lines[$i], $-[0], $+[0]-$-[0]); my $match = substr($lines[$i], $-[0], $+[0]-$-[0]);
my $post = substr($lines[$i], $+[0]); my $post = substr($lines[$i], $+[0]);
@ -427,7 +427,7 @@ sub HTML {
if ($settings{'toc'}) { if ($settings{'toc'}) {
foreach (@elements) { foreach (@elements) {
if ($_->{type} == kettext::TYPE_HEADER) { 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 { } else {
@ -513,7 +513,8 @@ sub HTML {
my $open = $text_patterns[$p]; my $open = $text_patterns[$p];
my $close = $text_patterns[$p+1]; 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/($open)([^$close]*)($close)((?:\()(.*?)(?:\))|)(\.\S*\(.*?\)|)/g) {
while ($new_text =~ m/(?:\s|)($open)(.*?)($close)((?:\()(.*?)(?:\))|)(\.\S*\(.*?\)|)/g) {
my $converted_text; my $converted_text;
if ($p == 4) { if ($p == 4) {
my @media = convertLink($2); my @media = convertLink($2);
@ -523,8 +524,17 @@ sub HTML {
if ($5) { if ($5) {
$opts->{$default_opts[$i]} = $5; $opts->{$default_opts[$i]} = $5;
} }
$converted_text = $ts.convertOpts($opts).$te.$media[1]; # FIXME: dirty hack to allow [[img:image]](url) or [[img:image]].href(url) to expand to <a href="url"><img src="image"></a>
$new_text =~ s/\Q$1$2$3$4$6\E/$converted_text/g; if ($opts->{'href'} && !($media[0] eq "<a>")) {
$converted_text = "<a href=\"".$opts->{'href'}."\">";
delete $opts->{'href'};
$converted_text .= $ts.convertOpts($opts).$te.$media[1];
$converted_text .= "</a>";
$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 { } else {
my $ts = substr($text_replace[$p], 0, -1); my $ts = substr($text_replace[$p], 0, -1);
my $te = substr($text_replace[$p], -1); my $te = substr($text_replace[$p], -1);

View File

@ -4,4 +4,10 @@
[[img:my_image.png]] [[img:my_image.png]]
[[img:my_image.png]](test)
[[img:my_image.png]].href(test)
[[my link]](test2)
[[my link]].href(lol) [[my link]].href(lol)

View File

@ -1,4 +1,14 @@
Okay **test**.name(yo).class(hi) //balls//.name(it) **lol** Okay **test**.name(yo).class(hi) //bold//.name(it) **lol**
This is [[a link]].href(#classics). I like to //fly//. This is [[a link]].href(#classics).
**bold//italics//**
**//both//**
//italics**bold**//
//**both**//
**[[my bold link]](yep)**.class(boldclass)
okay okay