Skip to content

Commit

Permalink
Add Asciidoctor Web PDF
Browse files Browse the repository at this point in the history
  • Loading branch information
diguage committed Mar 6, 2022
1 parent a609624 commit 947c711
Show file tree
Hide file tree
Showing 5 changed files with 159 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ ARG asciidoctor_revealjs_version=4.1.0
ARG kramdown_asciidoc_version=2.0.0
ARG asciidoctor_bibtex_version=0.8.0
ARG asciidoctor_kroki_version=0.5.0
ARG asciidoctor_web_pdf_version=1.0.0-alpha.14
ARG asciidoctor_kroki_npm_version=0.15.4

ENV ASCIIDOCTOR_VERSION=${asciidoctor_version} \
ASCIIDOCTOR_CONFLUENCE_VERSION=${asciidoctor_confluence_version} \
Expand All @@ -23,7 +25,9 @@ ENV ASCIIDOCTOR_VERSION=${asciidoctor_version} \
ASCIIDOCTOR_REVEALJS_VERSION=${asciidoctor_revealjs_version} \
KRAMDOWN_ASCIIDOC_VERSION=${kramdown_asciidoc_version} \
ASCIIDOCTOR_BIBTEX_VERSION=${asciidoctor_bibtex_version} \
ASCIIDOCTOR_KROKI_VERSION=${asciidoctor_kroki_version}
ASCIIDOCTOR_KROKI_VERSION=${asciidoctor_kroki_version} \
ASCIIDOCTOR_WEB_PDF_VERSION=${asciidoctor_web_pdf_version} \
ASCIIDOCTOR_KROKI_NPM_VERSION=${asciidoctor_kroki_npm_version}

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Minimal image with asciidoctor
Expand Down Expand Up @@ -100,7 +104,8 @@ RUN apk add --no-cache \
tzdata \
unzip \
which \
font-noto-cjk
font-noto-cjk \
nodejs

# Installing Ruby Gems for additional functionality
RUN apk add --no-cache --virtual .rubymakedepends \
Expand Down Expand Up @@ -142,6 +147,11 @@ RUN apk add --no-cache --virtual .pythonmakedepends \
seqdiag \
&& apk del -r --no-cache .pythonmakedepends

# Installing Nodejs dependencies for additional functionality
RUN npm install --global @asciidoctor/core \
asciidoctor-pdf@${ASCIIDOCTOR_WEB_PDF_VERSION} \
asciidoctor-kroki@${ASCIIDOCTOR_KROKI_NPM_VERSION}

COPY --from=build-haskell root/.cabal/bin/erd /bin/

WORKDIR /documents
Expand Down
22 changes: 22 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
:KRAMDOWN_ASCIIDOC_VERSION: 2.0.0
:ASCIIDOCTOR_BIBTEX_VERSION: 0.8.0
:ASCIIDOCTOR_KROKI_VERSION: 0.5.0
:ASCIIDOCTOR_WEB_PDF_VERSION: 1.0.0-alpha.14
ifdef::env-github[]
:tip-caption: :bulb:
:note-caption: :information_source:
:important-caption: :heavy_exclamation_mark:
:caution-caption: :fire:
:warning-caption: :warning:
endif::[]
= Asciidoctor Docker Container
:source-highlighter: coderay

Expand All @@ -34,6 +42,7 @@ This Docker image provides:
* https://github.com/asciidoctor/asciidoctor-confluence[Asciidoctor Confluence] {ASCIIDOCTOR_CONFLUENCE_VERSION}
* https://github.com/asciidoctor/asciidoctor-bibtex[Asciidoctor Bibtex] {ASCIIDOCTOR_BIBTEX_VERSION}
* https://github.com/Mogztter/asciidoctor-kroki[Asciidoctor Kroki] {ASCIIDOCTOR_KROKI_VERSION}
* https://github.com/Mogztter/asciidoctor-web-pdf[Asciidoctor Web PDF] {ASCIIDOCTOR_WEB_PDF_VERSION}


This image uses Alpine Linux {ALPINE_VERSION} as base image.
Expand Down Expand Up @@ -111,6 +120,19 @@ asciidoctor-revealjs -a revealjsdir=https://cdnjs.cloudflare.com/ajax/libs/revea
docker run --rm -v $(pwd):/documents/ asciidoctor/docker-asciidoctor asciidoctor-pdf index.adoc
----

* To convert files with Asciidoctor Web PDF:
+
[source, bash]
----
# 1. generate a PDF document from basic example
asciidoctor-web-pdf document.adoc
# Generate the file `document.pdf`
# 2. generate an PDF document with a diagram
asciidoctor-web-pdf --require asciidoctor-kroki document-with-diagram.adoc
# Generate the file `document-with-diagram.pdf`
----

== How to contribute / do it yourself?

=== Requirements
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ This Docker image provides:

