X

Polygot emitters in action

Converting

Blue-phrase can be used to represent many structured languages, and instant conversion is possible with the dedicated emitters that are built into the blue-processor.

Emitting markup

The blue-processor emits HTML by default, but this can be overridden by specifying the --emit option. Consider this prose example and its language counterparts.

h2 Raiders
When Vikings raided and traded along Europe's coasts, the prayer on every churchman's lips was to be spared the wrath of the Norsemen.

h2 Traders
The Vikings obtain goods from the around the world:
ul {
From the Far East: timber, iron, furs, amber, soapstone, whetstones and slaves.
From Arabia: silver, coins, fabrics, spices, silk, fruit and wine.
}
Original blue-phrase

HTML

<h2>Raiders</h2>
<p>When Vikings raided and traded along Europe's coasts, the prayer on every churchman's lips was to be spared the <q>wrath of the Norsemen</q>.</p>
<h2>Traders</h2>
<p>The Vikings obtain goods from the around the world:</p>
<ul>
<li>From the Far East: timber, iron, furs, amber, soapstone, whetstones and slaves.</li>
<li>From Arabia: silver, coins, fabrics, spices, silk, fruit and wine.</li>
</ul>
!option --emit=html

Github Flavored Markdown

## Raiders

When Vikings raided and traded along Europe's coasts, the prayer on every
churchman's lips was to be spared the <q>wrath of the
Norsemen</q>.

## Traders

The Vikings obtain goods from the around the world:

* From the Far East: timber, iron, furs, amber, soapstone, whetstones and slaves.
* From Arabia: silver, coins, fabrics, spices, silk, fruit and wine.
!option --emit=ghfm

Wikitext

## Raiders ##
When Vikings raided and traded along Europe's coasts, the prayer on every churchman's lips was to be spared the <q>wrath of the Norsemen</q>.


## Traders ##
The Vikings obtain goods from the around the world:

* From the Far East: timber, iron, furs, amber, soapstone, whetstones and slaves.
* From Arabia: silver, coins, fabrics, spices, silk, fruit and wine.
!option --emit=wiki

Plain text

Raiders
When Vikings raided and traded along Europe's coasts, the prayer on every churchman's lips was to be spared the wrath of the Norsemen.
Traders
The Vikings obtain goods from the around the world:
From the Far East: timber, iron, furs, amber, soapstone, whetstones and slaves.
From Arabia: silver, coins, fabrics, spices, silk, fruit and wine.
!option --emit=txt

Emitting structured data

The blue-processor can emit structured data in many popular formats. Consider this example with its encoded counterparts.

!option --vocabulary=unchecked

chapter *title=Raiders {
abstract The Wrath of the Norsemen
}
chapter *title=Traders {
abstract Global reach
region *name='Far East' {
product timber
product iron
product furs
product amber
product soapstone
product whetstones
product slaves
}
region *name=Arabia {
product silver
product coins
product fabrics
product spices
product silk
product fruit
product wine
}
}
Original blue-phrase

XML

<chapter title='Raiders'>
<abstract>The Wrath of the Norsemen</abstract>
</chapter>
<chapter title='Traders'>
<abstract>Global reach</abstract>
<region name='Far East'>
<product>timber</product>
<product>iron</product>
<product>furs</product>
<product>amber</product>
<product>soapstone</product>
<product>whetstones</product>
<product>slaves</product>
</region>
<region name='Arabia'>
<product>silver</product>
<product>coins</product>
<product>fabrics</product>
<product>spices</product>
<product>silk</product>
<product>fruit</product>
<product>wine</product>
</region>
</chapter>
!option --emit=xml

JSON

{
"chapter" : {
"attributes" : { "title" : "Raiders" },
"abstract" : "The Wrath of the Norsemen"
},
"chapter" : {
"attributes" : { "title" : "Traders" },
"abstract" : "Global reach",
"region" : {
"attributes" : { "name" : "Far East" },
"product" : "timber",
"product" : "iron",
"product" : "furs",
"product" : "amber",
"product" : "soapstone",
"product" : "whetstones",
"product" : "slaves"
},
"region" : {
"attributes" : { "name" : "Arabia" },
"product" : "silver",
"product" : "coins",
"product" : "fabrics",
"product" : "spices",
"product" : "silk",
"product" : "fruit",
"product" : "wine"
}
}
}
!option --emit=json

Yaml

---
chapter:
attributes: { title: Raiders }
abstract : The Wrath of the Norsemen
chapter:
attributes: { title: Traders }
abstract : Global reach
region:
attributes: { name: Far East }
product : timber
product : iron
product : furs
product : amber
product : soapstone
product : whetstones
product : slaves
region:
attributes: { name: Arabia }
product : silver
product : coins
product : fabrics
product : spices
product : silk
product : fruit
product : wine
...
!option --emit=yaml

INI

[chapter]
title = Raiders
abstract = The Wrath of the Norsemen

[chapter]
title = Traders
abstract = Global reach

[chapter.region]
name = Far East
product = timber
product = iron
product = furs
product = amber
product = soapstone
product = whetstones
product = slaves

[chapter.region]
name = Arabia
product = silver
product = coins
product = fabrics
product = spices
product = silk
product = fruit
product = wine
!option --emit=ini

TOML

[chapter]
attributes = { title = "Raiders" }
abstract = "The Wrath of the Norsemen"
[chapter]
attributes = { title = "Traders" }
abstract = "Global reach"
[chapter.region]
attributes = { name = "Far East" }
product = "timber"
product = "iron"
product = "furs"
product = "amber"
product = "soapstone"
product = "whetstones"
product = "slaves"
[chapter.region]
attributes = { name = "Arabia" }
product = "silver"
product = "coins"
product = "fabrics"
product = "spices"
product = "silk"
product = "fruit"
product = "wine"
!option --emit=toml

Summary

The built-in emitters are:

  • HTML5
  • XHTML 1.1 for ePubs
  • XML 1.0
  • Daring Fireball Markdown
  • Github Flavored Markdown
  • Wikimedia-style wikitext
  • JSON (IETF RFC 8259)
  • HAML 5.0
  • YAML 1.2
  • TOML 0.5
  • Windows INI
  • Apple property list
  • plain text

Polygot emitters in action