-
Notifications
You must be signed in to change notification settings - Fork 0
AsciiDoctor tips
- AsciiDoc support in Sublime Text 3
- Back quote and single quote side by side
- Display table of content in GitHub pages, Chrome, etc.
- DZSlides backend (slides generation)
- Emoji (emoticon, smiley) support in AsciiDoctor Chrome Extension
- "incompatible character encodings: UTF-8 and CP850" error
- Line breaks in AsciiDoc lists
- Open blocks to avoid having a style used for the preamble line
- Open blocks to handle list item continuation
- Text formatting: adding color
- Video rendering on GitHub or browser
Tip
|
Have a look at the source of the AsciiDoctor manual when you need some examples on a precise AsciiDoctor syntax. |
-
First, you have to download to download the zip containing all the source files from the GitHub repo of the AsciiDoc plugin for Sublime Text.
-
Then, you have to extract all its content in the
<Sublime Text 3 install dir>/Data/Packages/AsciiDoc
folder
Warning
|
Syntax highlighting works best with Sunburst or Twilight theme. For other themes, you may have to customize them. |
Having those 2 characters side by side can result in some unwanted substitution.
To avoid those, you can insert an {empty}
intrinsic attribute between them.
Example:
-
without {empty}
`wljmxclient.jar`'s MANIFEST ClassPath
renders as:
`wljmxclient.jar’s MANIFEST ClassPath
which is not what was expected, to know having
wljmxclient.jar
formatted as source code. -
with {empty}
`wljmxclient.jar`{empty}'s MANIFEST ClassPath]
renders as:
wljmxclient.jar
's MANIFEST ClassPathIn this last case,
wljmxclient.jar
is formatted as source code.
To display a table of content in GitHub pages (or in AsciiDoctor Chrome Extension, or, more generally everywhere…), 3 solutions are possible:
-
Using
:toc-placement: preamble
= My Document :toc: :toc-placement: preamble When using this method, you MUST add a preamble (the current line) to have the table of content displayed == First section Some text. == Second section Some other text.
-
Using
:toc-placement!:
= My Document :toc: :toc-placement!: toc::[] == First section Some text. == Second section Some other text.
-
Using
:toc: macro
= My Document // we use this method for the current GitHub wiki page :toc: macro toc::[] == First section Some text. == Second section Some other text.
Check following links for more info on this bug (after all, it should work with only setting the :toc:
attribute 😉):
-
https://github.com/jbake-org/jbake/issues/80#issuecomment-35131093
-
https://github.com/jbake-org/jbake/issues/144#issuecomment-57390764
-
You should also check the table of content section in the official AsciiDoctor user manual.
-
For Chrome (through Asciidoctor.js Live Preview), see https://github.com/asciidoctor/asciidoctor-chrome-extension#troubleshooting
You can also have a look at http://asciidoctor.org/news/2014/02/04/github-asciidoctor-0.1.4-upgrade-5-things-to-know/#5-table-of-contents
-
You need to give a name to images to have them autoresize:
image::images/an_image.jpg[title="a_title"]
-
Apparently, you need the
thread_safe
gem when generating the slides to have them work correctly.
This support was added in version 1.5.2.120.
You can see it there: https://github.com/asciidoctor/asciidoctor-chrome-extension
Here are some examples:
emoji:heart[2x] // the "[2x]" is a size modifier
emoji:rage[]
Tip
|
As explained in the user manual, you can change the icon size with the syntax icon:heart[2x] .
|
For a complete list of all emoji supported and their options, have a look at: https://github.com/asciidoctor/asciidoctor-chrome-extension/blob/master/app/js/vendor/asciidoctor-emoji-inline-macro.js
You will find a reference to http://www.tortue.me/ which gives you the whole list.
This is an AsciiDoctor error which is described here:
As explained, this is an encoding issue for which the workaround is to force the encoding of Ruby in the AsciiDoctor script.
Just replace
#!<ruby_install_path>/bin/ruby.exe
with
#!<ruby_install_path>/bin/ruby.exe -Eutf-8
in scripts:
-
<ruby_install_path>/bin/asciidoctor
-
<ruby_install_path>/bin/asciidoctor-safe
Here is also a Stackoverflow article on how to change an encoding in Ruby: http://stackoverflow.com/questions/15120955/ruby-how-to-specify-character-encoding-of-the-file-in-the-command-line-eexi
For line break in AsciiDoc lists, set the following attribute in the document’s header:
:lb: pass:[<br> +]
You can then use {lb}
in a list to leave a blank line in a list.
To avoid having the preamble bigger than the following text, you can use open blocks:
= My document title
--
This preamble will *not* be bigger than the following text.
--
== A first section
Here is some text!
This use is described here.
By using open blocks, you can, after having add a nested list, continue typing at the same level as its parent.
Example:
* List item one. +
Some text.
* List item two continued with an open block. +
Some text *before* the block
+
--
This paragraph is part of the preceding list item.
a. This list is nested and does not require explicit item continuation. +
This paragraph is part of the preceding list item.
b. List item b.
This paragraph belongs to item two of the outer list.
--
+
Some text *after* the block
renders as:
-
List item one.
Some text. -
List item two continued with an open block.
Some text before the blockThis paragraph is part of the preceding list item.
-
This list is nested and does not require explicit item continuation.
This paragraph is part of the preceding list item. -
List item b.
This paragraph belongs to item two of the outer list.
Some text after the block
-
As explained in the Asciidoc documentation (and not the Asciidoctor one), quoted text (bold, italic, etc.) can be given attributes which can be a color.
Example:
That's [green]#green#! +
[green]##c##[blue]##o##[red]##l##[yellow]##o##[orange]##r##
will give:
That’s green!
color
This is also indirectly explained in the section 22.5. Custom Styling With Attributes of the Asciidoctor documentation.
Warning
|
Unfortunately, this is not yet supported by GitHub Asciidoctor preview, see https://github.com/asciidoctor/asciidoctor-pdf/issues/376. |
We can use AsciiDoctor Conditional Directives to correctly render videos, depending on if document is on GitHub or on browser (using AsciiDoctor.js Live Preview on Chrome by example).
As a reminder, GitHub doesn’t support (2016/06/12) the video
macro.
ifdef::env-github[]
https://www.youtube.com/watch?v=4To7s3qln2s[vidéo sur YouTube]
endif::[]
ifdef::env-browser[]
video::4To7s3qln2s[youtube, width=640, height=480]
endif::[]
Of course, you can either use ifdef
or ifndef
depending of the situation.