Browse files

* added Changelog to prepare release of 0.3.0

* removed /example/online/ branch from repository
* fixed handling of "0" string in the lexer
* add syntax hilight example


git-svn-id: svn+ssh://faui2k3.org/var/lib/svn/moritz/mowyw@284 addfbb1e-f4f9-0310-b6f0-bccd0f9b8dc6
  • Loading branch information...
1 parent 34e019f commit b49857051a95281b4c81b000b834d297e5935617 moritz committed Apr 4, 2007
View
6 Changelog
@@ -1,3 +1,9 @@
+mowyw (0.3.0)
+ * mowyw: Added support for syntax highliting, variables and comments
+ * README: update accordingly
+ * example/source/bar.shtml: added syntax hilighting example
+ * example/source/style.css: added syntax hilighting classes
+ * Mowyw/Lexer.pm: fixed handling of "0" string
mowyw (0.2.0)
* Mowyw/Lexer.pm: added a separate lexer
* mowyw: (nearly) complete rewrite using a recursive-descending parser
View
2 Mowyw/Lexer.pm
@@ -55,7 +55,7 @@ our %EXPORT_TAGS = (":all" => \@EXPORT);
sub lex($$){
my ($text, $tokens) = @_;
- return () unless ($text);
+ return () unless (length $text);
my @res;
while (length($text) > 0){
my $matched = 0;
View
3 README
@@ -166,6 +166,9 @@ sub blubb {
}
[[[endsyntax]]]</pre>
+If you don't have Text::VimColor installed, the characters '&', '<' and '>'
+will still be automatically escaped.
+
The only argument to 'syntax' is the language that the code is in, if you use
a value that vim doesn't know it will try to guess the language.
View
1 example/incl_test
@@ -1 +0,0 @@
-[[[include head2]]]
View
51 example/online/bar.shtml
@@ -1,51 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
-<head>
-<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
-<link rel="stylesheet" type="text/css" media="screen, projection" href="style.css" />
-<link rel="stylesheet" type="text/css" media="print" href="print.css" />
-<title>Mowyw example: page `bar'</title>
-</head>
-
-<body id="home">
-
-<div id="header">
- <h1>Mowyw Example</h1>
- <p>Lore Impsum</p>
-</div>
-<div id="nav-page">
-<h2>Quick access</h2>
-<ul>
-<li><a href="#nav-main">Site navigation</a></li>
-<li><a href="#nav-secondary">Recent articles</a></li>
-</ul>
-</div>
-
-<div id="content-main">
-
-
-<h2>Some Foo Bar</h2>
-
-<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed ut dui ac lacus egestas vehicula. Quisque faucibus, risus id consequat porta, orci ligula condimentum mi, ac commodo leo libero eget tortor. Maecenas a ligula in nibh luctus gravida. Praesent vehicula rhoncus tortor. <a href="#">Donec porta rutrum dui.</a> Donec dignissim congue mauris. Sed rhoncus laoreet sem. Nam dui pede, vestibulum convallis, posuere ut, dictum eu, diam. Phasellus nunc. Ut eget ante a ipsum porttitor scelerisque. Quisque auctor elit vitae massa. Vestibulum massa risus, gravida quis, hendrerit sit amet, bibendum sit amet, enim. Fusce nulla. Quisque vulputate metus vitae orci. Pellentesque at arcu. Ut sed neque.</p>
-
-</div>
-
-<div id="nav-main">
-<h2>Navigation</h2>
-<ul>
- <li><a href="index.shtml">Home</a></li>
- <li><a href="foo.shtml">foo</a>
-</li>
- <li><a class="active" href="bar.shtml">bar</a></li>
-</ul>
-</div>
-
-
-<p id="footer">
-Powered by <a href="http://moritz.faui2k3.org/en/mowyw">mowyw</a> | <a href="#">Imprint</a> | Design by Dimiter Petrov
-</p>
-
-</body>
-</html>
View
58 example/online/foo.shtml
@@ -1,58 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
-<head>
-<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
-<link rel="stylesheet" type="text/css" media="screen, projection" href="style.css" />
-<link rel="stylesheet" type="text/css" media="print" href="print.css" />
-<title>Mowyw example: page foo</title>
-</head>
-
-<body id="home">
-
-<div id="header">
- <h1>Mowyw Example</h1>
- <p>Lore Impsum</p>
-</div>
-<div id="nav-page">
-<h2>Quick access</h2>
-<ul>
-<li><a href="#nav-main">Site navigation</a></li>
-<li><a href="#nav-secondary">Recent articles</a></li>
-</ul>
-</div>
-
-<div id="content-main">
-
-
-<h2>Bar is the successor of `foo'</h2>
-
-<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed ut dui ac lacus egestas vehicula. Quisque faucibus, risus id consequat porta, orci ligula condimentum mi, ac commodo leo libero eget tortor. Maecenas a ligula in nibh luctus gravida. Praesent vehicula rhoncus tortor. <a href="#">Donec porta rutrum dui.</a> Donec dignissim congue mauris. Sed rhoncus laoreet sem. Nam dui pede, vestibulum convallis, posuere ut, dictum eu, diam. Phasellus nunc. Ut eget ante a ipsum porttitor scelerisque. Quisque auctor elit vitae massa. Vestibulum massa risus, gravida quis, hendrerit sit amet, bibendum sit amet, enim. Fusce nulla. Quisque vulputate metus vitae orci. Pellentesque at arcu. Ut sed neque.</p>
-
-</div>
-
-<div id="nav-main">
-<h2>Navigation</h2>
-<ul>
- <li><a href="index.shtml">Home</a></li>
- <li><a class="active" href="foo.shtml">foo</a>
-
- <ul>
- <li><a href="foo1.shtml"
- style="margin-left:2em!important">foo1</a></li>
- <li><a href="foo2.shtml"
- style="margin-left:2em!important">foo2</a></li>
- </ul>
-</li>
- <li><a href="bar.shtml">bar</a></li>
-</ul>
-</div>
-
-
-<p id="footer">
-Powered by <a href="http://moritz.faui2k3.org/en/mowyw">mowyw</a> | <a href="#">Imprint</a> | Design by Dimiter Petrov
-</p>
-
-</body>
-</html>
View
58 example/online/foo1.shtml
@@ -1,58 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
-<head>
-<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
-<link rel="stylesheet" type="text/css" media="screen, projection" href="style.css" />
-<link rel="stylesheet" type="text/css" media="print" href="print.css" />
-<title>Mowyw example: page foo1</title>
-</head>
-
-<body id="home">
-
-<div id="header">
- <h1>Mowyw Example</h1>
- <p>Lore Impsum</p>
-</div>
-<div id="nav-page">
-<h2>Quick access</h2>
-<ul>
-<li><a href="#nav-main">Site navigation</a></li>
-<li><a href="#nav-secondary">Recent articles</a></li>
-</ul>
-</div>
-
-<div id="content-main">
-
-
-<h2>foo1 is a sub item of foo</h2>
-
-<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed ut dui ac lacus egestas vehicula. Quisque faucibus, risus id consequat porta, orci ligula condimentum mi, ac commodo leo libero eget tortor. Maecenas a ligula in nibh luctus gravida. Praesent vehicula rhoncus tortor. <a href="#">Donec porta rutrum dui.</a> Donec dignissim congue mauris. Sed rhoncus laoreet sem. Nam dui pede, vestibulum convallis, posuere ut, dictum eu, diam. Phasellus nunc. Ut eget ante a ipsum porttitor scelerisque. Quisque auctor elit vitae massa. Vestibulum massa risus, gravida quis, hendrerit sit amet, bibendum sit amet, enim. Fusce nulla. Quisque vulputate metus vitae orci. Pellentesque at arcu. Ut sed neque.</p>
-
-</div>
-
-<div id="nav-main">
-<h2>Navigation</h2>
-<ul>
- <li><a href="index.shtml">Home</a></li>
- <li><a class="active" href="foo.shtml">foo</a>
-
- <ul>
- <li><a href="foo1.shtml" class="active"
- style="margin-left:2em!important">foo1</a></li>
- <li><a href="foo2.shtml"
- style="margin-left:2em!important">foo2</a></li>
- </ul>
-</li>
- <li><a href="bar.shtml">bar</a></li>
-</ul>
-</div>
-
-
-<p id="footer">
-Powered by <a href="http://moritz.faui2k3.org/en/mowyw">mowyw</a> | <a href="#">Imprint</a> | Design by Dimiter Petrov
-</p>
-
-</body>
-</html>
View
58 example/online/foo2.shtml
@@ -1,58 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
-<head>
-<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
-<link rel="stylesheet" type="text/css" media="screen, projection" href="style.css" />
-<link rel="stylesheet" type="text/css" media="print" href="print.css" />
-<title>Mowyw example: page foo1</title>
-</head>
-
-<body id="home">
-
-<div id="header">
- <h1>Mowyw Example</h1>
- <p>Lore Impsum</p>
-</div>
-<div id="nav-page">
-<h2>Quick access</h2>
-<ul>
-<li><a href="#nav-main">Site navigation</a></li>
-<li><a href="#nav-secondary">Recent articles</a></li>
-</ul>
-</div>
-
-<div id="content-main">
-
-
-<h2>foo2 is another sub item of foo</h2>
-
-<p>And now I'm running out of ideas what to write</p>
-
-</div>
-
-<div id="nav-main">
-<h2>Navigation</h2>
-<ul>
- <li><a href="index.shtml">Home</a></li>
- <li><a class="active" href="foo.shtml">foo</a>
-
- <ul>
- <li><a href="foo1.shtml"
- style="margin-left:2em!important">foo1</a></li>
- <li><a href="foo2.shtml" class="active"
- style="margin-left:2em!important">foo2</a></li>
- </ul>
-</li>
- <li><a href="bar.shtml">bar</a></li>
-</ul>
-</div>
-
-
-<p id="footer">
-Powered by <a href="http://moritz.faui2k3.org/en/mowyw">mowyw</a> | <a href="#">Imprint</a> | Design by Dimiter Petrov
-</p>
-
-</body>
-</html>
View
BIN example/online/images/arrow.gif
Deleted file not rendered
View
BIN example/online/images/bg.png
Deleted file not rendered
View
BIN example/online/images/document.gif
Deleted file not rendered
View
87 example/online/index.shtml
@@ -1,87 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
-<head>
-<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
-<link rel="stylesheet" type="text/css" media="screen, projection" href="style.css" />
-<link rel="stylesheet" type="text/css" media="print" href="print.css" />
-<title>Mowyw example</title>
-</head>
-
-<body id="home">
-
-<div id="header">
- <h1>Mowyw Example</h1>
- <p>Lore Impsum</p>
-</div>
-<div id="nav-page">
-<h2>Quick access</h2>
-<ul>
-<li><a href="#nav-main">Site navigation</a></li>
-<li><a href="#nav-secondary">Recent articles</a></li>
-</ul>
-</div>
-
-<div id="content-main">
-
-
-<h2>A Word on the Design</h2>
-
-<p>This design is "stolen" from Dimiter Petrov, it is published on <a
-href="http://www.oswd.org/">oswd.org</a> under the name "Ordered
-Boxes".</p>
-
-<p>As far as I understand it is public domain, but he kindly asks anybody
-using this design to keep his name in the footer line.</p>
-
-<h2>Lore Ipsum</h2>
-
-<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed ut dui ac
-lacus egestas vehicula. Quisque faucibus, risus id consequat porta, orci
-ligula condimentum mi, ac commodo leo libero eget tortor. Maecenas a ligula in
-nibh luctus gravida. Praesent vehicula rhoncus tortor. <a href="#">Donec porta
-rutrum dui.</a> Donec dignissim congue mauris. Sed rhoncus laoreet sem. Nam
-dui pede, vestibulum convallis, posuere ut, dictum eu, diam. Phasellus nunc.
-Ut eget ante a ipsum porttitor scelerisque. Quisque auctor elit vitae massa.
-Vestibulum massa risus, gravida quis, hendrerit sit amet, bibendum sit amet,
-enim. Fusce nulla. Quisque vulputate metus vitae orci. Pellentesque
-at arcu. Ut sed neque.</p>
-
-<h2>Some Tests</h2>
-
-<p>These tests only tests some properties of the parser, you can safly ignore
-and delete them.</p>
-
-<h3>Parse test</h3>
-<p>Double braces should be ignored outside of an item: }} foo bar {{ {{.</p>
-
-<h3>Option parsing</h3>
-<p>Option items should be stripped, so the there should be no "option foo"
-output on the next line.</p>
-
-
-<h3>Verbose tests</h3>
-<p>Text between [[[verbatim $marker]]] and [[[endverbatim
-$marker]]] should be treated as plain text, e.g. tags inbetween should be
-ignored: [[[include foo]]].</p>
-
-</div>
-
-<div id="nav-main">
-<h2>Navigation</h2>
-<ul>
- <li><a class="active" href="index.shtml">Home</a></li>
- <li><a href="foo.shtml">foo</a>
-</li>
- <li><a href="bar.shtml">bar</a></li>
-</ul>
-</div>
-
-
-<p id="footer">
-Powered by <a href="http://moritz.faui2k3.org/en/mowyw">mowyw</a> | <a href="#">Imprint</a> | Design by Dimiter Petrov
-</p>
-
-</body>
-</html>
View
3 example/online/no-header-footer.shtml
@@ -1,3 +0,0 @@
-This file should not have a header or footer attached to it
-
-
View
17 example/online/print.css
@@ -1,17 +0,0 @@
-* {
- float: none;
- border: none;
- background: #fff;
-}
-
-h2 {
- font-weight: normal;
-}
-
-body {
- font: medium/1.8em "Trebuchet MS", Verdana, Helvetica, sans-serif;
-}
-
-#nav-page, #nav-main, #nav-secondary {
- display: none;
-}
View
149 example/online/style.css
@@ -1,149 +0,0 @@
-body {
- font: small/1.8em "Trebuchet MS", Verdana, Helvetica, sans-serif;
- color: #222;
- margin: 0;
- padding: 0 1em;
- background: #5B99D7 url(images/bg.png);
-}
-
-h1 {
- font-size: 3em;
- font-weight: normal;
- line-height: 1.3em;
-}
-
-h2 {
- font-size: large;
- font-weight: normal;
-}
-
-h3 {
- font-size: medium;
- font-weight: normal;
-}
-
-a {
- color: #2a65ad;
- color: #2A65AC;
- font-weight: bold;
- text-decoration: none;
-}
-
-a:visited {
- color: #3A7DCF;
-}
-
-a:hover {
- color: #000;
- border-bottom: 1px solid;
-}
-
-img {
- border: 0;
-}
-
-input {
- border: 1px solid #bbb;
-}
-input:focus {
- border: 1px solid #C6DDF1;
-}
-
-.hide {
- position: absolute;
- left: -9000px;
- display: none;
-}
-
-#header {
- margin: 0 0 1em 0;
- padding: 1em 3em;
- background: #fff;
- border: solid;
- border-width: 0 2px 2px 1px;
- border-color: #ccc #777 #333 #ddd;
-}
-
-#header p {
- font-size: large;
- font-weight: light;
-}
-
-#nav-page {
- position: absolute;
- left: -5000px;
-}
-
-#content-main {
- float: right;
- width: 60%;
- padding: 1.5em 2em;
- margin: 0 0 1em;
-/* max-width: 70em; */
-}
-
-#nav-main {
- float: left;
- width: 25%;
- padding: 1.5em;
- letter-spacing: 0.1em;
-}
-.active {
- color: #000 !important;
- background: #98BFE6 url(images/arrow.gif) 0.2em no-repeat !important;
-}
- #nav-main ul {
- padding: 0;
- margin: 0;
- list-style: none;
- }
- #nav-main li {
- margin: 2px 0;
- }
- #nav-main li a {
- display: block;
- height: 100%;
- border: none;
- padding: 0 0 0 20px;
- background: url(images/arrow.gif) 0.2em no-repeat;
- }
- #nav-main li a:hover {
- background-color: #C6DDF1;
- }
-
-#nav-secondary {
- float: left;
- width: 25%;
- margin-top: 1em;
- padding: 1.5em;
-}
- #nav-secondary ul {
- padding: 0;
- margin: 0;
- list-style: none;
- }
- #nav-secondary li a {
- padding-left: 20px;
- border: none;
- background: url(images/document.gif) 0.2em no-repeat;
- }
-
-#footer {
- clear: both;
- position: relative;
- font-size: 0.9em;
- text-align: center;
- margin: 1em 0 0 0;
- padding: 1em 1em 1.5em;
- background: #fff;
- border: solid;
- border-width: 1px 2px 0 1px;
- border-color: #ccc #777 #333 #ddd;
-}
-
-#content-main, #nav-main, #nav-secondary{
- background: #fff;
- border: solid;
- border-width: 1px 2px 2px 1px;
- border-color: #ccc #777 #333 #ddd;
-}
View
63 example/source/bar.shtml
@@ -1,7 +1,68 @@
<title>Mowyw example: page `bar'</title>
[[[include head2]]]
-<h2>Some Foo Bar</h2>
+<h2>Syntax hilighting</h2>
+
+<p>This page contains some syntax hilighting using the [[[verbatim foo]]]
+[[[syntax perl]]] $perlCode [[[endsyntax]]][[[endverbatim foo]]]
+construct. Note that not only perl is support, but every language that vim has
+a syntax file for.</p>
+
+<pre>[[[syntax perl]]]
+#!/usr/bin/perl
+# Copyright (C) 2006 by Moritz Andreas Lenz, http://moritz.faui2k3.org/
+# This is free Software. You may use, modify, redistribute... it
+# under the terms of the WTFPL: http://sam.zoy.org/wtfpl/
+#
+# Use it at your own Risk
+
+use warnings;
+use strict;
+use GD;
+
+
+my $width = 1024;
+my $edges = 5;
+my $height = $width;
+
+foreach $edges (10, 11, 13){
+ my $im = new GD::Image($width,$height);
+ my $black = $im->colorAllocate(0, 0, 0);
+ my $white = $im->colorAllocate(255, 255, 255);
+ $im->fill(1, 1, $white);
+
+ my @x;
+ my @y;
+
+ for (my $i = 0; $i < $edges; $i++){
+ $x[$i] = int $width/2 * (1-sin($i * (2*3.14159) / $edges));
+ $y[$i] = int $height/2 * (1-cos($i * (2*3.14159) / $edges));
+ }
+
+ for (my $i = 0; $i < $edges; $i++){
+ $im->line($x[$i], $y[$i], $x[($i+1)%$edges], $y[($i+1)%$edges], $black);
+ }
+
+ my $x = $width * rand();
+ my $y = $height * rand();
+
+ for (0 .. 5000 * $edges * $edges * $edges){
+ my $i = int ($edges*rand());
+ $x = .5*($x + $x[$i]);
+ $y = .5*($y + $y[$i]);
+ $im->setPixel(int $x, int $y, $black);
+ }
+
+ my $fn = sprintf("sierpinski-%02d.png", $edges);
+
+ open(OUT, ">", $fn) or die "$0: can't write to file '$fn': $!";
+ print "Writing file $fn\n";
+
+ binmode OUT;
+ print OUT $im->png;
+ close OUT;
+}
+[[[endsyntax]]]</pre>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed ut dui ac lacus egestas vehicula. Quisque faucibus, risus id consequat porta, orci ligula condimentum mi, ac commodo leo libero eget tortor. Maecenas a ligula in nibh luctus gravida. Praesent vehicula rhoncus tortor. <a href="#">Donec porta rutrum dui.</a> Donec dignissim congue mauris. Sed rhoncus laoreet sem. Nam dui pede, vestibulum convallis, posuere ut, dictum eu, diam. Phasellus nunc. Ut eget ante a ipsum porttitor scelerisque. Quisque auctor elit vitae massa. Vestibulum massa risus, gravida quis, hendrerit sit amet, bibendum sit amet, enim. Fusce nulla. Quisque vulputate metus vitae orci. Pellentesque at arcu. Ut sed neque.</p>
View
12 example/source/style.css
@@ -147,3 +147,15 @@ input:focus {
border-width: 1px 2px 2px 1px;
border-color: #ccc #777 #333 #ddd;
}
+
+/* syntax hilighting */
+.synComment { color: #0000FF }
+.synConstant { color: #FF00FF }
+.synIdentifier { color: #008B8B }
+.synStatement { color: #A52A2A ; font-weight: bold }
+.synPreProc { color: #A020F0 }
+.synType { color: #2E8B57 ; font-weight: bold }
+.synSpecial { color: #6A5ACD }
+.synUnderlined { color: #000000 ; text-decoration: underline }
+.synError { color: #FFFFFF ; background: #FF0000 none }
+.synTodo { color: #0000FF ; background: #FFFF00 none }
View
1 mowyw
@@ -32,6 +32,7 @@ use Mowyw::Lexer qw(lex);
use Carp;
use Storable qw(dclone);
+use Encode;
use Data::Dumper;
sub process_file($);

0 comments on commit b498570

Please sign in to comment.