From c49bf06e1bd3cbc3cdbd4f0e5c336db6ffae5933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20=E2=80=9CAd=C3=A6dra=E2=80=9D=20Hamel?= Date: Sat, 27 Apr 2024 02:00:14 +0200 Subject: [PATCH] Import into git --- Containerfile | 3 +++ README.asciidoc | 5 +++++ app.ini | 12 ++++++++++++ extended_rouge.rb | 11 +++++++++++ 4 files changed, 31 insertions(+) create mode 100644 Containerfile create mode 100644 README.asciidoc create mode 100644 app.ini create mode 100644 extended_rouge.rb diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..d0b1565 --- /dev/null +++ b/Containerfile @@ -0,0 +1,3 @@ +FROM gitea/gitea:1.21 +RUN apk --no-cache add asciidoctor ruby-rouge +COPY extended_rouge.rb /opt/extended_rouge.rb diff --git a/README.asciidoc b/README.asciidoc new file mode 100644 index 0000000..a84004e --- /dev/null +++ b/README.asciidoc @@ -0,0 +1,5 @@ += Gitea modifications + +My modifications on Gitea for use on my https://gitea.adaedra.eu/[instance]. + +Currently only adds support for Asciidoc documents with syntax highlighting. diff --git a/app.ini b/app.ini new file mode 100644 index 0000000..69aa657 --- /dev/null +++ b/app.ini @@ -0,0 +1,12 @@ +; Append to your own app.ini + +[markup.sanitizer.chroma] +ELEMENT = pre +ALLOW_ATTR = class +REGEXP = ^chroma$ + +[markup.asciidoc] +ENABLED = true +FILE_EXTENSIONS = .adoc,.asciidoc +RENDER_COMMAND = "asciidoctor -r /opt/extended_rouge -s -a showtitle -a source-highlighter=rouge --out-file=- -" +IS_INPUT_FILE = false diff --git a/extended_rouge.rb b/extended_rouge.rb new file mode 100644 index 0000000..896c511 --- /dev/null +++ b/extended_rouge.rb @@ -0,0 +1,11 @@ +class ExtendedRougeSyntaxHighlighter < (Asciidoctor::SyntaxHighlighter.for 'rouge') + register_for 'rouge' + + def format(_node, _lang, opts) + opts[:transform] = proc do |pre, code| + pre['class'] = 'chroma' + end + + super + end +end