![qipowl](/images/owl.png) ## Name _qipowl_ (pronounced as **keep all**) [![Build Status](https://travis-ci.org/mudasobwa/qipowl.png)](https://travis-ci.org/mudasobwa/qipowl) [![Gemnasium](https://gemnasium.com/mudasobwa/qipowl.png?travis)](https://gemnasium.com/mudasobwa/qipowl) [![Stories in Ready](https://badge.waffle.io/mudasobwa/qipowl.png?label=ready)](http://waffle.io/mudasobwa/qipowl) **Status:** Minimum viable product --- [Introduction into techniques](http://rocket-science.ru/qipowl/) ## Intro The main idea of _qipowl_ is to yield the power of [DSL in Ruby](http://jroller.com/rolsen/entry/building_a_dsl_in_ruby). The whole input text is treated neither more nor less than `DSL`. That gives the user an ability to make virtually every term in input text the _operating entity_. ## Principles **Qipowl** is a Ruby parsing library. The parsing is done via DSL exactly as [Ouroboros](http://en.wikipedia.org/wiki/Ouroboros) eats it’s own tail. The whole input is treated as Ruby source code and executed respectively. To prevent collisions of input with built-in ruby methods, the ASCII symbols in the input are being translated into their [fullwidth equivalents](http://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms#Chart) before execution (and back to ASCII after the parsing is done.) Let’s say we have a string “Hello world” as input. It became ‘encoded’ into: “Hello world”, executed as Ruby code (exactly as e. g. `puts rand` would) and finally ‘decoded’ back to ASCII. Whether the parser knows anything about ‘Hello’ or ‘world’ it would be executed. Say, we have def world *args "brave new #{__callee__}" end thus the output will be: # ⇒ Hello brave new world More about may be found at [project page](http://rocket-science.ru/qipowl/). ## Applications **Qipowl** has a wide list of applications. The “markright”, descendant of “markup” and “markdown” is presented [here](http://qipowl.herokuapp.com). **Qipowl HTML** uses extended unicode symbols to specify more clean and readable source files and (boom!) ruby DSL to interpret them. E.g. the data definitions look like: ▶ Data term — definition goes here Headings: §1 This is a second-level heading Bold and emphasis: The following ≡text≡ goes strong and this one is ≈emphasized≈. Comments are possible as well: ✍ FIXME! Not to forget add this to parsing! ✍ etc. ## Why? Just because it’s 2013 all around. Unicode came already and those fancy symbols are easily mapped to the keyboard layouts. The brackets, used in old good Markdown are ugly, look at how they might be introduced: I like Markdown¹http://daringfireball.net/projects/markdown/syntax Markdown lacks a lot of modern features (properties of text). Markdown does not provide a blanket set of marks, fully covering claims to markup language. ## Parsing Parsing is the most sexy part of **Qipowl** bowels, since it’s done almost without any external parsing; input files are the ruby scripts themselves. WTF? Let me explain. Let we have an input file of the following structure: §1 Qipowl ✍ FIXME include language reference here ✍ ≡Qipowl≡ is the most exciting ruby DSL application example. As it is stated in markdown reference: 〉 Readability, however, is emphasized above all else. A Markdown-formatted document should be publishable as-is, as plain text, without looking like it’s been marked up with tags or formatting instructions. — http://daringfireball.net/projects/markdown/syntax Now we simply give the source to ruby interpreter, which knowns, that `§1` is *in fact* ruby function, which transforms that to any other syntax we want. To HTML, for instance. ## Parsing problems Not all the constructions may be passed to ruby script as is. There are four exceptions: - **blockquotes**, which are in fact kinda documents inside documents, because they might be nested and they may include any other markup; - **images**, **videos**, etc. which may be typed as the hyperlink only; - **anchors, abbrs etc.**, the elements which are not “symbol-text” formed. They rather are looking like “text-symbol-text” and unfortunately should be preparsed to supply correct ruby DSL; - **lists and data definitions**, are to be surrounded with `