-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[markup.ascii]
ENABLED = false
FILE_EXTENSIONS = .adoc,.asciidoc
RENDER_COMMAND = "asciidoc --imagesdir=$GITEA_PREFIX_RAW --out-file=- -"
IS_INPUT_FILE = false
It'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 = false The 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.sh Thats my Dockerfile |
Got it working, thanks! |
Should close #5031.
This passes the current URL prefixes to external markup parsers as environment variables.
GITEA_PREFIX_SRC
is the current link prefix in thesrc
path tree,GITEA_PREFIX_RAW
is the prefix for images in theraw
path tree.The
raw
prefix is obtained by string replacement. That's not quite elegant, but it's whatmarkdown.go
does, 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