Forum Samples, Tips and Tricks

Self-Publicity - Open Source Text Processor

Christophe
This is a holder post, since I don't have the right to post URLs as first post (pretty understandable !).

So the post is just here down :
Christophe
I announce this text processor here, since I made it to edit html files for rendering with Prince.

The name is pwilang, and its guidelines are that :
1. Indentation is good
2. Html tags syntax is evil
3. Automation is nice

There is a way of doing CSS like less (see http://lesscss.org) with variables and tag nesting although it's a little different since it's through a macro. See example/cssexample.pwi if interested.

You can go see it on http://code.google.com/p/pwilang and see the doc to see a little what it's about.

Also, in the release there are example files for the curious.

I'll be happy to have any feedback whatsoever !
Christophe
Alright. Maybe this thing is not interesting anyone, or maybe I just should have put some kind of example of how you can write stuff with the pwilang.

So to rule out the second possibility, I'm just going to write here an example, to show how the language works (mostly). If I still don't get feedback, I guess it would mean that effectively nobody is interested :)

This "language" is actually kind of the one that was posted here a while ago that kinds of looks like lout (FopSnor). Actually, the concept of pwilang is similar : lots of "@".

I just wanted to get rid of so many { and }, and add a way of specifying classes, ids and attributes as easily as possible. I do my webpages with it too (interfaces well with the Django template processor !)

Also, I wanted to be able to create macros in python, and have some pretty powerful pre-processing (includes and such, that I won't detail here).

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@# Lines that start with "@#" are comments
@# The very first line is just some standard HTML. < and > are not escaped
@# and thus are interpreted as regular HTML. \< and \> give &lt; and &gt;
@# though.

@# This is a python statement that imports a module
@# This module actually gives a macro that allows us to make some
@# inline CSS in a simpler fashion. See below.
@${ include ("python/css.py") }

@# This is inline python
@${ color = "#111" }

@html
  @head
      @# Here we see an attribute
      @style type="text/css"
          @$ { css_transform () } @# This node's children are CSS statements !
             p.big
                font-weight: bold
                color: @${ color }
                em  @# This will translate to p.big em { font-size: 2em }
                    font-size: 2em

  @# Unindenting just closes the tags !
  @body
    @p .big #someid This is a paragraph, with
        some @em{inline emphasized text}. Its id is "someid" and its class is 
        "big".


That's about it.
Note that there are preprocessing stuff to include external files, or to extend base files that define blocks to override (a la Django).

Space handling is pretty well controlled in the html output. Also, you can output it in a pretty way with indentation and all (so that it's readable), OR have it all on one line (so that it's smaller).

Anyway, if anybody picks some kind of interest in it and wants more doc, I'll be happy to write more.
mikeday
This is interesting, perhaps you should announce it to the Python community as well? It seems that it is not Prince-specific, even if you are using it with Prince, and could be used as a templating language for web applications.