pandoc-action-example

授权协议 Readme
开发语言
所属分类 企业应用、 LaTeX排版系统
软件类型 开源软件
地区 不详
投 递 者 晁英彦
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Using pandoc with GitHub Actions

Simple UsageLong UsageAdvanced Usage

You can use pandoc, the universal markup converter, on GitHub Actions to convert documents.

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).For example, you can use GitHub Actions to convert some file.md to file.pdf (via LaTeX) and upload the results to a web host.

Using docker://pandoc Images Directly

You can now directly reference container actions on GitHub Actions.You do not need a separate GitHub Action.

If you need LaTeX (because you want to convert through to PDF), you should use the docker://pandoc/latex image.Otherwise, the smaller docker://pandoc/core will suffice.

It is a good idea to be explicit about the pandoc version you require, such as docker://pandoc/core:2.9.This way, any future breaking changes in pandoc will not affect your workflow.You can find out whatever the latest released docker image is on docker hub.You should avoid specifying no tag or the latest tag -- these will float to the latest image and will expose your workflow to potentially breaking changes.

Simple Usage

You can use pandoc inside GitHub actions exactly as you would use it on the command line.The string passed to args gets appended to the pandoc command.

The below example is equivalent to running pandoc --help.

You can see it in action here.

name: Simple Usage

on: push

jobs:
  convert_via_pandoc:
    runs-on: ubuntu-18.04
    steps:
      - uses: docker://pandoc/core:2.9
        with:
          args: "--help" # gets appended to pandoc command

Long Pandoc Calls

Remember that as per the GitHub Actions workflow syntax, "an array of strings is not supported by the jobs.<job_id>.steps.with.args parameter.Pandoc commands can sometimes get quite long and unwieldy, but you must pass them as a single string.If you want to break up the string over several lines, you can use YAML's block chomping indicator:

name: Long Usage

on: push

jobs:
  convert_via_pandoc:
    runs-on: ubuntu-18.04
    steps:
      - run: echo "foo" > input.txt  # create an example file
      - uses: docker://pandoc/core:2.9
        with:
          args: >-  # allows you to break string into multiple lines
            --standalone
            --output=index.html
            input.txt

You can see it in action here.

Advanced Usage

You can also:

  • create an output directory to compile into; makes it easier to deploy outputs.
  • upload the output directory to GitHub's artifact storage; you can quickly download the results from your GitHub Actions tab in your repo.

Remember that wildcard substitution (say, pandoc *.md) or other shell features frequently used with pandoc do not work inside GitHub Actions yaml files args: fields.Only GitHub Actions context and expression syntax can be used here.If you want to make use of such shell features, you have to run that in a separate step in a run field and store the result in the GitHub actions context.The below workflow includes an example of how to do this to concatenate several input files.

You can see it in action (haha!) here.

name: Advanced Usage

on: push

jobs:
  convert_via_pandoc:
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@v2

      - name: create file list
        id: files_list
        run: |
          echo "Lorem ipsum" > lorem_1.md  # create two example files
          echo "dolor sit amet" > lorem_2.md
          mkdir output  # create output dir
          # this will also include README.md
          echo "::set-output name=files::$(printf '"%s" ' *.md)"

      - uses: docker://pandoc/latex:2.9
        with:
          args: --output=output/result.pdf ${{ steps.files_list.outputs.files }}
          
      - uses: actions/upload-artifact@master
        with:
          name: output
          path: output
 相关资料
  • Pandoc 可将多种文档格式,包括:markdown, reStructuredText, textile, HTML, DocBook, or LaTeX 转成: HTML formats: XHTML, HTML5, and HTML slide shows using Slidy, Slideous, S5, or DZSlides. Word processor formats: Mic

  • 来源:Markdown+Pandoc,打通写作界的任督二脉! Markdown+Pandoc,可以把自己的写作内容,变成世界上已有的任何格式的文件,包括很炫的slide,html5。没有人(或者我没看到)总结过这些内容,导致我走了很多弯路才最终打通任督二脉,特此纪念。 了解Markdwon以后,我的写作世界,只有它;看到Pandoc格式转换以后,对生成的slide和pdf羡慕的不行。那时,自己期望

  • pandoc-plot A Pandoc filter to generate figures from code blocks in documents pandoc-plot turns code blocks present in your documents (Markdown, LaTeX, etc.) into embedded figures, using your plotting

  • Pandoc Starter This repository contains a number of files for getting started with Pandoc. Eachexample comes with: A README.md, describing the type of document and usage A Makefile, for building the d

  • Pandoc Markdown template This repository is a small collection of personal Markdown templates for Pandoc. Each directory contains a working template and example PDF output. Requirements Be sure to hav

  • Eisvogel A clean pandoc LaTeX template to convert your markdown files to PDF or LaTeX. It is designed for lecture notes and exercises with a focus on computer science. The template is compatible with