{"id":66477,"date":"2022-08-15T09:01:42","date_gmt":"2022-08-15T09:01:42","guid":{"rendered":"https:\/\/www.cryptocabaret.com\/?p=66477"},"modified":"2022-08-15T09:01:42","modified_gmt":"2022-08-15T09:01:42","slug":"try-asciidoc-instead-of-markdown","status":"publish","type":"post","link":"https:\/\/www.cryptocabaret.com\/?p=66477","title":{"rendered":"Try Asciidoc instead of Markdown"},"content":{"rendered":"<p><span class=\"field field--name-title field--type-string field--label-hidden\">Try Asciidoc instead of Markdown<\/span><br \/>\n<span class=\"field field--name-uid field--type-entity-reference field--label-hidden\"><a title=\"View user profile.\" href=\"https:\/\/opensource.com\/users\/seth\" class=\"username\">Seth Kenlon<\/a><\/span><br \/>\n<span class=\"field field--name-created field--type-created field--label-hidden\">Mon, 08\/15\/2022 &#8211; 03:00<\/span><\/p>\n<div data-drupal-selector=\"rate-node-70154\" class=\"rate-widget-thumbs-up\" title=\"Register or Login to like.\">\n<div class=\"rate-thumbs-up-btn-up vote-pending\">1 reader likes this<\/div>\n<div class=\"rate-score\">1 reader likes this<\/div>\n<\/div>\n<div class=\"clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item\">\n<p>I&#8217;m a happy user of the XML-based <a href=\"https:\/\/opensource.com\/article\/17\/9\/docbook\" target=\"_blank\" rel=\"noopener\">Docbook<\/a> markup language. To me, it&#8217;s a precise, explicit, and detailed system that allows me to have contextual and domain-specific metadata in what I write. Best of all, though, it can be transformed (that&#8217;s what XML users call it when XML is converted into another format) into nearly any format, including HTML, EPUB, FO for PDF, plain text, and more. With great power comes a lot of typing, though, and sometimes Docbook feels like it&#8217;s surplus to requirements. Luckily, there&#8217;s <a href=\"http:\/\/asciidoc.org\/\" target=\"_blank\" rel=\"noopener\">Asciidoc<\/a>, a system of writing plain text with the same markup-less feel of Markdown, but that transforms to Docbook to take advantage of its precision and flexibility.<\/p>\n<h2>Asciidoc rules<\/h2>\n<p>Like Markdown, one of the goals of Asciidoc is that you don&#8217;t really have to <em>learn<\/em> it. Instead, it aims to be intuitive and natural. You may well have written snippets of valid Asciidoc without realizing it if you&#8217;ve ever added a little style to a plain text document for readability. For instance, if you habitually separate paragraphs with a blank line, then you&#8217;ve written the equivalent of the HTML <code><\/p>\n<p><\/code> or Docbook <code><para><\/para><\/code> tag. It seems obvious, and yet in academia separating paragraphs with blank lines isn&#8217;t generally done, so even this simple convention is technically markup.<\/p>\n<p>Here&#8217;s the most common syntax.<\/p>\n<\/p>\n<div class=\"embedded-resource-list callout-float-right\">\n<div class=\"field field--name-title field--type-string field--label-hidden field__item\">More Linux resources<\/div>\n<div class=\"field field--name-links field--type-link field--label-hidden field__items\">\n<div class=\"field__item\"><a href=\"https:\/\/developers.redhat.com\/cheat-sheets\/linux-commands-cheat-sheet\/?intcmp=70160000000h1jYAAQ\">Linux commands cheat sheet<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/developers.redhat.com\/cheat-sheets\/advanced-linux-commands\/?intcmp=70160000000h1jYAAQ\">Advanced Linux commands cheat sheet<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/www.redhat.com\/en\/services\/training\/rh024-red-hat-linux-technical-overview?intcmp=70160000000h1jYAAQ\">Free online course: RHEL technical overview<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/downloads\/cheat-sheet-networking?intcmp=70160000000h1jYAAQ\">Linux networking cheat sheet<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/downloads\/cheat-sheet-selinux?intcmp=70160000000h1jYAAQ\">SELinux cheat sheet<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/downloads\/linux-common-commands-cheat-sheet?intcmp=70160000000h1jYAAQ\">Linux common commands cheat sheet<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/resources\/what-are-linux-containers?intcmp=70160000000h1jYAAQ\">What are Linux containers?<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/tags\/linux?intcmp=70160000000h1jYAAQ\">Our latest Linux articles<\/a><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<h3>Text styles<\/h3>\n<p>Text styles include the basics such as bold, italics, and code font. Most of the notation is relatively intuitive, with the possible exception of italics.<\/p>\n<p><strong>*Bold*<\/strong><\/p>\n<p><em>_Italics_<\/em><\/p>\n<p><em><strong>*_Bold and italic_*<\/strong><\/em><\/p>\n<p><code>`Monospace or code`<\/code><\/p>\n<h3>Code<\/h3>\n<p>Code is marked with backticks or by explicit declaration of a code block.<\/p>\n<p><code>`Monospace or code`<\/code><\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"text geshifilter-text\">[source,python]<br>\n----<br>\nprint('a whole code block')<br>\n----<\/div><\/div><\/pre>\n<h3>Headlines<\/h3>\n<p>Headings are marked with leading equal signs (<code>=<\/code>):<\/p>\n<p>= Heading 1 (<code><\/p>\n<h1><\/h1>\n<p><\/code>)<\/p>\n<p>== Heading 2 (<code><\/p>\n<h2><\/h2>\n<p><\/code>)<\/p>\n<p>=== Heading 3 (<code><\/p>\n<h3><\/h3>\n<p><\/code>)<\/p>\n<p>==== Heading 4 (<code><\/p>\n<h4><\/h4>\n<p><\/code>)<\/p>\n<p>===== Heading 5 (<code><\/p>\n<h5><\/h5>\n<p><\/code>)<\/p>\n<p>====== Heading 6 (<code><\/p>\n<h6><\/h6>\n<p><\/code>)<\/p>\n<h3>Links<\/h3>\n<p>Hyperlinks favor the link first, followed by the word or phrase used to &#8220;disguise&#8221; the link as text.<\/p>\n<p>This is a <a href=\"http:\/\/example.com%5Bhyperlink\/\">http:\/\/example.com[hyperlink<\/a>] that leads to the example.com site.<\/p>\n<p>I don&#8217;t find this as elegant as Markdown&#8217;s link notation, but then it&#8217;s a lot more flexible. For instance, you can add attributes in Asciidoc links:<\/p>\n<p>This is a <a href=\"https:\/\/example.com%5Blink,role=external,window=_blank\/\">https:\/\/example.com[link,role=external,window=_blank<\/a>] with the <code>target=\"_blank\"<\/code> attribute set.<\/p>\n<h3>Lots more<\/h3>\n<p>Asciidoc also features internal links so you can link from one section to another, a standard for document headers, automatic table of content generation, the ability to include other documents within another, and much much more.<\/p>\n<p>But best of all, Asciidoc is actually <em>standardized<\/em>. Not everyone knows it, but the term &#8220;Markdown&#8221; doesn&#8217;t refer to one markup-light language. Different organizations and groups regularly customize and alter Markdown for their own use, so when you use Markdown you really ought to verify <em>which<\/em> markdown you&#8217;re meant to use. Many of the conventions you might have learned from one website using Markdown don&#8217;t carry over to another site using Markdown. There&#8217;s essentially no standard for Markdown, and that&#8217;s resulted in such confusion that the <a href=\"http:\/\/commonmark.org\/\" target=\"_blank\" rel=\"noopener\">Commonmark.org<\/a> project has been formed in an attempt to assemble a standardized definition.<\/p>\n<p>Asciidoc was designed from the start with a standard definition, so the tool or website that claims to parse Asciidoc actually does parse all valid Asciidoc, because there&#8217;s only one valid Asciidoc.<\/p>\n<h2>Asciidoc to anything<\/h2>\n<p>The point of writing in a markup-light language like Asciidoc is to ensure predictability and consistency when text is parsed. You want a person to write a script, or to run an application someone else has written, to be able to transform your plain text into whatever format works best for them. Sometimes that&#8217;s HTML (incidentally Markdown&#8217;s native output format, and fallback language when there&#8217;s something missing from its own syntax.) Other times it&#8217;s an EPUB, or a PDF for printing, Docbook, a LibreOffice document, or any number of possible output formats.<\/p>\n<p>There are several tools to help you transform Asciidoc to another format. A popular command is <a href=\"https:\/\/asciidoctor.org\/\" target=\"_blank\" rel=\"noopener\">Asciidoctor<\/a>, which you can install using your package manager. For instance, on Fedora, CentOS, or RHEL:<\/p>\n<pre>\n<span class=\"geshifilter\"><code class=\"bash geshifilter-bash\"><span class=\"co4\">$ <\/span><span class=\"kw2\">sudo<\/span> dnf <span class=\"kw2\">install<\/span> asciidoctor<\/code><\/span><\/pre>\n<p>On Debian-based systems:<\/p>\n<pre>\n<span class=\"geshifilter\"><code class=\"bash geshifilter-bash\"><span class=\"co4\">$ <\/span><span class=\"kw2\">sudo<\/span> apt <span class=\"kw2\">install<\/span> asciidoctor<\/code><\/span><\/pre>\n<p>Alternately, you can install it on any OS with Ruby:<\/p>\n<pre>\n<span class=\"geshifilter\"><code class=\"bash geshifilter-bash\"><span class=\"co4\">$ <\/span>gem <span class=\"kw2\">install<\/span> asciidoctor<\/code><\/span><\/pre>\n<p>Here&#8217;s a simple example of an Asciidoc document, which you can create using any <a href=\"https:\/\/opensource.com\/\" target=\"_blank\" rel=\"noopener\">text editor<\/a> or even a word processor (like <a href=\"https:\/\/opensource.com\/\" target=\"_blank\" rel=\"noopener\">LibreOffice<\/a>) as long as you save the file as plain text. Most applications expect a plain text document to use the extension <code>.txt<\/code>, and while it&#8217;s a convention use the extension <code>.adoc<\/code> for Asciidoc, it&#8217;s not necessary. Asciidoctor doesn&#8217;t require any special extension.<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"bash geshifilter-bash\">= This is my example document<br><br>\nIt<span class=\"st_h\">'s not written in _Markdown_, nor _reStructured Text_.<br>\nThis is *Asciidoc*.<br><br>\nIt can be transformed into nearly any format using the tool `Asciidoctor` and other similar parsers.<br>\nTry it for yourself!<\/span><\/div><\/div><\/pre>\n<p>To transform an Asciidoc document to HTML, run <code>asciidoctor<\/code>:<\/p>\n<pre>\n<span class=\"geshifilter\"><code class=\"bash geshifilter-bash\"><span class=\"co4\">$ <\/span>asciidoctor example.adoc<\/code><\/span><\/pre>\n<p>The file <code>example.adoc<\/code> is transformed into HTML5 by default, but you can use different backends to gain access to more formats.<\/p>\n<h2>From Asciidoc to XML<\/h2>\n<p>My favourite is the Docbook backend, because it transforms my Asciidoc to Docbook XML, allowing me to use my existing Docbook toolchain (custom Makefiles, Apache FOP, <code>xsltproc<\/code>, <code>xmlto<\/code>, and so on) to complete my work:<\/p>\n<pre>\n<span class=\"geshifilter\"><code class=\"bash geshifilter-bash\"><span class=\"co4\">$ <\/span>asciidoctor <span class=\"re5\">--backend<\/span> docbook5 example.adoc<\/code><\/span><\/pre>\n<p>This outputs Docbook XML. The final two built-in backends are <code>xhtml5<\/code> and <code>manpage<\/code>.<\/p>\n<h2>From Asciidoc to EPUB<\/h2>\n<p>If you want to turn your writing into an ebook, you can install the EPUB3 backend:<\/p>\n<pre>\n<span class=\"geshifilter\"><code class=\"bash geshifilter-bash\"><span class=\"co4\">$ <\/span>gem <span class=\"kw2\">install<\/span> asciidoctor-epub3<\/code><\/span><\/pre>\n<p>Transform your Asciidoc into EPUB:<\/p>\n<pre>\n<span class=\"geshifilter\"><code class=\"bash geshifilter-bash\"><span class=\"co4\">$ <\/span>asciidoctor-epub3 example.adoc<\/code><\/span><\/pre>\n<h2>From Asciidoc to PDF<\/h2>\n<p>You can transform Asciidoc directly to PDF, too:<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"bash geshifilter-bash\">$ gem <span class=\"kw2\">install<\/span> asciidoctor-pdf<br>\n$ asciidoctor-pdf example.adoc<\/div><\/div><\/pre>\n<article class=\"align-center media media--type-image media--view-mode-default\">\n<div class=\"field field--name-field-media-image field--type-image field--label-hidden field__item\">  <img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/opensource.com\/sites\/default\/files\/2022-08\/asciidoc-pdf.webp\" width=\"799\" height=\"169\" alt=\"Asciidoctor-pdf\"><\/div>\n<div class=\"field field--name-field-caption field--type-text-long field--label-hidden caption field__item\"><span class=\"caption__byline\">Image by: <\/span><\/p>\n<p>(Seth Kenlon, CC BY-SA 4.0)<\/p>\n<\/div>\n<\/article>\n<h2>Who should use Asciidoc<\/h2>\n<p>Asciidoc is excellent for technical writers and writers who have precise requirements for how they want text to be organized and parsed. It&#8217;s a clear and strictly defined markup format that eliminates the confusion of competing Markdown formats, and it transforms to all the major formats. Asciidoc is admittedly more verbose and possibly less intuitive than Markdown, but it&#8217;s still just plain text so you can author on anything, and Asciidoctor makes processing easy. Next time you write a document for any purpose, consider trying Asciidoc.<\/p>\n<\/div>\n<div class=\"clearfix text-formatted field field--name-field-article-subhead field--type-text-long field--label-hidden field__item\">\n<p>Next time you write, use Asciidoc and Asciidoctor as alternatives to Markdown.<\/p>\n<\/div>\n<div class=\"field field--name-field-lead-image field--type-entity-reference field--label-hidden field__item\">\n<article class=\"media media--type-image media--view-mode-caption\">\n<div class=\"field field--name-field-media-image field--type-image field--label-hidden field__item\">  <img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.cryptocabaret.com\/wp-content\/uploads\/2022\/08\/laptop_screen_desk_work_chat_text-1.png\" width=\"1040\" height=\"584\" alt=\"Person using a laptop\" title=\"Person using a laptop\"><\/div>\n<\/article>\n<\/div>\n<div class=\"field field--name-field-tags field--type-entity-reference field--label-hidden field__items\">\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/tags\/linux\" hreflang=\"en\">Linux<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/tags\/documentation\" hreflang=\"en\">Documentation<\/a><\/div>\n<\/p><\/div>\n<div class=\"field field--name-field-listicle-title field--type-string field--label-hidden field__item\">What to read next<\/div>\n<div class=\"field field--name-field-listicles field--type-entity-reference field--label-hidden field__items\">\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/article\/19\/8\/markdown-beginners-cheat-sheet\" hreflang=\"und\">Markdown beginner&#8217;s cheat sheet<\/a><\/div>\n<\/p><\/div>\n<div class=\"field field--name-field-default-license field--type-list-string field--label-hidden field__item\"><a rel=\"license\" href=\"http:\/\/creativecommons.org\/licenses\/by-sa\/4.0\/\"><br \/>\n        <img decoding=\"async\" alt=\"Creative Commons License\" src=\"https:\/\/www.cryptocabaret.com\/wp-content\/uploads\/2022\/08\/cc-by-sa--21.png\" title=\"This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.\"><\/a>This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.<\/div>\n<section class=\"field field--name-field-comments field--type-comment field--label-hidden comment-wrapper\">\n<div class=\"comments__count\">\n<div class=\"login\"><a href=\"https:\/\/opensource.com\/user\/register?absolute=1\">Register<\/a> or <a href=\"https:\/\/opensource.com\/user\/login?current=\/rss.xml&amp;absolute=1\">Login<\/a> to post a comment.<\/div>\n<\/p><\/div>\n<\/section>\n<p class=\"wpematico_credit\"><small>Powered by <a href=\"http:\/\/www.wpematico.com\" target=\"_blank\" rel=\"noopener\">WPeMatico<\/a><\/small><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Try Asciidoc instead of Markdown Seth Kenlon Mon, 08\/15\/2022 &#8211; 03:00 1 reader likes this 1 reader likes this I&#8217;m a happy user of the XML-based Docbook markup language. To me, it&#8217;s a precise, explicit, and detailed system that allows me to have contextual and domain-specific metadata in what I write. Best of all, though, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":66478,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[307],"tags":[],"class_list":["post-66477","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-open-source"],"_links":{"self":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/posts\/66477","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=66477"}],"version-history":[{"count":0,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/posts\/66477\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/media\/66478"}],"wp:attachment":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=66477"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=66477"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=66477"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}