- [Asciidoctor Kroki](https://github.com/Mogztter/asciidoctor-kroki) 0.5.0

- [Asciidoctor Web PDF](https://github.com/Mogztter/asciidoctor-web-pdf) 1.0.0-alpha.14

This image uses Alpine Linux 3.13.5 as base image.

## How to use it
Expand Down Expand Up @@ -71,6 +73,17 @@ You can find several examples below.

docker run --rm -v $(pwd):/documents/ asciidoctor/docker-asciidoctor asciidoctor-pdf index.adoc

- To convert files with Asciidoctor Web PDF:

# 1. generate a PDF document from basic example
asciidoctor-web-pdf document.adoc
# Generate the file `document.pdf`
# 2. generate an PDF document with a diagram
asciidoctor-web-pdf --require asciidoctor-kroki document-with-diagram.adoc
# Generate the file `document-with-diagram.pdf`


## How to contribute / do it yourself?

### Requirements
Expand Down
22 changes: 22 additions & 0 deletions tests/asciidoctor.bats
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ ASCIIDOCTOR_REVEALJS_VERSION=4.1.0
KRAMDOWN_ASCIIDOC_VERSION=2.0.0
ASCIIDOCTOR_BIBTEX_VERSION=0.8.0
ASCIIDOCTOR_KROKI_VERSION=0.5.0
ASCIIDOCTOR_WEB_PDF_VERSION=1.0.0-alpha.14
DOCKER_IMAGE_NAME_TO_TEST="${IMAGE_NAME:-asciidoctor}"

clean_generated_files() {
Expand Down Expand Up @@ -48,6 +49,12 @@ teardown() {
| grep "${ASCIIDOCTOR_PDF_VERSION}"
}

@test "asciidoctor-web-pdf is installed and in version ${ASCIIDOCTOR_WEB_PDF_VERSION}" {
docker run -t --rm "${DOCKER_IMAGE_NAME_TO_TEST}" asciidoctor-web-pdf -v \
| grep "Asciidoctor Web PDF" | grep "${ASCIIDOCTOR_VERSION}" \
| grep "${ASCIIDOCTOR_WEB_PDF_VERSION}"
}

@test "asciidoctor-revealjs is callable without error" {
docker run -t --rm "${DOCKER_IMAGE_NAME_TO_TEST}" asciidoctor-revealjs -v \
| grep "${ASCIIDOCTOR_REVEALJS_VERSION}"
Expand Down Expand Up @@ -120,6 +127,13 @@ teardown() {
/documents/fixtures/basic-example.adoc
}

@test "We can generate a PDF document from basic example(Asciidoctor Web PDF)" {
docker run -t --rm \
-v "${BATS_TEST_DIRNAME}":/documents/ \
"${DOCKER_IMAGE_NAME_TO_TEST}" \
asciidoctor-web-pdf -D /documents/tmp /documents/fixtures/basic-example.adoc
}

@test "We can generate an FB2 document from basic example without errors/warnings" {

docker run -t --rm \
Expand Down Expand Up @@ -285,6 +299,14 @@ teardown() {
/documents/fixtures/samples-syntax-highlight/*.adoc
}

@test "We can generate PDF documents with different syntax-colored codes(Asciidoctor Web PDF)" {
docker run -t --rm \
-v "${BATS_TEST_DIRNAME}":/documents/ \
"${DOCKER_IMAGE_NAME_TO_TEST}" \
asciidoctor-web-pdf -D /documents/tmp \
/documents/fixtures/samples-syntax-highlight/*.adoc
}

@test "We can convert a Markdown file to an AsciiDoc file" {
docker run -t --rm \
-v "${BATS_TEST_DIRNAME}":/documents/ \
Expand Down
90 changes: 90 additions & 0 deletions updatecli/updatecli.d/asciidoctor-web-pdf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
---
title: "Bump Asciidoctor-Web-PDF version"

scms:
default:
kind: github
spec:
user: "{{ .github.user }}"
email: "{{ .github.email }}"
owner: "{{ requiredEnv .github.owner }}"
repository: "{{ requiredEnv .github.repository }}"
token: "{{ requiredEnv .github.token }}"
username: "{{ .github.username }}"
branch: "{{ .github.branch }}"

sources:
latestVersion:
kind: githubRelease
name: "Get the latest Asciidoctor-Web-PDF version"
spec:
owner: "Mogztter"
repository: "asciidoctor-web-pdf"
token: "{{ requiredEnv .github.token }}"
username: "{{ .github.username }}"
versionFilter:
kind: latest
transformers:
- trimPrefix: "v"

conditions:
testDockerfileArgVersion:
name: "Does the Dockerfile have an ARG instruction which key is asciidoctor_web_pdf_version?"
kind: dockerfile
spec:
file: Dockerfile
instruction:
keyword: "ARG"
matcher: "asciidoctor_web_pdf_version"
testVersionInReadme:
name: "Does the README.adoc have a variable asciidoctor_web_pdf_version"
kind: file
spec:
file: README.adoc
matchPattern: '(?m:^:ASCIIDOCTOR_WEB_PDF_VERSION:.*)'
testVersionInTestHarness:
name: "Does the test harness have variable ASCIIDOCTOR_WEB_PDF_VERSION"
kind: file
spec:
file: tests/asciidoctor.bats
matchPattern: '(?m:^ASCIIDOCTOR_WEB_PDF_VERSION=.*)'

targets:
updateDockerfile:
name: "Update the value of ARG asciidoctor_web_pdf_version in the Dockerfile"
kind: dockerfile
spec:
file: Dockerfile
instruction:
keyword: "ARG"
matcher: "asciidoctor_web_pdf_version"
scmID: default
updateTestHarness:
name: "Update the key ASCIIDOCTOR_WEB_PDF_VERSION in the test harness"
kind: file
spec:
file: tests/asciidoctor.bats
matchPattern: '(?m:^ASCIIDOCTOR_WEB_PDF_VERSION=.*)'
content: 'ASCIIDOCTOR_WEB_PDF_VERSION={{ source `latestVersion` }}'
scmID: default
updateReadme:
name: "Update the key ASCIIDOCTOR_WEB_PDF_VERSION in the README.adoc file"
kind: file
spec:
file: README.adoc
matchPattern: '(?m:^:ASCIIDOCTOR_WEB_PDF_VERSION:.*)'
content: ':ASCIIDOCTOR_WEB_PDF_VERSION: {{ source `latestVersion` }}'
scmID: default

pullrequests:
default:
kind: github
scmID: default
targets:
- updateDockerfile
- updateTestHarness
- updateReadme
spec:
labels:
- chore
- dependencies

0 comments on commit 947c711

Please sign in to comment.