~bohwaz/blog/

Avec de vrais morceaux de 2.0 !

SkrivLite, a lightweight implementation of SkrivML

SkrivML is a markup language inspired by other ASCII markup languages like MediaWiki, Creole, MarkDown, reST, txt2tags, AsciiDoc et d'autres. I think it is the most intuitive markup, and it is powerful and easy to use. It's much better than the terrible Markdown for writing. The only problem I had was its implementation which was quite bloated with more than 350 KB of code and more than 60 files.

That's not exactly how I like programming. I like it small, easy to read and maintain, with very few dependencies. So I began to work on my own implementation of this markup.

So here is SkrivLite: a lightweight PHP library. Only one file and 25KB of code, without any other dependency whatsoever. It is two to three times faster and takes up to three times less memory. It is fully compatible with the Skriv Markup Language, except for the symbols and smileys.

SkrivLite also adds some features like:

  • Filtering of outgoing links to avoid XSS attempts
  • Ability to allow HTML too (if HTML is allowed then it's a good idea to filter the output against invalid markup and XSS, for that you can use Garbage2xhtml)
  • Named arguments for extensions. In the original syntax the arguments of extensions are written like that: <<lipsum|5|2>>, but in SkrivLite it's also possible to use named arguments like this: <<lipsum paragraphs="5" words=2>>

SkrivLite is available under a 2-clause BSD license: download the source code.

Write a comment
(optional)
(optional)
(mandatory)
             __                             _      
 _ __ ___   /_/ _ __   __ _  __ _  ___ _ __(_) ___ 
| '_ ` _ \ / _ \ '_ \ / _` |/ _` |/ _ \ '__| |/ _ \
| | | | | |  __/ | | | (_| | (_| |  __/ |  | |  __/
|_| |_| |_|\___|_| |_|\__,_|\__, |\___|_|  |_|\___|
                            |___/                  
(mandatory)

URLs will create links automatically.
Allowed HTML tags: <blockquote> <cite> <pre> <code> <var> <strong> <em> <del> <ins> <kbd> <samp> <abbr>