Pass link prefixes to external markup parsers#5201
Conversation
Signed-off-by: Nicolas Lenz <nicolas@eisfunke.com>
Signed-off-by: Nicolas Lenz <nicolas@eisfunke.com>
Signed-off-by: Nicolas Lenz <nicolas@eisfunke.com>
Codecov Report
@@ Coverage Diff @@
## master #5201 +/- ##
==========================================
- Coverage 37.49% 37.47% -0.02%
==========================================
Files 310 310
Lines 45934 45934
==========================================
- Hits 17223 17215 -8
- Misses 26237 26242 +5
- Partials 2474 2477 +3
Continue to review full report at Codecov.
|
|
[markup.ascii]
ENABLED = false
FILE_EXTENSIONS = .adoc,.asciidoc
RENDER_COMMAND = "asciidoc --imagesdir=$GITEA_PREFIX_SRC --out-file=- -"
IS_INPUT_FILE = false |
For images |
lunny
left a comment
There was a problem hiding this comment.
[markup.ascii]
ENABLED = false
FILE_EXTENSIONS = .adoc,.asciidoc
RENDER_COMMAND = "asciidoc --imagesdir=$GITEA_PREFIX_RAW --out-file=- -"
IS_INPUT_FILE = falseIt's not right you can config as above, $GITEA_PREFIX_RAW is blank, you have to write a shell script and use $GITEA_PREFIX_RAW in your script.
[markup.asciidoc]
ENABLED = true
FILE_EXTENSIONS = .adoc,.asciidoc
RENDER_COMMAND = 'asciidoctor -b html5 -a imagesdir="$GITEA_PREFIX_RAW" -a relfileprefix="$GITEA_PREFIX_SRC" --out-file=- -'
IS_INPUT_FILE = falseThe config is not working with commit ref:078c404c3b0f283a242ad93b6a2f4cabb2575410 |
|
@Cellebyte Yes, it will not except you create a shell script and save that command there. |
|
@lunny thanks so i should copy a simple wrapper script with $@ to asciidoc? |
|
I mean you can create a script file such as #!/bin/bash
asciidoctor -b html5 -a imagesdir="$GITEA_PREFIX_RAW" -a relfileprefix="$GITEA_PREFIX_SRC" --out-file=- - |
|
Have done that. Will test it thanks for the reply ;) #!/bin/bash
asciidoctor -b html5 -a imagesdir="$GITEA_PREFIX_RAW/" -a relfileprefix="$GITEA_PREFIX_SRC/" --out-file=- $1 | sed 's/lang="en">//'Need to use sed, don't know why this lang="en" appears. |
@Eisfunke Would you mind to share the used |
|
Sounds like this might close #3025 - can anyone confirm? @Cellebyte did the shell script work in your case? |
|
Yes @garyritchie it worked very well. The only problem are svg images. But this is referenced in another Issue. |
|
Thanks @Cellebyte ! Where should I put the script? I'll need to include it when I build my gitea-asciidoc docker image (based on gitea:1.8). |
FROM gitea/gitea:1.8
RUN apk add --update --no-cache \
ruby \
sed \
asciidoctor && \
gem install --no-ri --no-rdoc coderay && \
gem update --no-ri --no-rdoc asciidoctor && \
gem cleanup && \
rm -rf /tmp/* /var/cache/apk/*
COPY asciidoc.sh /usr/bin/asciidoc.sh
RUN chown 1000:1000 /usr/bin/asciidoc.sh && \
chmod 0755 /usr/bin/asciidoc.shThats my Dockerfile |
|
Got it working, thanks! |
Should close #5031.
This passes the current URL prefixes to external markup parsers as environment variables.
GITEA_PREFIX_SRCis the current link prefix in thesrcpath tree,GITEA_PREFIX_RAWis the prefix for images in therawpath tree.The
rawprefix is obtained by string replacement. That's not quite elegant, but it's whatmarkdown.godoes, so I copied that.I tested the change with Pandoc as markdown parser, and I was able to get links and images working using the environment variables.
Signed-off-by: Nicolas Lenz nicolas@eisfunke.com