Table of Contents
This story chronicles the inexplicable hazards and vicious beasts a team must conquer and vanquish on their journey to discovering the true power of Open Source.

1. It’s a City Under Siege

This journey begins one late Monday afternoon at Devoxx. Our team needs coffee, desperately, but none of us dare open the theater doors…​

During the opening university session, a script-happy warlock inadvertently released a legion of Wolpertingers! To leave now would mean code dismemberment and certain death.

Behold → the horror!

Wolpertinger
Figure 1. Wolpertinger, stuffed

You may not be familiar with these ravenous beasts. Trust us, they’ll eat your shorts and suck loops from your code. In light of this danger, we’ve searched high and wide for the security crew’s defensive operations manual. We can’t find it and the DefOps[1] werewolves haven’t returned from their rendezvous at Bier Central. They’ve either eaten each other or fallen victim to the Wolpertingers roaming the streets of Antwerp. Quick, hit Ctrl+Alt+Backspace or select File  Quit and let’s bail out of here!

Working with DefOps[1] werewolves leads to howling and trying to train aggressive regular expressions with Pavlovian reinforcement.

Weak light from the hallway trickled across the theater, chased by a distant scream.

1.1. Rendezvous Point

Come on, Bier Central, of course! Did you have to ask? If you beat me there, order me a St. Bernardus Abt 12. Here’s some €.

2. The Ravages of Writing

Crystalline XML tags relentlessly bombarded the theater.

Listing 1. XML tags
<author id="1">
  <personname>
    <firstname>Lazarus</firstname>
    <surname>het Draeke</surname>
  </personname>
</author>

Despite the assault, we continued our pursuit to draft a DefOps[1] plan.

Example 1. DefOps Plan

Click Download Zip to download the defensive operation plan bundle.

OMG! Somebody please save us now! I want my mum — and an extra-large double macchiato, please.

Unfortunaly, Lazarus and I had both come to the conclusion that we weren’t going to get out of this without corrupted hardrives if we didn’t locate caffeine within the next few hours.

2.1. A Recipe for Potion That Will Ensure You Win the Hearts of Developers

This potion for a sample document contains the following ingredients, which are listed in a very random, chaotically nested order.

Ingredients for Potion that Demystifies Documents
  • all the headings

    • syntax highlighted source code

      • non-syntax highlighted source code or just a listing block

  • quote block

    • verse block

      • table with some cell formatting

        • sequential paragraphs

          • admonition blocks, but use them sparingly

      • bullet list with nesting

    • numbered list with nesting

    • definition list

      • sidebar

  • example block

    • block image (no inline images)

      • inline formatting in a paragraph

        • two fresh Burdockian leaves

          • They must be harvested by the light of the teal moons.

Are you square?

  • one

  • two

  • three

What is there to do?

  • Done

  • Next

  • Who’s counting?

2.1.1. Searching for Burdockian

Steps for finding and preparing Burdockian leaves
  1. Locate dusty botany

    1. Sneeze

      1. Sneeze some more

  2. Find section on Burdockian

    1. Review its characteristics

      1. Take a picture of the diagram of its leaves

        1. Don’t rip out the picture like a troglodyte

          1. Don’t do it, I’m watching you

  3. Put on your hiking boots

  4. Freeze your butt off on the side of a mountain at midnight

Let’s skip a few steps and start counting from 10.

  1. arabic (10)

    1. loweralpha (a)

      1. lowerroman (i)

      2. lowerroman (ii)

      3. lowerroman (iii)

      4. lowerroman (iv)

        1. upperalpha (A)

  2. arabic (11)

It’s time for a top 5 list, made using the reversed option on an ordered list!

  1. Stone Imperial Russian Stout

  2. Pliny the Elder

  3. Chimay Grande Réserve (Blue)

  4. St. Bernardus Abt 12

  5. Westvleteren 12 (XII)

How about a list with some terms?

  • Fruits

    Apple

    The round fruit of a tree of the rose family, which typically has thin red or green skin and crisp flesh. Yes, I said flesh.

    Pear

    A yellowish- or brownish-green edible fruit that is typically narrow at the stalk and wider toward the base, with sweet, slightly gritty flesh. More flesh. Mmmmm.

  • Vegetables

    Carrot

    An orange-colored root eaten as a vegetable. Beware, it’s a favorite of the Wolpertinger.

Are You Still Here?
Move, move, move!

The Wolpertingers can smell your procrastination. It’s not their fault you can’t find your boots.

Sigh…​
Your boots are in your closet.

3. Dawn on the Plateau

Lazarus was hanging from the bottom limb of a Burdockian tree, licking the bark.

On pavements and the bark of trees I have found whole worlds.
— Mark Tobey

“If there are whole worlds on that bark, he just swallowed them,” Kizmet replied.

No bark was harmed in the making of this potion.
    We’re not so sure about a couple ants though.

        Nor those worlds…​

     Crap, I smell an injunction.
— The documentation attorneys

We’d retrieved the leaves, but we’d obviously lost our minds in the process.

Roses are red.
Violets are blue-ish.

