Skip to content

Commit

Permalink
Merge branch 'pandoc:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
reijoh authored May 7, 2024
2 parents 16cc6ca + c51648d commit 3ac79af
Show file tree
Hide file tree
Showing 20 changed files with 1,189 additions and 128 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
stacks: ${{ steps.config.outputs.stacks }}
build: ${{ steps.config.outputs.build }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ github.event.after }}
- name: Configure build
Expand Down Expand Up @@ -100,7 +100,7 @@ jobs:
STACK: ${{ matrix.stack }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Show config
run: make show-args
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ endef
# Generate convenience targets for all supported stacks.
$(foreach img,$(image_stacks),$(eval $(call stack,$(img))))

export TEXLIVE_MIRROR_URL

# Freeze ################################################################
.PHONY: freeze-file
freeze-file: $(STACK)/$(stack_freeze_file)
Expand All @@ -112,7 +114,7 @@ freeze-file: $(STACK)/$(stack_freeze_file)
$(docker_cpu_options)
docker run --rm \
-v "$(makefile_dir):/app" \
--env WITHOUT_CROSSREF=$(WITHOUT_CROSSREF) \
--env WITHOUT_CROSSREF=$(WITHOUT_CROSSREF) \
pandoc/$(STACK)-builder-base:latest-$(STACK) \
sh /app/common/pandoc-freeze.sh \
-c $(PANDOC_COMMIT) \
Expand Down
71 changes: 28 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,49 +107,6 @@ Basic Usage
the next time. You don't have to worry about where/how Docker keeps these
images.

Pandoc Scripts
--------------------------------------------------------------------------------

Pandoc commands have a way of getting pretty long, and so typing them into the
command line can get a little unwieldy. To get a better handle of long pandoc
commands, you can store them in a script file, a simple text file with an `*.sh`
extension such as

```sh
#!/bin/sh
pandoc README.md
```

The first line, known as the [*shebang*](https://stackoverflow.com/q/7366775)
tells the container that the following commands are to be executed as shell
commands. In our case, we really don't use a lot of shell magic, we just call
pandoc in the second line (though you can get fancier, if you like). Notice that
the `#!/bin/sh` will *not* get you a full bash shell, but only the more basic
ash shell that comes with Alpine linux on which the pandoc containers are based.
This won't matter for most uses, but if you want to write writing more
complicated scripts you may want to refer to the [`ash`
manual](https://linux.die.net/man/1/ash).

Once you have stored this script, you must make it executable by running the
following command on it (this may apply only to UNIX-type systems):

```sh
chmod +x script.sh
```

You only have to do this once for each script file.

You can then run the completed script file in a pandoc docker container like so:

```sh
docker run --rm --volume "`pwd`:/data" --entrypoint "/data/script.sh" pandoc/latex:2.6
```

Notice that the above `script.sh` *did* specify `pandoc`, and you can't just
omit it as in the simpler command above. This is because the `--entrypoint` flag
*overrides* the `ENTRYPOINT` field in the docker file (`pandoc`, in our case),
so you must include the command.

GitHub Actions
--------------------------------------------------------------------------------

Expand Down Expand Up @@ -195,6 +152,34 @@ Started guide](https://docs.docker.com/get-started/part2/).

[spellcheck](https://github.com/pandoc/lua-filters/tree/master/spellcheck)

### Internationalized LaTeX images

This very method can be used to create images with support for
additional fonts. This is of particular importance for the processing of
documents written in a language that uses non-Latin characters.

Below is an example Dockerfile that can be used to build a custom image with
support for Ukrainian. It adds the necessary LaTeX packages via `tlmgr` and
installs *Linux Libertine* as a font with support for Cyrillic.

``` Dockerfile
FROM pandoc/latex
RUN tlmgr install babel-ukrainian
RUN apk --no-cache add font-linux-libertine
```

After building a new image as described in the previous section, the
image can then be used to convert documents such as:

``` markdown
---
title: "Приклад українською"
mainfont: Linux Libertine
lang: uk
---

Цей текст не дуже цікавий.
```

License
================================================================================
Expand Down
24 changes: 15 additions & 9 deletions alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ FROM alpine-core as alpine-latex

# NOTE: to maintainers, please keep this listing alphabetical.
RUN apk --no-cache add \
curl \
fontconfig \
freetype \
gnupg \
Expand Down Expand Up @@ -135,9 +136,15 @@ COPY common/latex/packages.txt /root/packages.txt
# TeXLive version to install (leave empty to use the latest version).
ARG texlive_version=

# TeXLive mirror URL (leave empty to use the default mirror).
ARG texlive_mirror_url=

# Request musl precompiled binary access
RUN echo "binary_x86_64-linuxmusl 1" >> /root/texlive.profile \
&& /root/install-texlive.sh $texlive_version \
&& ( \
[ -z "$texlive_version" ] || printf '-t\n%s\n"' "$texlive_version"; \
[ -z "$texlive_mirror_url" ] || printf '-m\n%s\n' "$texlive_mirror_url" \
) | xargs /root/install-texlive.sh \
&& sed -e 's/ *#.*$//' -e '/^ *$/d' /root/packages.txt | \
xargs tlmgr install \
&& rm -f /root/texlive.profile \
Expand All @@ -151,20 +158,19 @@ WORKDIR /data
# extra ##############################################################
FROM alpine-latex as alpine-extra

COPY common/latex/texlive.profile /root/texlive.profile
COPY common/extra/packages.txt /root/extra_packages.txt
COPY common/extra/requirements.txt /root/extra_requirements.txt

RUN apk --no-cache add py-pip
# The option `--break-system-packages` sounds bad but this is not
# really a problem here because we are not using Python apk packages
# anyway.
RUN apk --no-cache add py-pip \
&& pip3 install -r /root/extra_requirements.txt --break-system-packages \
&& rm -f /root/extra_requirements.txt

RUN sed -e 's/ *#.*$//' -e '/^ *$/d' /root/extra_packages.txt | \
xargs tlmgr install \
&& rm -f /root/texlive.profile \
/root/extra_packages.txt

RUN pip3 --no-cache-dir install -r /root/extra_requirements.txt \
&& rm -f /root/extra_requirements.txt

&& rm -f /root/extra_packages.txt
ARG TEMPLATES_DIR=/.pandoc/templates

RUN mkdir -p ${TEMPLATES_DIR} && \
Expand Down
Loading

0 comments on commit 3ac79af

Please sign in to comment.