<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Gitea on tastyteablog</title>
		<link>https://blog.tastytea.de/tags/gitea/</link>
		<description>Recent content in Gitea on tastyteablog</description>
		<generator>Hugo 0.54.0 -- gohugo.io</generator>
		<language>en</language>
		<managingEditor>tastytea@tastytea.de (tastytea)</managingEditor>
		<webMaster>tastytea@tastytea.de (tastytea)</webMaster>
		<copyright>CC BY-NC 4.0</copyright>
		<lastBuildDate>Sat, 26 Jan 2019 13:03:36 +0100</lastBuildDate>
		<atom:link href="https://blog.tastytea.de/tags/gitea/index.xml" rel="self" type="application/rss+xml" />
		<item>
			<title>Using AsciiDoc(tor) with Gitea</title>
			<link>https://blog.tastytea.de/posts/using-asciidoc-with-gitea/</link>
			<pubDate>Sat, 26 Jan 2019 13:03:36 +0100</pubDate>
			<author>tastytea@tastytea.de (tastytea)</author>
			<guid>https://blog.tastytea.de/posts/using-asciidoc-with-gitea/</guid>
			<description>&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;In this blogpost I describe what I did to get AsciiDoc support into
&lt;a href=&#34;https://gitea.io/&#34;&gt;Gitea&lt;/a&gt;. If you want more than syntax highlighting and basic
formatting, Gitea has to be patched unfortunately(this
&lt;a href=&#34;https://github.com/go-gitea/gitea/issues/4935&#34;&gt;issue&lt;/a&gt; has already been reported).
But I think most people will only need to edit 1 configuration file and are
done.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;sect1&#34;&gt;
&lt;h2 id=&#34;_asciidoctor_or_asciidoc&#34;&gt;Asciidoctor or AsciiDoc?&lt;/h2&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;&lt;a href=&#34;https://asciidoctor.org/&#34;&gt;Asciidoctor&lt;/a&gt; has inbuilt support for
&lt;a href=&#34;https://highlightjs.org/&#34;&gt;highlight.js&lt;/a&gt;, the solution Gitea
uses and is therefore the best choice in most scenarios. If you can&amp;#8217;t or don&amp;#8217;t
want to use it you can use &lt;a href=&#34;http://asciidoc.org/&#34;&gt;AsciiDoc&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;Add the following section to &lt;code&gt;conf/app.ini&lt;/code&gt; in your Gitea path. The change
causes &lt;code&gt;.adoc&lt;/code&gt; files to be rendered with asciidoctor.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;listingblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;pre&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-ini&#34; data-lang=&#34;ini&#34;&gt;&lt;span class=&#34;k&#34;&gt;[markup.asciidoc]&lt;/span&gt;
&lt;span class=&#34;na&#34;&gt;ENABLED&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;true&lt;/span&gt;
&lt;span class=&#34;c1&#34;&gt;; List of file extensions that should be rendered by an external command&lt;/span&gt;
&lt;span class=&#34;na&#34;&gt;FILE_EXTENSIONS&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;.adoc,.asciidoc&lt;/span&gt;
&lt;span class=&#34;c1&#34;&gt;; External command to render all matching extensions&lt;/span&gt;
&lt;span class=&#34;na&#34;&gt;RENDER_COMMAND&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;&amp;#34;asciidoctor --backend=html5 --no-header-footer --attribute source-highlighter=highlightjs --out-file=- -&amp;#34;&lt;/span&gt;
&lt;span class=&#34;c1&#34;&gt;; Don&amp;#39;t pass the file on STDIN, pass the filename as argument instead.&lt;/span&gt;
&lt;span class=&#34;na&#34;&gt;IS_INPUT_FILE&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;false&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;If you want to use asciidoc instead the command would be:
&lt;code&gt;asciidoc --backend=xhtml11 --no-header-footer --attribute
source-highlighter=highlight --out-file=- -&lt;/code&gt;. I would choose the &lt;code&gt;xhtml11&lt;/code&gt;
backend because it is the only one that encloses code snippets with &lt;code&gt;&amp;lt;code&amp;gt;&lt;/code&gt;
tags. Instead of
&lt;a href=&#34;http://www.andre-simon.de/doku/highlight/en/highlight.html&#34;&gt;highlight&lt;/a&gt; you can
use &lt;a href=&#34;http://www.gnu.org/software/src-highlite/&#34;&gt;source-highlight&lt;/a&gt; or
&lt;a href=&#34;http://pygments.org/&#34;&gt;Pygments&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;If you use asciidoctor and don&amp;#8217;t need tables or other fancy stuff you&amp;#8217;re now
done! If you use asciidoc, you&amp;#8217;ll have to patch Gitea to get syntax
highlighting.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;sect1&#34;&gt;
&lt;h2 id=&#34;_patching_gitea&#34;&gt;Patching Gitea&lt;/h2&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;The sanitizer strips almost all attributes from HTML-tags, as a security
precaution. I&amp;#8217;ve added exceptions for:&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;ulist&#34;&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;class&lt;/code&gt; attributes on all the tags Asciidoctor introduces,&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Numerous attributes on &lt;code&gt;table&lt;/code&gt; tags,&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;align&lt;/code&gt; and &lt;code&gt;valign&lt;/code&gt; on &lt;code&gt;td&lt;/code&gt; tags,&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;style&lt;/code&gt; attributes on &lt;code&gt;span&lt;/code&gt; tags, but only if they contain nothing more than
color and font definitions.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;If you use Asciidoctor with highlight.js output, you don&amp;#8217;t need to allow &lt;code&gt;style&lt;/code&gt;
attributes, if you don&amp;#8217;t use tables you can omit the lines that deal with them
and the &lt;code&gt;class&lt;/code&gt; exception is only useful if you add custom CSS to use them.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;Apply the patch with &lt;code&gt;patch -p1 &amp;lt; gitea_relax-sanitizer.patch&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;listingblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;pre&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-diff&#34; data-lang=&#34;diff&#34;&gt;&lt;span class=&#34;gh&#34;&gt;diff -ur a/modules/markup/sanitizer.go b/modules/markup/sanitizer.go
&lt;/span&gt;&lt;span class=&#34;gh&#34;&gt;&lt;/span&gt;&lt;span class=&#34;gd&#34;&gt;--- a/modules/markup/sanitizer.go   2019-01-26 16:04:56.014108339 +0100
&lt;/span&gt;&lt;span class=&#34;gd&#34;&gt;&lt;/span&gt;&lt;span class=&#34;gi&#34;&gt;+++ b/modules/markup/sanitizer.go   2019-01-26 16:03:21.776401012 +0100
&lt;/span&gt;&lt;span class=&#34;gi&#34;&gt;&lt;/span&gt;&lt;span class=&#34;gu&#34;&gt;@@ -38,6 +38,16 @@
&lt;/span&gt;&lt;span class=&#34;gu&#34;&gt;&lt;/span&gt; 
        // Custom URL-Schemes
        sanitizer.policy.AllowURLSchemes(setting.Markdown.CustomURLSchemes...)
&lt;span class=&#34;gi&#34;&gt;+       // Allow style on span tags
&lt;/span&gt;&lt;span class=&#34;gi&#34;&gt;+       sanitizer.policy.AllowAttrs(&amp;#34;style&amp;#34;).Matching(regexp.MustCompile(`^(background-)?color:[^;]+(; ?font[^;]+)?;?$`)).OnElements(&amp;#34;span&amp;#34;)
&lt;/span&gt;&lt;span class=&#34;gi&#34;&gt;+
&lt;/span&gt;&lt;span class=&#34;gi&#34;&gt;+       // Allow class attribute
&lt;/span&gt;&lt;span class=&#34;gi&#34;&gt;+       sanitizer.policy.AllowAttrs(&amp;#34;class&amp;#34;).OnElements(&amp;#34;code&amp;#34;, &amp;#34;pre&amp;#34;, &amp;#34;span&amp;#34;, &amp;#34;div&amp;#34;, &amp;#34;p&amp;#34;, &amp;#34;table&amp;#34;, &amp;#34;td&amp;#34;)
&lt;/span&gt;&lt;span class=&#34;gi&#34;&gt;+
&lt;/span&gt;&lt;span class=&#34;gi&#34;&gt;+       // Allow table attributes
&lt;/span&gt;&lt;span class=&#34;gi&#34;&gt;+       sanitizer.policy.AllowAttrs(&amp;#34;width&amp;#34;, &amp;#34;frame&amp;#34;, &amp;#34;rules&amp;#34;, &amp;#34;cellspacing&amp;#34;, &amp;#34;cellpadding&amp;#34;).OnElements(&amp;#34;table&amp;#34;)
&lt;/span&gt;&lt;span class=&#34;gi&#34;&gt;+       sanitizer.policy.AllowAttrs(&amp;#34;width&amp;#34;).OnElements(&amp;#34;col&amp;#34;)
&lt;/span&gt;&lt;span class=&#34;gi&#34;&gt;+       sanitizer.policy.AllowAttrs(&amp;#34;align&amp;#34;, &amp;#34;valign&amp;#34;).OnElements(&amp;#34;td&amp;#34;)
&lt;/span&gt;&lt;span class=&#34;gi&#34;&gt;&lt;/span&gt;    })
 }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;sect1&#34;&gt;