4. Words Seasoned with Power

To tame the wild wolpertingers, we needed to build a charm. But ultimate victory could only be won if we divined the true name of the warlock.

“What kind of charm?” Lazarus asked. “An odoriferous one or a mineral one?” Kizmet shrugged. “The note from Olaf’s desk says ‘wormwood and licorice,’ but these could be normal groceries for werewolves.”

“Well the H2O written on the security whiteboard could be part of a shopping list, but I don’t think the local bodega also sells e = mc2,” Lazarus replied.

“Wait!” Indigo plucked a small vial from her desk’s top drawer and held it toward us. The vial’s label read ‘e = mc2 the scent of science smells like a genius’.

4.1. Can I Get Some Code?

Sure.
Have a listing block.

This is an example of a listing block.
The content inside is rendered as <pre> text.

But I’m not giving you any highlighting shazam just yet.

What is a listing block?

Like literal blocks, the content in listing blocks is displayed exactly as you entered it. Listing block content is rendered as <pre> text.

The listing style is applied to an element, such as a paragraph, by setting the listing attribute on that element.

Let’s get our highlighting on!

Install Prawn:

$ gem install prawn

Then create your first PDF document in Ruby!

Listing 2. Generates a basic PDF document using Prawn
require 'prawn' (1)

Prawn::Document.generate 'output.pdf' do (3)
  text 'Hello, World!' (2)
end
1 Imports Prawn library
2 Adds text “Hello, World!” to first page
3 Writes PDF to output.pdf after executing all statements

How about some source code that styles code? So meta!

code {
  padding: 2px 4px;
  font-size: 90%;
  font-weight: normal;
  color: #c7254e;
  white-space: nowrap !important;
  background-color: #f9f2f4;
  border-radius: 4px;
}

Where could we go without some Java™? Naturally, some autosizing is necessary.

package org.javaee7.cdi.events;

import javax.annotation.PostConstruct;
import javax.enterprise.context.SessionScoped;
import javax.enterprise.event.Observes;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.ws.rs.*;

/**
 * This session-scoped bean receives greeting strings from the event bus
 * and provides access to the collection of these greetings via a REST API.
 *
 * @author The Duke
 * @since 1.0
 */
@SessionScoped
public class GreetingReceiver implements EventReceiver, Serializable {

    private List<String> greetings;

    @PostConstruct
    void init() {
        this.greetings = new ArrayList<String>();
    }

    void receive(@Observes String greet) {
        this.greetings.add(greet);
    }

    @GET
    @Produces("application/json")
    public List<String> listAll(@QueryParam("start") Integer start, @QueryParam("max") Integer max) {
        int numGreetings = this.greetings.size();

        if (numGreetings == 0 || max == 0) {
            return Collections.<String>emptyList();
        }

        if (start == null) {
            start = 0;
        }

        if (max == null) {
            max = numGreetings;
        }

        return this.greetings.subList(start, Math.min(max + start, numGreetings));
    }

}

We already showed you an XML example in Chapter 2, a language we often rant about over beers at Bier Central.

I’ll trade you a little table for some of that bark.

Column 1 Column 2 Column 3 Column 4

Prefix | with ^ to center content horizontally within the cell.

Prefix | with a . and > to align content to the bottom of the cell.

Prefix | with a ^, ., and ^ to place content in the middle of the cell.

Prefix | with > to align content to the right horizontally within the cell.

This content spans all four columns (4+) and is centered horizontally (^) within the cell.

Wait. What? Where is this story going?

<span>

an html tag that makes me crazy

align

something I never get going in the right direction. Also has to do with my poor verbal communication skills

float
style

don’t make me laugh

Does anyone have the time?

Tg lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborumj.

5. Keeping It Together

On this page we have nested “keep together” logic. The combined block will be shifted to the next page if there isn’t room available on this one.

First,
we
need
to
waste
several
lines
using
a
verse
to
push
the
next
block
to
its
breaking
point.
What happens if there is both a field and a method with the same name?

Back to the previous example, suppose that we have both a field and a method with the same name, as in:

Listing 3. Java class with a field and method that share the same name
public class Foo {
  public String bar;

  public String bar() {
    return bar;
  }
}

Golo resolves methods first, fields last. Hence, the following Golo code will resolve the bar() method, not the bar field:

Listing 4. Golo picks the method over the field with the same name
let foo = Foo()

foo: bar("baz") (1)

println(foo: bar()) (2)
1 Writes the field
2 Calls the bar() method

Here’s a preview of how each heading level is rendered.

Heading 1 (Level 0)

filler content

Heading 2 (Level 1)

filler content

Heading 3 (Level 2)

filler content

Heading 4 (Level 3)

filler content

Heading 5 (Level 4)

filler content

Heading 6 (Level 5)

filler content


Here’s some content inside an open block.

Appendix A: Credits

Brought to you with by OpenDevise
Name Title Alias

Sarah White

President

@carbonfray

Dan Allen

Vice President

@mojavelinux

Powered by Open Source

Index


1. DefOps is a portmanteau of “defensive” and “operations”.