Added: EnvironmentBlock < Extensions::BlockProcessor

The EnvironmentBlock detects [env.joke], [env.theorem], etc., in the source text and creates
an "environment" block with given content, and with a title  constructed from the role
and a counter.  The title is not currently used -- see below -- but will be.  The created
block is subsequently processed by `converter.rb`in the backend.

Example:  The source text

```
[env.joke]
--
An engineer, a philosopher, and a mathematician met
at the bar for a drink.  (To be continued).
-- 
```
produces this latex:
```
\begin{joke}
An engineer, a philosopher, and a mathematician met
at the bar for a drink.  (To be continued).
\end{joke}
```
What will also be needed is an addition to the html backend, or a customized version of it for
use with mathematical text so that the source will be accepted without error and produce output
equivalent to that of the input

```
.Joke {counter:joke}
--
An engineer, a philosopher, and a mathematician met
at the bar for a drink.  (To be continued).
--
```

Note that the EnvironmentBlock provides the latex backend with `title=Joke 1`.  This information is not needed by the latex backend, but it would be by a modified html backend (can we use an extension to avoid modifying it)?

@jirukta, I noticed your work on slim.  Perhaps you would like to work on this also?

The goal of all this is to be able to have one `.adoc` file produce both the `.tex` and the `.html`.

See comments in `environment_block.rb` and use `samples/env.adoc` for testing.

PS.  I am in Beijing till Dec 2.  No google search, twitter, New York Times, etc.  The Great Firewall!

Fantastico!



> On Nov 16, 2014, at 5:05 PM, Dan Allen <notifications@github.com> wrote:
> 
> In lib/asciidoctor-latex/environment_block.rb:
> 
> > + 
> > +class EnvironmentBlock < Extensions::BlockProcessor
> > +  
> > +  require_relative 'colored_text'
> > +  
> > +  use_dsl
> > +  # ^^^ don't know what this is.  Could you explain?
> > +
> > +  named :env
> > +  on_context :open
> > +  # parse_context_as :complex
> > +  # ^^^ The above line gave me an error.  I'm not sure what do to with it.
> > +  
> > +  # Hash to count the number of times each environment is encountered
> > +  # Global variables again.  Is there a better way?
> > +  $counter = {}
> Asciidoctor has built-in support for counter numbers. Here's how it's done.
> 
> attrs['title'] = env_name.capitalize
> caption = attrs.delete 'caption'
> block = create_block parent, :environment, reader.lines, attrs
> block.assign_caption caption, 'environment'
> block
> You can see that it handles all the logic of increment and adding the counter number to the title in this method:
> 
> https://github.com/asciidoctor/asciidoctor/blob/master/lib/asciidoctor/abstract_block.rb#L317 <https://github.com/asciidoctor/asciidoctor/blob/master/lib/asciidoctor/abstract_block.rb#L317>
> If there's something missing, we'll fix it in core.
> 
> —
> Reply to this email directly or view it on GitHub <https://github.com/asciidoctor/asciidoctor-latex/pull/7/files#r20408090>.
>