some samples of what makrell can do.
to test snippets locally, use
include 'makrell.inc.php'; $m = new Makrell; $result = $m->parse(<<<EOS copy-paste snippet source here EOS ); echo $result;
"hello, world" of makrell
source
sayhello {{ hello, user! }}
- hello, makrell! - sayhello
result
- hello, makrell!
- hello, user!
shorten complex html
Nifty Corners by Alessandro Fulciniti @ http://www.html.it/articoli/nifty/index.htmlsource
<fancybox> {{
<div class="nifty">
<b class="rtop"><b class="r1"></b><b class="r2"></b><b class="r3"></b><b class="r4"></b></b>
<div>
}}
</fancybox> {{
</div>
<b class="rbottom"><b class="r4"></b><b class="r3"></b><b class="r2"></b><b class="r1"></b></b>
</div>
}}
<fancybox>a nice fancy box</fancybox> foo, bar <fancybox>look, I've got another one!</fancybox>
result
a nice fancy box
look, I've got another one!
parameteric macros
source
* @title: @text. {{
<div style="background: silver">
<h3>@title</h3>
<p>@text</p>
</div>
}}
* about this example : illustrates how makrell can be used to create html from the plain text. * another list element: lets put some text in here.
result
about this example
illustrates how makrell can be used to create html from the plain text
another list element
lets put some text in here
plaintext wiki-style markup
source
### @text {{ <h3>@text</h3> }}
## @text {{ <h2>@text</h2> }}
# @text {{ <h1>@text</h1> }}
*@text* {{ <b>@text</b> }}
!@text! {{ <i>@text</i> }}
[[[ @text ]]] {{ <pre>@text</pre> }}
# documentation ## debugging ### error messages It's *extremely* important that you turn php !error reporting! on when debugging. [[[ error_reporting(E_ALL); ]]]
result
documentation
debugging
error messages
It's extremely important that you turn php error reporting on when debugging.error_reporting(E_ALL);
shorten complex php
source
{each @ary @var} {{ <?php foreach($@ary as $@var) { ?> }}
{/each} {{ <?php } ?> }}
{@ary.@index} {{ <?php echo htmlspecialchars($@ary['@index']); ?> }}
{each customers cust}
<p>{cust.first_name}</p>
<p>{cust.last_name}</p>
{/each}
result
<?php foreach($customers as $cust) { ?>
<p> <?php echo htmlspecialchars($cust['first_name']); ?> </p>
<p> <?php echo htmlspecialchars($cust['last_name']); ?> </p>
<?php } ?>
typed variables
source
(@var:id) {{ <?php echo $@var; ?> }}
(@str:string) {{ <?php echo @str; ?> }}
The content in parenthesis will only be replaced if it is an identifier or a string:
(replace_this) and ("this") (but not this) or ( this ).
result
The content in parenthesis will only be replaced if it is an identifier or a string:
<?php echo $replace_this; ?> and <?php echo "this"; ?> (but not this) or ( this ).
custom types
source
{{ type url http:\/\/[\w\/.?&#]+ }}
@text:alnum (@u:url) {{ <a href="@u">@text</a> }}
recommended websites: google (http://www.google.com) and yahoo (http://www.yahoo.com) <br> recommended books: Design patterns (Gamma et al.), PoEAA (Fowler)
result
recommended websites: google and yahoo
recommended books: Design patterns (Gamma et al.), PoEAA (Fowler)
recommended books: Design patterns (Gamma et al.), PoEAA (Fowler)
assertions
source
{{ type begin (?<=\n) }}
@:begin* @text {{ <li>@text</li> }}
* hello * wonderful * world this * has no effect
result
regular expressions
source
/([\w.-]+)@([\w.-]+)/ {{ <a href="mailto:@1%40@2">@1 at @2</a> }}
contact me: streofrog@gmail.com
result
contact me: streofrog at gmail.com