Asciidoctor Java integration 0.1.3 released!

by Alex Soto -

The Asciidoctor Java integration is the official means of using Asciidoctor to render your AsciiDoc documentation using Java instead of Ruby.

The following issues have been resolved in version 0.1.3:

  • Promoted icons, iconsdir and scriptsdir attributes in the fluent API. Resolves #31.

  • Required libraries for rendering documents are preloaded. Resolves #32.

  • Copycss hack is removed. Asciidoctor can generate css file when it is executed from Java. Resolves #40.

  • Added support for the parse_header_only mode. Resolves #42.

  • Promoted base_dir option to attributes in the fluent API. Resolves #43.

  • Removed requirement to invoke asMap() on builders. Resolves #45.

  • Promoted numbered attribute in the fluent API. Resolves #47.

  • Updated asciidoctor dependency to 0.1.3. Resolves #48.

  • Attributes argument of render can be a string or array Resolves #50.

  • Promoted linkattrs attribute in the fluent API. Resolves #51.

  • Promoted experimental attribute in the fluent API. Resolves #52.

  • Added support for setting icons value. Resolves #53.

For more information, visit the Asciidoctor Java integration project on GitHub.

The argument type for icons method has been changed from boolean to String to accomodate the font-based icons introduced in Asciidoctor 0.1.3 by #53. The equivalent method to .icons(true) is .icons(Attributes.ORIGINAL_ADMONITION_ICONS_WITH_IMG).

Asciidoctor 0.1.3 released!

by Sarah White and Dan Allen -

We’re thrilled to announce the release of Asciidoctor 0.1.3.
Read Installing or Updating Asciidoctor to learn how to get it setup.

Asciidoctor is an open source text processor and publishing toolchain written in Ruby for converting AsciiDoc markup into HTML 5, DocBook 4.5 and custom formats. Asciidoctor is written in Ruby, but available to any JVM language using the Java integration library.

This release marks an important milestone. It’s been exactly 6 months since Dan picked up Asciidoctor and started driving it forward. The project sure has come a long way since then. With this release, we’ve moved past just implementing AsciiDoc to advancing it, as this post highlights.

Overview

The focus of this release cycle was on:

  • AsciiDoc compliance (yes, still)

  • New shorthand syntax and macros

  • Improved styles

  • Markdown compatibility

  • Bug fixes

The valuable feedback we’ve received has helped bring Asciidoctor to 99.5% compliance with the AsciiDoc syntax and key parts of the Markdown syntax. The improvements have given Asciidoctor a 10% boost in speed over the previous release, nearly 40x as fast as the native AsciiDoc processor.

This document covers most of the new and noteworthy fixes and enhancements. Here’s the TL;DR version if you’re in a hurry.

  • File encoding and Windows path bugs fixed!

  • Haml/Slim/Jade-inspired syntax for defining the id and role for block content

  • Shorthand syntax to set the table format using the first position of the block delimiter

  • Alternate "air quotes" delimiters for defining block quotations

  • Support for Markdown blockquotes and headings (to join fenced code blocks)

  • Font-based admonition icons powered by Font Awesome and CSS-based callout icons

  • Linked section titles as floating anchors or linked title text

  • Target window and role (i.e., CSS class) attributes for links

  • Option to use google-code-prettify to highlight source code blocks

  • Attributes resolved in target of include macro

  • Control over block indentation of included content

  • Sidebar placement for table of contents (toc2)

  • Macros for keyboard shortcuts, menu selections and UI buttons (experimental)

  • Table of contents honors numbered setting for section titles

  • Inline doctype for rendering simple, unstructured content

  • Shorthand syntax for passing attributes to the Asciidoctor API

  • General style improvements in default stylesheet

  • Updated asciidoc.conf compatibility configuration

  • 1,000+ tests in the test suite

  • Over 40 issues resolved

Read on to learn about these great improvements!

Write faster with new shorthand syntax!

Shorthand notation for setting id and role block attributes

In the spirit of Haml, Jade, and Slim, Asciidoctor allows you to assign the id and role attributes on a block using attribute shortcuts. This shorthand syntax is useful for creating presentations with AsciiDoc, where lots of style classes in the markup are needed.

Consider the following AsciiDoc markup:

[[goals]]
[role="incremental"]
* Goal 1
* Goal 2

In Asciidoctor, this can now be written as:

[#goals.incremental]
* Goal 1
* Goal 2

The # prefix is recognized as shorthand for id=, and the . prefix is recognized as shorthand for role=.

Both source snippets produce the following HTML:

<div id="goals" class="ulist incremental">
<ul>
<li><p>Goal 1</p></li>
<li><p>Goal 2</p></li>
</ul>
</div>

This shorthand notation is part of a block’s style. Thus, it leverages the first attribute position to its fullest extent.

Let’s say you want to create a blockquote from an open block and assign it an id and role. You prepend the style quote to the # (id) and . (role) in the first attribute position, as this example shows:

[quote#roads.dramatic, Dr. Emmett Brown]
____
Roads? Where we're going, we don't need roads.
____

That produces the following HTML:

<div id="roads" class="quoteblock dramatic">
<blockquote>
<div class="paragraph">
<p>Roads? Where we're going, we don't need roads.</p>
</div>
</blockquote>
<div class="attribution">
&#8212; Dr. Emmett Brown
</div>
</div>

Here are some other things to know about this notation:

  • To specifiy multiple roles using the shorthand syntax, separate them by dots

    For example, [.summary.incremental] emits the HTML attribute class="summary incremental".

  • The order of id and role values in the shorthand syntax does not matter

    For example, [#goals.incremental] and [.incremental#goals] produce the same output.

Learn more in the Asciidoctor Docs: block attributes

Shorthand notation for setting csv and dsv table formats

The first position of the table block delimiter (i.e., |===) can be replaced by the data delimiter to set the table format.

Instead of specifying the csv format using a block attribute, as shown here:

[format="csv"]
|===
a,b,c
|===

you can simply replace the leading pipe (|) with a comma (,):

,===
a,b,c
,===

In the same way, the dsv format can be specified by replacing the leading pipe (|) with a colon (:).

:===
a:b:c
:===

Now, you only need the block attribute list for setting any additional options.

Learn more in the Asciidoctor Docs: tables

Alternate blockquote syntax

Asciidoctor 0.1.3 brings three new syntax variations for marking up blockquotes:

  1. Quoted paragraph

  2. Air quotes

  3. Markdown-style

Here’s an example of a traditional AsciiDoc quote block with three parts (quoted text, attribution and source):

[quote, Thomas Jefferson, Papers of Thomas Jefferson: Volume 11]
____
I hold it that a little rebellion now and then is a good thing,
and as necessary in the political world as storms in the physical.
____

Here are the three new alternatives.

Quoted paragraph blockquote

You can turn a single paragraph into a blockquote by:

  1. surrounding it with double quotes

  2. adding an optional attribution (prefixed with two dashes) below the quoted text.

"I hold it that a little rebellion now and then is a good thing,
and as necessary in the political world as storms in the physical."
-- Thomas Jefferson, Papers of Thomas Jefferson: Volume 11

Here’s the result of the abbreviated blockquote syntax:

I hold it that a little rebellion now and then is a good thing, and as necessary in the political world as storms in the physical.
— Thomas Jefferson
Papers of Thomas Jefferson: Volume 11

Air quotes

Asciidoctor recognizes text between "air quotes" as a quote block. Air quotes are the best thing since fenced code blocks.

[,Lewis Carroll]
""
If you don't know where you are going, any road will get you there.
""

This syntax is inspired by the gesture people make with their fingers when quoting someone, such as famously used by Dr. Evil.

Markdown-style blockquotes

Asciidoctor even supports Markdown-style blockquotes:

> I hold it that a little rebellion now and then is a good thing,
> and as necessary in the political world as storms in the physical.
> -- Thomas Jefferson, Papers of Thomas Jefferson: Volume 11

This markup renders the same as the example above.

Like Markdown, Asciidoctor supports block content inside the blockquote, including nested blockquotes:

Markdown-style blockquote containing block content
> > What's new?
>
> I've got Markdown in my AsciiDoc!
>
> > Like what?
>
> * Blockquotes
> * Headings
> * Fenced code blocks
>
> > Is there more?
>
> Yep. AsciiDoc and Markdown share a lot of common syntax already.

Here’s how this conversation renders:

What’s new?

I’ve got Markdown in my AsciiDoc!

Like what?

  • Blockquotes

  • Headings

  • Fenced code blocks

Is there more?

Yep. AsciiDoc and Markdown share a lot of common syntax already. Just try it.

Learn more in the Asciidoctor Docs: blocks

You often need to set the target attribute on a link element (<a>) so the link opens in a new window (e.g., <a href="…​" target="_blank">).

This type of configuration is normally specified using attributes. However, AsciiDoc does not parse attributes in the link macro by default. In Asciidoctor, you can now enable parsing of link macro attributes by setting the linkattrs document attribute in the header.

 :linkattrs:

You can then specify the name of the target window using the window attribute:

http://google.com[Google, window="_blank"]

Since _blank is the most common window name, we’ve introduced shorthand for it. Just end the link text with a caret (^):

http://google.com[Google^]
If you use the caret syntax more than once in a single paragraph, you may need to escape the first occurrence with a backslash. If the link text contains a comma, then you need to surround the link text in double quotes.

Since Asciidoctor is parsing the attributes, that opens the door for adding a role (i.e., CSS class) to the link:

http://google.com[Google^, role="external"]

Have fun styling your links!

Font awesome icons, fancy section anchors and other style options

You no longer have to carry icons around with you where ever you go! Asciidoctor 0.1.3 introduces Font-based admonition and CSS-based callout icons.

Admonition icons powered by Font Awesome

Icons can make your document look sharp, but they are a pain to manage. That is, until now! Asciidoctor can "draw" icons using Font Awesome and CSS.

To use this feature, just set the value of the icons document attribute to font. Asciidoctor will then emit HTML markup that selects an appropriate font character from the Font Awesome font for each admonition block.

Here’s an example, starting with the AsciiDoc source:

:icons: font

NOTE: Asciidoctor now supports font-based admonition icons, powered by Font Awesome!

Here’s the HTML it produces:

<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="icon-note" title="Note"></i>
</td>
<td class="content">
Asciidoctor now supports font-based admonition icons, powered by Font Awesome!
</td>
</tr>
</table>
</div>

And here’s a preview of how it renders:

Asciidoctor now supports font-based admonition icons, powered by Font Awesome!

Asciidoctor adds a reference to the Font Awesome stylesheet, served from a CDN, to the document header. The stylesheet then imports the font from the same server.

<link rel="stylesheet"
  href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.1.0/css/font-awesome.min.css">
The default stylesheet (or any stylesheet produced by the Asciidoctor stylesheet factory) is required for this feature to work.

Learn more in the Asciidoctor Docs: admonition blocks | Asciidoctor stylesheets

CSS-based callout icons

The font icons setting also enables callout icons drawn using CSS.

:icons: font (1)

NOTE: Asciidoctor now supports font-based admonition icons, powered by Font Awesome! (2)
1 Activates font-based icons in the HTML5 backend
2 Admonition block that uses a font-based icon

Kick that icon directory to the curb. You’re untethered!

Two document attributes are available to control section linking:

sectanchors

When this attribute is enabled on a document, an anchor (empty link) is added before the section title. The default Asciidoctor stylesheet renders the anchor as a section entity (§) that floats to the left of the section title.

sectlinks

When this attribute is enabled on a document, the section titles are turned into links. The default Asciidoctor stylesheet displays linked section titles in the same color as normal section titles.

Section title anchors depend on the default Asciidoctor stylesheet to render properly.

Learn more in the Asciidoctor Docs: section titles

Lead paragraph style

Simply apply role="lead" (or .lead) above any paragraph, and it will appear in the style of a lead paragraph (i.e., larger font).

Cleaner quote blocks and verses

If a quote or verse block does not have an attribution, the empty attribution div is no longer displayed in the HTML5 output. This corrects any output styling inconsistencies caused by the empty div.

AsciiDoc quote block syntax without attribution
[quote]
____
Words of wisdom.
____
HTML output using Asciidoctor 0.1.2 and older versions
<div class="quoteblock">
<blockquote>
<div class="paragraph">
<p>Words of wisdom.</p>
</div>
</blockquote>

<div class="attribution">
</div>

</div>
HTML output using Asciidoctor 0.1.3
<div class="quoteblock">
<blockquote>
<div class="paragraph">
<p>Words of wisdom.</p>
</div>
</blockquote>
</div>

The default stylesheet has been updated to follow suit. Additionally, verse blocks have been given a style makeover, so they should appear consistent with the default look and feel.

The stylesheet has also been updated with some new styles for the experimental user input macros.

Return of the Mac(ros): Making it clear what readers are supposed to press

You must set the experimental attribute to enable these macros.

Keyboard shortcuts

Asciidoctor now recognizes a macro for creating keyboard shortcuts following the syntax kbd:[key(+key)*].

For example:

[options="header", caption=""]
.Common browser keyboard shortcuts
|===
|Shortcut |Purpose

|kbd:[F11]
|Toggle fullscreen

|kbd:[Ctrl+T]
|Open a new tab

|kbd:[Ctrl+Shift+N]
|New incognito window

|kbd:[Ctrl + +]
|Increase zoom
|===

renders as:

Common browser keyboard shortcuts
Shortcut Purpose

F11

Toggle fullscreen

Ctrl+T

Open a new tab

Ctrl+Shift+N

New incognito window

Ctrl++

Increase zoom

You no longer have to struggle to explain to users what combination of keys they are supposed to press.

Trying to explain to someone how to select a menu item can be a pain. With the new menu macro, the symbols do the work.

For example:

To save the file, select menu:File[Save].

Select menu:View[Zoom > Reset] to reset the zoom level to the default setting.

The instructions in the example appove appear as:

To save the file, select File  Save.

Select View  Zoom  Reset to reset the zoom level to the default setting.

UI buttons

It can be equally difficult to communicate to the reader that they need to press a button. They can’t tell if you are saying “OK” or they are supposed to look for a button labeled "OK". It’s all about getting the semantics right. The new btn macro to the rescue!

For example:

Press the btn:[OK] button when you are finished.

Select a file in the file navigator and click btn:[Open].

Here’s the result:

Press the OK button when you are finished.

Select a file in the file navigator and click Open.

We are looking for feedback on these macros before setting them in stone. If you have suggestions, we want to hear from you!

A better programmer’s best friend

AsciiDoc is a programmer’s best friend because it keeps your source code close to the documentation and makes inserting source code easy. Now there are even more options for pulling source code snippets into your document and highlighting them.

Normalizing the block indentation of included source code

Source code snippets from external files are often padded with leading block indent. This leading block indent is relevant in its original context. However, once inside the documentation, this leading block indent is no longer needed.

The attribute indent allows the leading block indent to be stripped and, optionally, a new block indent to be inserted for blocks with verbatim content (listing, literal, source, verse, etc.).

  • When indent is 0, the leading block indent is stripped (tabs are replaced with 4 spaces).

  • When indent is > 0, the leading block indent is first stripped (tabs are replaced with 4 spaces), then a block is indented by the number of columns equal to this value.

For example, this AsciiDoc source:

[source,ruby,indent=0]
----
    def names
      @name.split ' '
    end
----

Produces:

def names
  @name.split ' '
end

You’ll need this feature when including content:

[source,ruby,indent=0]
----
include::lib/document.rb[lines=5..10]
----

This AsciiDoc source:

[indent=2]
----
    def names
      @name.split ' '
    end
----

Produces:

  def names
    @name.split ' '
  end
The relative indentation between the lines of source code is not affected.

Including files relative to a common source directory

Asciidoctor now expands attributes in the target of the include macro. That means you only have to type the unique part of the path when linking to a source file.

Example:

:sourcedir: src/main/java

[source,java]
----
include::{sourcedir}/org/asciidoctor/Asciidoctor.java[]
----

The target of the include macro resolves to:

src/main/java/org/asciidoctor/Asciidoctor.java

Learn more in the Asciidoctor Docs: include macro and blocks

New source highlighter: google-code-prettify

Source code snippets can now be highlighted with the google-code-prettify library.

To use prettify, enable it by setting the source-highlighter attribute in the document header (or pass it as an argument):

:source-highlighter: prettify

Asciidoctor will link to the prettify JavaScript library and stylesheet and emit the HTML prettify requires to highlight the source code.

Consider this source code block:

[source,java]
----
public class Person {
  private String name;

  public String getName() {
    return name;
  }
}
----

Asciidoctor produces the following HTML:

<div class="listingblock">
<div class="content monospaced">
<pre class="prettyprint java language-java"><code>public class Person {
  private String name;

  public String getName() {
    return name;
  }
}</code></pre>
</div>
</div>

The key addition is the prettyprint class on the <pre> tag.

Learn more in the Asciidoctor Docs: enabling source code highlighters

Documents with more depth, a bigger picture and mini content

Level 5 section title added

Asciidoctor 0.1.3 includes syntax for the level 5 section title.

===== Level 5 Section Title

The level 5 title maps to the <h6> tag in the html5 backend.

Part headings in HTML backend

Previously, part headings (level 0 sections in a book doctype document) weren’t distinguishable from other <h1> tags. In 0.1.3, these <h1> tags get the sect0 class name to be consistent with the class names assigned to the other section levels. This addition simplifies the effort of adding custom styles to the part headings.

Table of contents layout and style options

Asciidoctor 0.1.3 includes numerous table of contents (TOC) style changes and options.

More table of contents position options

The AsciiDoc toc2 layout is now included in the Asciidoctor default stylesheet as the toc2 class. To use the alternate TOC, specify the document attribute toc2 in the header.

The table of contents can also be inserted directly beneath a document’s preamble. To place the TOC under the preamble, assign the new value, preamble to the toc-placement attribute.

The TOC macro requires the toc attribute to be set. To disable the built-in TOC, unassign the toc-placement attribute (toc-placement!)

Updated level 0 section title styles

Level 0 section titles (only applicable to book doctype) are now organized in their own level within the table of contents (in the HTML backend). A CSS class has been added to each outline level (i.e., <ol> element) that cooresponds to the level of the sections it contains (e.g., sect1level) The addition of these CSS classes make it easier to style the TOC.

In the default stylesheet, the following style changes have been made to the TOC:

  • Level 0 and level 1 section titles are aligned vertically

  • Extra spacing has been added between level 0 and level 1 section titles to make level 0 section titles stand out

  • Level 0 section titles (i.e., parts) appear in italic text

Also, the type="none" attribute has been added to the <ol> elements to provide a hint to the browser not to add a number in front of each item. This change satisfies the requirement that the TOC should "just work" without a stylesheet.

Introducing the inline doctype for inline formatting on input text

There may be cases when you only want to apply inline AsciiDoc formatting to input text without wrapping it in a block element. For example, in the Asciidoclet project (AsciiDoc in Javadoc), only the inline formatting is needed for the text in Javadoc tags.

The rules for the inline doctype are as follows:

  • Only a single paragraph is read from the AsciiDoc source

  • Inline formatting is applied

  • The output is not wrapped in the normal paragraph tags

Given the following input:

http://asciidoc.org[AsciiDoc] is a _lightweight_ markup language...

Processing it with the options doctype=inline and backend=html5 produces:

<a href="http://asciidoc.org">AsciiDoc</a> is a <em>lightweight</em> markup language&#8230;

The Asciidoctor processor is now able to cover the full range of output, from unstructured (inline) text to a full, standalone document!

Markdown in your AsciiDoc?

That’s right! Asciidoctor supports three key elements from the Markdown syntax (where AsciiDoc and Markdown don’t already overlap).

  • Headings

  • Blockquotes

  • Fenced code blocks

In addition to the equal marker (=) used for defining single-line section titles, Asciidoctor recognizes the hash symbol (#) from Markdown. That means the outline of a Markdown document will render just fine as an AsciiDoc document.

# Document Title

## Section One

content

The Markdown-style blockquotes where previously described in Alternate blockquote syntax.

Markdown-style headings and blockquotes join support for fenced code blocks (from GitHub-flavored Markdown), which was added in a previous release.

```ruby
require 'asciidoctor'

puts Asciidoctor.render("http://asciidoc.org[AsciiDoc] is a _lightweight_ markup language...")
```

We hope these additions help to ease and encourage migration from Markdown to AsciiDoc. To alleviate concerns about fragmentation from AsciiDoc, we maintain an AsciiDoc configuration file in the project that brings these same enhancements to AsciiDoc when used.

Important bug fixes

The Windows path bug is fixed

Asciidoctor 0.1.3 properly detects the Windows environment and converts all backslashes to forward slashes. This eliminates file path resolution errors in Windows. Resolves issue 330.

File encoding errors when using Ruby 1.9 and above is fixed

Asciidoctor was not properly setting the encoding on data read from files when the default system encoding was not UTF-8. To correct this issue, any data that comes into Asciidoctor 0.1.3 is force encoded to UTF-8 on Ruby 1.9 and above. Resolves issue 308.

Additional bug fixes

  • The Asciidoctor CLI no longer splits attribute key/value pairs on the first equal sign. Resolves issue 291.

  • Asciidoctor no longer crashes if to_file and base_dir are both set. Resolves issue 335.

  • DocBook renderer works if the author is defined using document attributes. Resolves issue 301.

Compliance fixes

doctitle attribute

The doctitle attribute can be used anywhere in a document. It’s value is identical to the value returned by Document#doctitle.

AsciiDoc doctitle syntax
= Document Title

The document title is {doctitle}.
doctitle output result
The document title is Document Title.

Horizontal layout for labeled lists added to DocBook 4.5 backend

Example:

[horizontal]
first term:: definition
+
more detail

second term:: definition

Renders:

<informaltable tabstyle="horizontal" frame="none" colsep="0" rowsep="0">
<tgroup cols="2">
<colspec colwidth="15*"/>
<colspec colwidth="85*"/>
<tbody valign="top">
<row>
<entry>
<simpara>first term</simpara>
</entry>
<entry>
<simpara>definition</simpara>
<simpara>more detail</simpara>
</entry>
</row>
<row>
<entry>
<simpara>second term</simpara>
</entry>
<entry>
<simpara>definition</simpara>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>

Consecutive terms in labeled list share same varlistentry

Consecutive terms in a labeled list share the same varlistentry in the docbook backend.

Example:

term::
alt term::
definition

Produces:

<variablelist>
<varlistentry>
<term>
term
</term>
<term>
alt term
</term>
<listitem>
<simpara>
definition
</simpara>
</listitem>
</varlistentry>
</variablelist>

Special sections and styles

The partintro and abstract styles can be used on open blocks and are handled correctly by the renderer.

Sections assigned the glossary and appendix styles are now handled correctly in Asciidoctor.

Assign document variables inline

Document variables can be assigned using the following syntax:

{set:<attrname>[!][:<value>]}

For example:

{set:sourcedir:src/main/java}

It’s effectively the same as:

:sourcedir: src/main/java

This is important for being able to assign document attributes in places where attribute entry lines are not normally processed, such as in a table cell.

An example of where this might be used is documented in the how to set the background color of a table cell tip.

Block title not allowed above document title

Previously, a block title line above a level 0 heading was being processed and passed on to the first content block. AsciiDoc sees the block title as the first line of content and does not create a header as a result. Asciidoctor’s behavior is now consistent with AsciiDoc.

Example:

.Misplaced block title
= Document Title
Author Name

The following input is now rendered as a link.

irc://irc.freenode.org/#asciidoctor

CLI and API updates

Specify any backend with the Asciidoctor CLI

Previously, the Asciidoctor CLI restricted the user from specifying a backend other than html5 or docbook45. Now, any non-empty value can be specified as the backend. This is critical when you want to use a custom backend, such as deck.js or dzslides.

Set safe mode with a string, symbol or integer in the Asciidoctor API

The safe level option now accepts a symbol, string or integer value to lookup the safe level.

result = Asciidoctor.render_file('master.ad', :safe => 'server')

can now be written as:

result = Asciidoctor.render_file('master.ad', :safe => :server)

Use a string or symbol to set the backend in the Asciidoctor API

The backend option now accepts a symbol or string value.

result = Asciidoctor.render_file('master.ad', :backend => 'docbook')

can now be written as:

result = Asciidoctor.render_file('master.ad', :backend => :docbook)

Pass attributes as a string or array to the Asciidoctor API

Previously, attributes were passed as a Hash to the Asciidoctor API methods. At times, this made the argument list feel heavy. These methods now accept the attributes as a string or array.

For instance, consider a user wants to pass the attribute that enables the table of contents (toc) and auto-numbering (numbered). Previously, that required:

result = Asciidoctor.render_file('master.ad',
    :attributes => {'toc' => '', 'numbered' => ''})

Since both attributes are simple flags, the invocation can be simplified as:

result = Asciidoctor.render_file('master.ad',
    :attributes => ['toc', 'numbered'])

It can be further simplified using the array-from-string shorthand in Ruby:

result = Asciidoctor.render_file('master.ad',
    :attributes => %w(toc numbered))

That leads us into attributes specified as a string:

result = Asciidoctor.render_file('master.ad',
    :attributes => 'toc numbered')

That’s quite an improvement over the original call.

If the attribute requires a value, such as source-highlighter, you just use the key=value form:

result = Asciidoctor.render_file('master.ad',
    :attributes => 'toc numbered source-highlighter=coderay')

This API call parallels this commandline invocation:

$ asciidoctor -a toc -a numbered -a source-highlighter=coderay master.adoc

This enhancement is particularly useful in the integrations, such as the Gradle plugin.

Learn more in the Asciidoctor Docs: Asciidoctor Ruby API | Asciidoctor Java API

And that’s a wrap!

Thanks!

As we hoped, Asciidoctor 0.1.2 downloads broke into the next increment of 10,000. RubyGems.org was reporting over 20,000 downloads of the Asciidoctor gem prior to this release and Maven Central over 100 downloads of the Java integration. We look forward reaching new landmarks with 0.1.3.

The level of participation in the Asciidoctor project continues to grow at an impressive rate. We welcomed several new projects in this development iteration, including Asciidoclet, a Javadoclet for writing Javadoc in AsciiDoc by John Ericksen, as well as several AsciiDoc editor initiatives. We’re very grateful to everyone who participates, especially those who contribute and spread the word :)

We’d especially like to thank the following people for their contributions and feedback on this release:

A special shout out to Brian Leathem for finding a critical regression the night before the release.

Additional thanks goes to everyone who is using the project and has contributed to it. Together, we’re making documentation fun, easy, and rewarding!

What’s next?

This release is just the beginning of the release train. Look for releases of the Java integration, Maven plugin, Gradle plugin and more recent additions such as the editors.


Asciidoctor Java integration 0.1.2.1 released!

by Alex Soto -

The Asciidoctor Java integration is the official means of using Asciidoctor to render your AsciiDoc documentation using Java instead of Ruby.

The following issues have been resolved in version 0.1.2.1:

  • Upgraded JRuby version to 1.7.4. Resolves #39.

  • Fixed a bug with to_dir and to_file options when render method was called. Resolves #38.

  • Fixed a NPE in AsciidocDirectoryWalker class when directory was not existing. Resolves #34.

  • Promoted stylesheet and stylesdir options to attributes in the fluent API. Resolves #30.

  • Fixed a bug with boolean attributes (for JRuby "" is true and null is false). Resolves #29.

  • Promoted linkcss option to attributes in the fluent API. Resolves #28.

  • Promoted toc option to attributes in the fluent API. Resolves #27.

  • Added renderFiles method which renders a list of AsciiDoc files. Resolves #23.

  • Added create method where you can pass the gem_path variable. Resolves #22, you still need to do some work yourself for adapting to OSGi, but reflection is not required anymore.

  • Fixed a bug with copycss attribute which throws a fatal error when was set with linkcss attribute. Resolves #21.

  • Added Options and Attributes class to set parameters to Asciidoctor. Resolves #19.

  • Changed scope of gems to provided. Resolves #18.

For more information, visit the Asciidoctor Java integration project on GitHub.


Asciidoctor Maven plugin 0.1.2.1 released!

by Jason Porter -

Some great things have happened for the Asciidoctor Maven plugin since the last release, I’m happy to announce the release of version 0.1.2.1!

This release is still based upon the version 0.1.2 release of both the Asciidoctor Java integration project and the Asciidoctor projects. This release contains bug fixes and a couple of new features, but is still fully compatible with the 0.1.2 release.

Plugin artifact information
Group ID Artifact ID Latest versions Download

org.asciidoctor

asciidoctor-maven-plugin

0.1.2.1

pom jar

Upgrading to 0.1.2.1 (recommended) is simple. Just update the version in your Maven POM. All necessary dependencies should be pulled in via Maven.

For more information about issues fixed in this release, please see the 0.1.2.1 milestone in the issue tracker!


Asciidoctor Java integration 0.1.2 released!

by Alex Soto -

The Asciidoctor Java integration is the official means of using Asciidoctor to render all your AsciiDoc documentation using Java instead of Ruby.

In this new release, the following issues has been resolved:

  • Upgraded Asciidoctor gem to 0.1.2. Resolves #17.

  • Reduced startup time by tuning JRuby. Resolves #15, documented in optimization.

  • Renamed AsciidocDirectoryWalker class to AsciiDocDirectoryWalker to follow naming conventions. Resolves #12.

    If you’re currently using AsciidocDirectoryWalker, you’ll need to refactor your code to reflect this name change.
  • Promoted backend and doctype attributes to options in the fluent API. Resolves #11.

  • Added a render method which takes a Reader and Writer interface as input and output content. Resolves #9, documented in usage.

  • Changed Asciidoctor#renderFile method parameter type from java.lang.String to java.io.File.

    If you’re currently using the Asciidoctor#renderFile method, you’ll need to refactor your code to reflect this type change.

For more information, visit the Asciidoctor Java integration project on GitHub.


Asciidoctor Maven plugin 0.1.2 released!

by Jason Porter -

Following the tradition of quick updates shortly after the release of Asciidoctor, I’d like to announce the release of versions 0.1.2 and 0.1.1.1 of the Asciidoctor Maven plugin!

These releases are based on Asciidoctor 0.1.2 and 0.1.1, respectively. Both versions of the plugin have been migrated to the newly released Asciidoctor Java integration, and thus supports all the options exposed through that library.

Plugin artifact information
Group ID Artifact ID Latest versions Download

org.asciidoctor

asciidoctor-maven-plugin

0.1.2

pom jar

org.asciidoctor

asciidoctor-maven-plugin

0.1.1.1

pom jar

Upgrading to 0.1.2 (recommended) or 0.1.1.1 is simple. Just update the version in your Maven POM. All necessary dependencies should be pulled in via Maven.

For more information about issues fixed in this release, please see the 0.1.2 milestone in the issue tracker!


Asciidoctor 0.1.2 released!

by Dan Allen -

We’re proud to announce the release of Asciidoctor 0.1.2!

Asciidoctor is an open source text processor and publishing toolchain for converting AsciiDoc markup into HTML 5, DocBook 4.5 and other formats.

The focus of this release cycle was on:

The valuable feedback we’ve received has helped bring Asciidoctor to 99% compliance with the AsciiDoc syntax. The improvements have also given Asciidoctor a 28% boost in speed, now more than 30x as fast as AsciiDoc.

Key improvements

default stylesheet

Asciidoctor now ships a default stylesheet! This stylesheet gives documents a unique, modern and elegant look and feel out of the box. To learn how to use it, read the stylesheet section of How do I render a document?. Visit http://themes.asciidoctor.org to a preview the default stylesheet and other themes created using the Asciidoctor stylesheet factory. Resolves issues #76 and #165.

docinfo files

Supplemental document header files (i.e., docinfo files) are now included in the rendered output when enabled. These files are used to include custom content into the header of the HTML or DocBook output. Resolves issues #116 and #193.

leveloffset

The leveloffset attribute is now supported. This attribute allows several standalone documents to be combined as a master document. Resolves issue #212.

partial includes

The include macro can now be used to include select regions of a file by line numbers, line ranges or tagged regions. This enhancement to the include macro is unique to Asciidoctor. Resolves issue #226.

footnotes in embedded mode

Footnotes are now rendered at the bottom of the output in embedded mode (when the header and footer are disabled), such as on GitHub or in a page generated by Awestruct. Resolves issue #206.

table of contents macro

Support has been added for the toc macro, which allows you to place the toc anywhere in the document. This feature makes it possible to include a toc in the document when in embedded mode, such as on GitHub or in a page generated by Awestruct. Resolves issues #269 and #221.

audio and video macros

Macros have been added to output HTML 5 audio and video tags. These macros parallel the block image macro. Resolves issue #155.

safe mode and embedded attributes

The attributes safe-mode-level, safe-mode-name and safe-mode-%name% are now assigned to match the active safe mode. The attribute embedded is assigned to indicate the document is rendered using the embedded document template. Resolves issue #244.

multiple authors

You can now specify multiple authors in the header of the document, separated by semi-colons. In the DocBook backend, the authors are listed in an authorgroup element in the document info section. This feature is unique to Asciidoctor. Resolves issue #223.

email macro

The inline email address and the inline mailto macro are now recognized. Resolves issue #213.

secure paths

The path resolution logic was simply too fragile as a result of relying on Ruby core libraries. The code has been completely rewritten so that paths are properly normalized and secured, with loads of tests to back it up.

custom block substitutions

Substitution groups applied to block content can now be customized using the subs block attribute. Resolves issue #220.

masquerading blocks and paragraphs

The open block and paragraphs can now masquerade as any style of block. Masquerading is also available for other blocks, where applicable. This was one of the weakest areas of Asciidoctor, now fully compliant (and even a little extra). Resolves issue #187.

In order to implement full support for masquerading blocks, paragraphs and custom block substitutions, the main block parsing code had to be reworked. The refactoring not only cleaned up the code, but laid the foundation necessary to implement block filters and other extensions.

Some of the improvements to Asciidoctor have resolved issues inherent in AsciiDoc. Fortunately, AsciiDoc is configurable enough that these issues can be "ported" to AsciiDoc without changing the core. We now maintain and ship an AsciiDoc configuration file, asciidoc.conf, that makes AsciiDoc conform to Asciidoctor’s behavior and enhancements. Resolves issue #257.

The full list of new features, enhancements and patches implemented in this release can be viewed by filtering on the 0.1.2 milestone in the issue tracker.

New website and documentation

You’re looking at it!

During the 0.1.2 release cycle, we created a proper website for Asciidoctor and focused on getting the user documentation started. Both the website and documentation are, of course, written in AsciiDoc.

Sarah White has taken on the initiative of untangling information in the AsciiDoc user guide and man pages and converting it to something consumable so users can get started quickly with the AsciiDoc and Asciidoctor toolchains.

I wrote up an introduction to AsciiDoc, an AsciiDoc writer’s guide and an AsciiDoc syntax quick reference to reveal the elegance of the AsciiDoc syntax and get writers the information they need to be productive and proficient with AsciiDoc. I summarized this information in an article titled The Zen of Writing (Ascii)Docs, published in the April issue of NFJS, The Magazine (also produced from articles written in AsciiDoc).

Look for more details about the website and documentation in a future news post.

Thanks!

The amount of participation in the Asciidoctor project, particularly around the integrations, has increased tremendously since the last release. Asciidoctor 0.1.1 crossed the 10,000 downloads mark prior to this release. We look forward to 0.1.2 breaking the next 10,000.

We’re very grateful to everyone who participates, especially those who contribute and spread the word :) We’d especially like to thank the following people for their contributions and feedback:

Together, we’re making documentation easy, fun and rewarding!


  • 2 of 2