Fix AsciiDoc Display in Gitea ############################# :category: Ruby :date: 2019-10-17 13:00:00 +03:00 :tags: asciidoc, asciidoctor, gitea, git .. _my own Gitea: https://sandfox.org/ .. _Gitea: https://gitea.io/ .. _reStructuredText: http://docutils.sourceforge.net/rst.html .. _AsciiDoc: https://asciidoctor.org/ After installing `my own Gitea`_ I looked for the support for the markups I use. Gitea_ has support for external markup renderers and the official doc lists configs for both reStructuredText_ and AsciiDoc_: .. TEASER_END .. code-block:: ini [markup.asciidoc] ENABLED = true FILE_EXTENSIONS = .adoc,.asciidoc RENDER_COMMAND = "asciidoctor --out-file=- -" ; Input is not a standard input but a file IS_INPUT_FILE = false [markup.restructuredtext] ENABLED = true FILE_EXTENSIONS = .rst RENDER_COMMAND = rst2html.py IS_INPUT_FILE = false RST works perfectly but AsciiDoc has two visible problems: .. figure:: /images/ruby/gitea-asciidoc/glitch1.png :width: 576px Glitch on the top .. figure:: /images/ruby/gitea-asciidoc/glitch2.png :width: 408px Useless timestamp on the bottom Unfortunately it seems that the Asciidoctor CLI cannot produce html code that will be correctly rendered by Gitea so we need to use the Ruby interface. .. code-block:: ruby require 'asciidoctor' # Load the document in the embeddable mode document = Asciidoctor.load STDIN.read # Embeddable doesn't display the main header so render it manually puts "

#{document.doctitle}

" # Render HTML puts document.convert Now replace the asciidoctor call with our new script: .. code-block:: ini [markup.asciidoc] ENABLED = true FILE_EXTENSIONS = .adoc,.asciidoc RENDER_COMMAND = "ruby /path/to/gitea-asciidoc.rb" ; Input is not a standard input but a file IS_INPUT_FILE = false and enjoy a non glitchy AsciiDoc render.