&lt;h2 id=&#34;_tables_without_borders&#34;&gt;Tables without borders&lt;/h2&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;I used tables without borders in a manpage I wrote for the list of options.
Gitea insist on drawing borders around them, so I had to create a custom CSS
snippet.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;In your Gitea directory, create &lt;code&gt;custom/templates/custom/header.tmpl&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;listingblock&#34;&gt;
&lt;div class=&#34;content&#34;&gt;
&lt;pre&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-css&#34; data-lang=&#34;css&#34;&gt;&lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;style&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&#34;c&#34;&gt;/* Additions for asciidoc */&lt;/span&gt;
    &lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nc&#34;&gt;markdown&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;nd&#34;&gt;not&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;code&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;nt&#34;&gt;table&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nc&#34;&gt;frame-none&lt;/span&gt;
    &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
        &lt;span class=&#34;k&#34;&gt;border&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt; &lt;span class=&#34;cp&#34;&gt;!important&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;
    &lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;
    &lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nc&#34;&gt;markdown&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;nd&#34;&gt;not&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;code&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;nt&#34;&gt;table&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nc&#34;&gt;grid-none&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;*&lt;/span&gt;
    &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
        &lt;span class=&#34;k&#34;&gt;border&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt; &lt;span class=&#34;cp&#34;&gt;!important&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;
    &lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;
&lt;span class=&#34;o&#34;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;style&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description>
		</item>
	</channel>
</rss>
