Project Icon

dockerfiles

Pandoc Docker 镜像集合 满足多样文档转换需求

该项目提供多种 Pandoc Docker 镜像变体,如 minimal、core、latex 和 extra,适用于不同文档转换场景。用户可在支持 Docker 的环境中轻松进行文档转换,无需手动安装 Pandoc 及其依赖。项目包含 GitHub Actions 使用示例,并说明如何构建自定义镜像,如添加拼写检查或国际化支持等特定功能。

pandoc Dockerfiles

This repo contains a collection of Dockerfiles to build various pandoc container images.

Available Images

Docker images hosted here have the following variants:

  • minimal: kept as small as possible. See the pandoc/minimal repository.
  • core: suitable for common conversion tasks; includes additional libraries and programs. See the pandoc/core repository.
  • latex: builds on top of the core image, and provides a basic LaTeX installation in addition. This includes all packages that pandoc might use, and any libraries needed by these packages. See the pandoc/latex repository.
  • extra: extends the latex image with a curated selection of templates, filters, fonts, etc. See the pandoc/extra repository.

All images are based on the alpine stack. The pandoc/minimal, pandoc/latex and pandoc/extra images are also available with an ubuntu stack.

Usage

Note: this section describes how to use the docker images. Please refer to the pandoc manual for usage information about pandoc.

Docker images are pre-provisioned computing environments, similar to virtual machines, but smaller and cleverer. You can use these images to convert document wherever you can run docker images, without having to worry about pandoc or its dependencies. The images bring along everything they need to get the job done.

Basic Usage

  1. Install Docker if you don't have it already.

  2. Start up Docker. Usually you will have an application called "Docker" on your computer with a rudimentary graphical user interface (GUI). You can also run this command in the command-line interface (CLI):

    open -a Docker
    
  3. Open a shell and navigate to wherever the files are that you want to convert.

    cd path/to/source/dir
    

    You can always run pwd to check whether you're in the right place.

  4. Run docker by entering the below commands in your favorite shell.

    Let's say you have a README.md in your working directory that you'd like to convert to HTML.

    docker run --rm --volume "`pwd`:/data" --user `id -u`:`id -g` pandoc/latex:2.6 README.md
    

    The --volume flag maps some directory on your machine (lefthand side of the colons) to some directory in the container (righthand side), so that you have your source files available for pandoc to convert. pwd is quoted to protect against spaces in filenames.

    Ownership of the output file is determined by the user executing pandoc in the container. This will generally be a user different from the local user. It is hence a good idea to specify for docker the user and group IDs to use via the --user flag.

    pandoc/latex:2.6 declares the image that you're going to run. It's always a good idea to hardcode the version, lest future releases break your code.

    It may look weird to you that you can just add README.md at the end of this line, but that's just because the pandoc/latex:2.6 will simply prepend pandoc in front of anything you write after pandoc/latex:2.6 (this is known as the ENTRYPOINT field of the Dockerfile). So what you're really running here is pandoc README.md, which is a valid pandoc command.

    If you don't have the current docker image on your computer yet, the downloading and unpacking is going to take a while. It'll be (much) faster the next time. You don't have to worry about where/how Docker keeps these images.

GitHub Actions

GitHub Actions is an Infrastructure as a Service (IaaS) from GitHub that allows you to automatically run code on GitHub's servers on every push (or a bunch of other GitHub events).

Such continuous integration and delivery (CI/CD) may be useful for many pandoc users. Perhaps, you're using pandoc convert some markdown source document into HTML and deploy the results to a webserver. If the source document is under version control (such as git), you might want pandoc to convert and deploy on every commit. That is what CI/CD does.

To use pandoc on GitHub Actions, you can leverage the docker images of this project.

To learn more how to use the docker pandoc images in your GitHub Actions workflow, see these examples.

Building custom images

The official images are bare-bones, providing everything required to use pandoc and Lua filters, but not much more. Often, one will want to have additional software available. This is best achieved by building custom Docker images.

For example, one may want to use advanced spellchecking as demonstrated in the [spellcheck] in the Lua filters collection. This requires the aspell package as well as language-specific packages. A good solution would be to define a new Dockerfile and to use pandoc/core as the base package:

FROM pandoc/core:latest
RUN apk --no-cache add aspell aspell-en aspell-fr

Create a new image by running docker build --tag=pandoc-with-aspell . in the directory containing the Dockerfile. Now you can use pandoc-with-aspell instead of pandoc/core to get access to spellchecking in your image.

See Docker documentation for more details, for example part 2 of the Get Started guide.

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.

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:

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

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

License

Code in this repository is licensed under the GNU General Public License, version 2.0 or later.

项目侧边栏1项目侧边栏2
推荐项目
Project Cover

豆包MarsCode

豆包 MarsCode 是一款革命性的编程助手,通过AI技术提供代码补全、单测生成、代码解释和智能问答等功能,支持100+编程语言,与主流编辑器无缝集成,显著提升开发效率和代码质量。

Project Cover

AI写歌

Suno AI是一个革命性的AI音乐创作平台,能在短短30秒内帮助用户创作出一首完整的歌曲。无论是寻找创作灵感还是需要快速制作音乐,Suno AI都是音乐爱好者和专业人士的理想选择。

Project Cover

有言AI

有言平台提供一站式AIGC视频创作解决方案,通过智能技术简化视频制作流程。无论是企业宣传还是个人分享,有言都能帮助用户快速、轻松地制作出专业级别的视频内容。

Project Cover

Kimi

Kimi AI助手提供多语言对话支持,能够阅读和理解用户上传的文件内容,解析网页信息,并结合搜索结果为用户提供详尽的答案。无论是日常咨询还是专业问题,Kimi都能以友好、专业的方式提供帮助。

Project Cover

阿里绘蛙

绘蛙是阿里巴巴集团推出的革命性AI电商营销平台。利用尖端人工智能技术,为商家提供一键生成商品图和营销文案的服务,显著提升内容创作效率和营销效果。适用于淘宝、天猫等电商平台,让商品第一时间被种草。

Project Cover

吐司

探索Tensor.Art平台的独特AI模型,免费访问各种图像生成与AI训练工具,从Stable Diffusion等基础模型开始,轻松实现创新图像生成。体验前沿的AI技术,推动个人和企业的创新发展。

Project Cover

SubCat字幕猫

SubCat字幕猫APP是一款创新的视频播放器,它将改变您观看视频的方式!SubCat结合了先进的人工智能技术,为您提供即时视频字幕翻译,无论是本地视频还是网络流媒体,让您轻松享受各种语言的内容。

Project Cover

美间AI

美间AI创意设计平台,利用前沿AI技术,为设计师和营销人员提供一站式设计解决方案。从智能海报到3D效果图,再到文案生成,美间让创意设计更简单、更高效。

Project Cover

AIWritePaper论文写作

AIWritePaper论文写作是一站式AI论文写作辅助工具,简化了选题、文献检索至论文撰写的整个过程。通过简单设定,平台可快速生成高质量论文大纲和全文,配合图表、参考文献等一应俱全,同时提供开题报告和答辩PPT等增值服务,保障数据安全,有效提升写作效率和论文质量。

投诉举报邮箱: service@vectorlightyear.com
@2024 懂AI·鲁ICP备2024100362号-6·鲁公网安备37021002001498号