From 57578263c6a3d6c9f4dd8fdb04cf22db3edff16d Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Thu, 2 Jul 2020 20:40:48 +0300 Subject: [PATCH 01/25] [CI] Update all to GHC 8.10; Use actions/setup-haaskell --- .github/workflows/haskell.yml | 34 +++++++++++++++------------------- osx/Brewfile | 3 --- 2 files changed, 15 insertions(+), 22 deletions(-) delete mode 100644 osx/Brewfile diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index b9ddcea7..546941dc 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -6,7 +6,7 @@ jobs: linux: runs-on: ubuntu-latest container: - image: lierdakil/pandoc-crossref-build:71e65f8f7c0da1ccb4aee041d25c898df0d04d08 + image: lierdakil/pandoc-crossref-build:0e0b898911d87ee9630aa5a55d030a319902c6e2 strategy: matrix: pandocver: ["2.10"] @@ -54,24 +54,19 @@ jobs: strategy: matrix: pandocver: ["2.10"] - ghcver: ["8.8"] + ghcver: ["8.10.1"] outputs: version: ${{ steps.get_version.outputs.version }} steps: - uses: actions/checkout@v2 - - name: Setup GHC - run: | - brew bundle --file=osx/Brewfile - echo "::add-path::/usr/local/opt/ghc@${{matrix.ghcver}}/bin" - # - uses: actions/cache@v1 - # id: cache - # with: - # path: .cabal-store - # key: ${{ runner.os }}-${{matrix.pandocver}}-${{ hashFiles('pandoc-crossref.cabal') }} - - name: Cabal init/update + - uses: actions/setup-haskell@v1.1.1 + with: + ghc-version: ${{matrix.ghcver}} + cabal-version: '3.2' + - name: Check GHC version + shell: bash run: | - cabal user-config init --force --augment="store-dir: $PWD/.cabal-store" - cabal v2-update + [ "$(ghc --numeric-version)" == "${{matrix.ghcver}}" ] - name: Install dependencies # if: steps.cache.outputs.cache-hit != 'true' run: | @@ -85,6 +80,8 @@ jobs: - name: Copy binary shell: bash run: find dist-newstyle -type f -perm +100 -name pandoc-crossref -exec cp {} ./ \; + - name: Install UPX + run: brew install upx - name: Package artifact shell: bash run: | @@ -113,11 +110,10 @@ jobs: outputs: version: ${{ steps.get_version.outputs.version }} steps: - - name: Get GHC version - run: | - $BinGhcPath = Join-Path $env:ChocolateyInstall "lib\ghc.${{matrix.ghcver}}\tools\ghc-${{matrix.ghcver}}\bin\" - echo "$BinGhcPath" - echo "::add-path::$BinGhcPath" + - uses: actions/setup-haskell@v1.1.1 + with: + ghc-version: ${{matrix.ghcver}} + cabal-version: '3.2' - name: Check GHC version shell: bash run: | diff --git a/osx/Brewfile b/osx/Brewfile deleted file mode 100644 index 3b7183ab..00000000 --- a/osx/Brewfile +++ /dev/null @@ -1,3 +0,0 @@ -brew 'cabal-install' -brew 'ghc@8.8' -brew 'upx' From cb772a01642f1fefb3fbb2b007a5c7a8a79cde35 Mon Sep 17 00:00:00 2001 From: Gleb Popov <6yearold@gmail.com> Date: Tue, 7 Jul 2020 10:21:58 +0400 Subject: [PATCH 02/25] Update README.md: Add FreeBSD install source (#271) * Update README.md Mention FreeBSD in third party install sources list * Fix typo --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c456864b..92cdcb00 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,7 @@ time of writing, pandoc-crossref is provided on the following platforms - NixOS or Nix package manager (via `nixpkgs.haskellPackages` attribute) - MacOS (via [Homebrew](https://brew.sh)) +- FreeBSD official binary package [textproc/hs-pandoc-crossref](https://www.freshports.org/textproc/hs-pandoc-crossref/) - Any Linux distribution (via [Linuxbrew](https://docs.brew.sh/Linuxbrew)) - Gentoo Linux (via gentoo-haskell overlay) From 76200741d1a4a6e9bc8cd7720fb460f75a149237 Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Sat, 11 Jul 2020 12:17:34 +0300 Subject: [PATCH 03/25] Bump version --- package.yaml | 2 +- pandoc-crossref.cabal | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.yaml b/package.yaml index 6030c79f..3c0b4d04 100644 --- a/package.yaml +++ b/package.yaml @@ -1,5 +1,5 @@ name: pandoc-crossref -version: '0.3.6.4' +version: '0.3.7.0' synopsis: Pandoc filter for cross-references description: pandoc-crossref is a pandoc filter for numbering figures, equations, tables and cross-references to them. diff --git a/pandoc-crossref.cabal b/pandoc-crossref.cabal index 8a9f9382..311f7b09 100644 --- a/pandoc-crossref.cabal +++ b/pandoc-crossref.cabal @@ -1,13 +1,13 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.33.0. +-- This file has been generated from package.yaml by hpack version 0.34.2. -- -- see: https://github.com/sol/hpack -- --- hash: 5947c8a1c32868f622361a6885adaaf8518701d317ced81d5489e2434d5e1cef +-- hash: 232423e0b6a509d19ce5c9a2f9de39e0e1a56b2021f29f1ddec8cd41f4a15db8 name: pandoc-crossref -version: 0.3.6.4 +version: 0.3.7.0 synopsis: Pandoc filter for cross-references description: pandoc-crossref is a pandoc filter for numbering figures, equations, tables and cross-references to them. category: Text From b51a31af9fb526a18d5eb4aae6869d686b8e888e Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Sat, 11 Jul 2020 12:27:50 +0300 Subject: [PATCH 04/25] Update CHANGELOG --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5a050db..c7f663d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.3.7.0 + +- Support for pandoc-2.10 + ## 0.3.6.4 - Last version to support pandoc 2.9 From 9ca9f7f022ffdb160e0b6911acf6b48ac7eef4c3 Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Sat, 11 Jul 2020 14:13:28 +0300 Subject: [PATCH 05/25] Try fixing Win build (disable cache, enable threading) --- .github/workflows/haskell.yml | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index 546941dc..33eba9df 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -121,26 +121,18 @@ jobs: - uses: actions/checkout@v2 - uses: actions/cache@v1 id: cache + if: false with: path: .cabal-store key: ${{ runner.os }}-${{matrix.ghcver}}-${{matrix.pandocver}}-${{ hashFiles('pandoc-crossref.cabal') }} - name: Cabal init/update run: | $store = Join-Path $pwd ".cabal-store" - cabal user-config init --force --augment="store-dir: $store" --augment="jobs: 1" + cabal user-config init --force --augment="store-dir: $store" cabal v2-update - name: Install dependencies if: steps.cache.outputs.cache-hit != 'true' - run: | - [int]$retrycount = 10 - do { - try { - cabal v2-build --only-dependencies --enable-tests --constraint pandoc==${{matrix.pandocver}} - break - } catch { - $retrycount = $retrycount - 1 - } - } while($retrycount -gt 0) + run: cabal v2-build --only-dependencies --enable-tests --constraint pandoc==${{matrix.pandocver}} - name: Build run: cabal v2-build --constraint pandoc==${{matrix.pandocver}} - name: Run tests From ea95228f26d71e9c527530fe8a5ec52eb54fecbd Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Sat, 11 Jul 2020 15:15:44 +0300 Subject: [PATCH 06/25] [CI] downgrade Windows ghc version --- .github/workflows/haskell.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index 33eba9df..6a5381dc 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -106,7 +106,7 @@ jobs: strategy: matrix: pandocver: ["2.10"] - ghcver: ["8.10.1"] + ghcver: ["8.8.3"] outputs: version: ${{ steps.get_version.outputs.version }} steps: @@ -121,7 +121,6 @@ jobs: - uses: actions/checkout@v2 - uses: actions/cache@v1 id: cache - if: false with: path: .cabal-store key: ${{ runner.os }}-${{matrix.ghcver}}-${{matrix.pandocver}}-${{ hashFiles('pandoc-crossref.cabal') }} @@ -131,7 +130,6 @@ jobs: cabal user-config init --force --augment="store-dir: $store" cabal v2-update - name: Install dependencies - if: steps.cache.outputs.cache-hit != 'true' run: cabal v2-build --only-dependencies --enable-tests --constraint pandoc==${{matrix.pandocver}} - name: Build run: cabal v2-build --constraint pandoc==${{matrix.pandocver}} From 5b2fea4af4687291cb02a10ad70d318bddb0265f Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Sat, 11 Jul 2020 16:03:04 +0300 Subject: [PATCH 07/25] Revert "Try fixing Win build (disable cache, enable threading)" This reverts commit 9ca9f7f022ffdb160e0b6911acf6b48ac7eef4c3. --- .github/workflows/haskell.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index 6a5381dc..88448d1e 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -127,10 +127,19 @@ jobs: - name: Cabal init/update run: | $store = Join-Path $pwd ".cabal-store" - cabal user-config init --force --augment="store-dir: $store" + cabal user-config init --force --augment="store-dir: $store" --augment="jobs: 1" cabal v2-update - name: Install dependencies - run: cabal v2-build --only-dependencies --enable-tests --constraint pandoc==${{matrix.pandocver}} + run: | + [int]$retrycount = 10 + do { + try { + cabal v2-build --only-dependencies --enable-tests --constraint pandoc==${{matrix.pandocver}} + break + } catch { + $retrycount = $retrycount - 1 + } + } while($retrycount -gt 0) - name: Build run: cabal v2-build --constraint pandoc==${{matrix.pandocver}} - name: Run tests From c0d00a40b6edcd8de4247b4e15db2f84dc96836d Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Thu, 30 Jul 2020 09:49:46 +0300 Subject: [PATCH 08/25] [CI] Bump pandoc version --- .github/workflows/haskell.yml | 12 ++++++------ stack.yaml | 7 +++++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index 88448d1e..33a738c4 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -6,10 +6,10 @@ jobs: linux: runs-on: ubuntu-latest container: - image: lierdakil/pandoc-crossref-build:0e0b898911d87ee9630aa5a55d030a319902c6e2 + image: lierdakil/pandoc-crossref-build:004a98f6499f04efbfca5f91a9c594cde6952e36 strategy: matrix: - pandocver: ["2.10"] + pandocver: ["2.10.1"] outputs: version: ${{ steps.get_version.outputs.version }} steps: @@ -53,7 +53,7 @@ jobs: runs-on: macos-latest strategy: matrix: - pandocver: ["2.10"] + pandocver: ["2.10.1"] ghcver: ["8.10.1"] outputs: version: ${{ steps.get_version.outputs.version }} @@ -105,7 +105,7 @@ jobs: runs-on: windows-latest strategy: matrix: - pandocver: ["2.10"] + pandocver: ["2.10.1"] ghcver: ["8.8.3"] outputs: version: ${{ steps.get_version.outputs.version }} @@ -169,7 +169,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - pandocver: ["2.10"] + pandocver: ["2.10.1"] steps: - uses: actions/download-artifact@v1 with: @@ -262,7 +262,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - pandocver: ["2.10"] + pandocver: ["2.10.1"] steps: - uses: actions/checkout@v2 - name: Install dependencies diff --git a/stack.yaml b/stack.yaml index 7433e63c..7634779c 100644 --- a/stack.yaml +++ b/stack.yaml @@ -10,8 +10,11 @@ packages: extra-deps: - roman-numerals-0.5.1.5 - data-accessor-template-0.2.1.16 -- pandoc-2.10 +- pandoc-2.10.1 - hslua-1.1.2 - jira-wiki-markup-1.3.2 - pandoc-types-1.21 -resolver: lts-16.3 +- commonmark-0.1.0.1 +- commonmark-extensions-0.2.0.1 +- commonmark-pandoc-0.2.0.0 +resolver: lts-16.7 From 7bd21747a39e921bc8173a971152b71d67b12fe4 Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Thu, 30 Jul 2020 16:03:55 +0300 Subject: [PATCH 09/25] [CI] Bump Windows compiler version --- .github/workflows/haskell.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index 33a738c4..342fd307 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -106,7 +106,7 @@ jobs: strategy: matrix: pandocver: ["2.10.1"] - ghcver: ["8.8.3"] + ghcver: ["8.8.4"] outputs: version: ${{ steps.get_version.outputs.version }} steps: From 4941f70c1fa4adb961d8ed9661aa5546d111fca5 Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Mon, 3 Aug 2020 12:30:26 +0300 Subject: [PATCH 10/25] [CI] Attempt at simplification --- .github/workflows/haskell.yml | 320 ++++++++++++-------------------- .gitignore | 1 + cabal.project | 4 +- misc/Linux-build-cabal-config | 14 ++ misc/Windows-build-cabal-config | 10 + misc/macOS-build-cabal-config | 9 + pandoc-crossref.cabal | 2 +- 7 files changed, 155 insertions(+), 205 deletions(-) create mode 100644 misc/Linux-build-cabal-config create mode 100644 misc/Windows-build-cabal-config create mode 100644 misc/macOS-build-cabal-config diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index 342fd307..79a3e3bc 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -3,242 +3,158 @@ name: Haskell CI on: [push] jobs: - linux: - runs-on: ubuntu-latest - container: - image: lierdakil/pandoc-crossref-build:004a98f6499f04efbfca5f91a9c594cde6952e36 - strategy: - matrix: - pandocver: ["2.10.1"] - outputs: - version: ${{ steps.get_version.outputs.version }} - steps: - - uses: actions/checkout@v2 - - name: Copy build config from image - run: | - cp -r /root/.cabal "$HOME" - cp /root/cabal.project.local ./ - - name: Cabal update - run: cabal v2-update - - name: Build - run: cabal v2-build --constraint pandoc==${{matrix.pandocver}} - - name: Run tests - run: cabal v2-test --constraint pandoc==${{matrix.pandocver}} - - name: Copy binary - shell: bash - run: find dist-newstyle -type f -perm +100 -name pandoc-crossref -exec cp {} ./ \; - - name: Make manpage - run: | - cabal v2-install --installdir="$HOME" pandoc --constraint pandoc==${{matrix.pandocver}} - "$HOME/pandoc" -s -t man docs/index.md -o pandoc-crossref.1 - - name: Package artifact - shell: bash - run: | - upx --best pandoc-crossref - mkdir pandoc-crossref-linux - mv pandoc-crossref pandoc-crossref.1 pandoc-crossref-linux - - name: Get Version - id: get_version - run: | - cd pandoc-crossref-linux/ - chmod +x pandoc-crossref - VERSION="$(./pandoc-crossref --version)" - echo ::set-output name=version::"$VERSION" - - uses: actions/upload-artifact@v1 - with: - name: linux-build - path: pandoc-crossref-linux - - macos: - runs-on: macos-latest + build: strategy: matrix: + os: [ubuntu-latest, macos-latest, windows-latest] pandocver: ["2.10.1"] - ghcver: ["8.10.1"] - outputs: - version: ${{ steps.get_version.outputs.version }} + include: + - os: ubuntu-latest + container: 'lierdakil/alpine-haskell:8.10.1-pwsh' + ghcver: '8.10.1' + - os: macos-latest + ghcver: '8.10.1' + - os: windows-latest + ghcver: '8.8.4' + runs-on: ${{ matrix.os }} + container: ${{ matrix.container }} steps: - uses: actions/checkout@v2 - - uses: actions/setup-haskell@v1.1.1 + - uses: actions/setup-haskell@v1 + if: '!(matrix.container)' with: ghc-version: ${{matrix.ghcver}} cabal-version: '3.2' - - name: Check GHC version - shell: bash - run: | - [ "$(ghc --numeric-version)" == "${{matrix.ghcver}}" ] - - name: Install dependencies - # if: steps.cache.outputs.cache-hit != 'true' - run: | - cabal v2-build --constraint pandoc==${{matrix.pandocver}} --only-dependencies --enable-tests - - name: Build - run: | - cabal v2-build --constraint pandoc==${{matrix.pandocver}} - - name: Run tests - run: | - cabal v2-test --constraint pandoc==${{matrix.pandocver}} - - name: Copy binary - shell: bash - run: find dist-newstyle -type f -perm +100 -name pandoc-crossref -exec cp {} ./ \; - - name: Install UPX - run: brew install upx - - name: Package artifact - shell: bash - run: | - upx --best pandoc-crossref - mkdir pandoc-crossref-macos - mv pandoc-crossref pandoc-crossref-macos - - name: Get Version - shell: bash - id: get_version + - name: Cabal init + shell: pwsh run: | - cd pandoc-crossref-macos/ - chmod +x pandoc-crossref - VERSION="$(./pandoc-crossref --version)" - echo ::set-output name=version::"$VERSION" - - uses: actions/upload-artifact@v1 - with: - name: macos-build - path: pandoc-crossref-macos - - windows: - runs-on: windows-latest - strategy: - matrix: - pandocver: ["2.10.1"] - ghcver: ["8.8.4"] - outputs: - version: ${{ steps.get_version.outputs.version }} - steps: - - uses: actions/setup-haskell@v1.1.1 - with: - ghc-version: ${{matrix.ghcver}} - cabal-version: '3.2' - - name: Check GHC version + $store = Join-Path $pwd ".cabal-store" + New-Item -ItemType Directory -Force "$store" + cabal user-config init --force --augment="store-dir: $store" ` + --augment="install-method: copy" + - name: Cabal update + run: cabal v2-update + - name: Copy build config shell: bash - run: | - [ "$(ghc --numeric-version)" == "${{matrix.ghcver}}" ] - - uses: actions/checkout@v2 - - uses: actions/cache@v1 - id: cache + run: cp misc/${{runner.os}}-build-cabal-config ./cabal.project + - name: Cabal confugure + run: cabal v2-configure --constraint pandoc==${{matrix.pandocver}} --enable-tests + - uses: actions/cache@v2 with: path: .cabal-store - key: ${{ runner.os }}-${{matrix.ghcver}}-${{matrix.pandocver}}-${{ hashFiles('pandoc-crossref.cabal') }} - - name: Cabal init/update - run: | - $store = Join-Path $pwd ".cabal-store" - cabal user-config init --force --augment="store-dir: $store" --augment="jobs: 1" - cabal v2-update + key: ${{runner.os}}-${{matrix.ghcver}}-${{matrix.pandocver}}-${{hashFiles('pandoc-crossref.cabal')}}-${{hashFiles('dist-newstyle/cache/plan.json')}}-r1 + restore-keys: | + ${{runner.os}}-${{matrix.ghcver}}-${{matrix.pandocver}}-${{hashFiles('pandoc-crossref.cabal')}}-${{hashFiles('dist-newstyle/cache/plan.json')}} + ${{runner.os}}-${{matrix.ghcver}}-${{matrix.pandocver}}-${{hashFiles('pandoc-crossref.cabal')}} + ${{runner.os}}-${{matrix.ghcver}}-${{matrix.pandocver}} + - shell: bash + run: | + rm -rvf .cabal-store/ghc-${{matrix.ghcver}}/pandoc-crossref-* + rm -rvf .cabal-store/ghc-${{matrix.ghcver}}/pandoc-crossr_-* + rm -rvf .cabal-store/ghc-${{matrix.ghcver}}/pndc-crssrf-* - name: Install dependencies - run: | - [int]$retrycount = 10 - do { - try { - cabal v2-build --only-dependencies --enable-tests --constraint pandoc==${{matrix.pandocver}} - break - } catch { - $retrycount = $retrycount - 1 - } - } while($retrycount -gt 0) + run: cabal v2-build --only-dependencies - name: Build - run: cabal v2-build --constraint pandoc==${{matrix.pandocver}} + run: cabal v2-build - name: Run tests - run: cabal v2-test --constraint pandoc==${{matrix.pandocver}} - - name: Copy binary + run: cabal v2-test + - name: Install shell: bash - run: find dist-newstyle -type f -name pandoc-crossref.exe -exec cp {} ./ \; + run: | + mkdir pandoc-crossref-${{runner.os}} + export GIT_DIR="$PWD/.git" + cabal v2-install --installdir=$PWD/pandoc-crossref-${{runner.os}} + - name: Make manpage + if: runner.os == 'Linux' + run: | + cabal v2-install --installdir="$HOME" pandoc + "$HOME/pandoc" -s -t man docs/index.md -o pandoc-crossref-${{runner.os}}/pandoc-crossref.1 - name: Get Version shell: bash id: get_version run: | - VERSION="$(./pandoc-crossref.exe --version)" - echo ::set-output name=version::"$VERSION" - - name: Package artifact - shell: bash - run: | - 7z a "pandoc-crossref.exe.xz" pandoc-crossref.exe - mkdir pandoc-crossref-windows - mv pandoc-crossref.exe.xz pandoc-crossref-windows - - uses: actions/upload-artifact@v1 + cd pandoc-crossref-${{runner.os}}/ + case "${{runner.os}}" in + Windows) + VERSION="$(./pandoc-crossref.exe --version)" + ;; + *) chmod +x pandoc-crossref + VERSION="$(./pandoc-crossref --version)" + ;; + esac + echo "$VERSION" + echo "$VERSION" > version.txt + - uses: actions/upload-artifact@v2 with: - name: windows-build - path: ./pandoc-crossref-windows + name: ${{runner.os}}-build + path: pandoc-crossref-${{runner.os}} + - shell: bash + run: | + rm -rvf .cabal-store/ghc-${{matrix.ghcver}}/pandoc-crossref-* + rm -rvf .cabal-store/ghc-${{matrix.ghcver}}/pandoc-crossr_-* + rm -rvf .cabal-store/ghc-${{matrix.ghcver}}/pndc-crssrf-* release: - needs: [linux, windows, macos] + needs: [build] runs-on: ubuntu-latest + container: alpine:3.12 strategy: matrix: pandocver: ["2.10.1"] steps: - - uses: actions/download-artifact@v1 - with: - name: linux-build - - uses: actions/download-artifact@v1 - with: - name: macos-build - - uses: actions/download-artifact@v1 - with: - name: windows-build - - name: Unpack assets - run: | - unxz windows-build/pandoc-crossref.exe.xz + - run: apk add --update --no-cache p7zip upx bash tar xz + - uses: actions/checkout@v2 + - uses: actions/download-artifact@v2 - name: Repack assets run: | mkdir assets - chmod +x linux-build/pandoc-crossref - chmod +x macos-build/pandoc-crossref - tar cJf assets/pandoc-crossref-linux-${{github.sha}}.tar.xz -C linux-build pandoc-crossref pandoc-crossref.1 - tar cJf assets/pandoc-crossref-macos-${{github.sha}}.tar.xz -C macos-build pandoc-crossref - 7z a assets/pandoc-crossref-windows-${{github.sha}}.7z windows-build/pandoc-crossref.exe - - name: Create Release - if: contains(github.ref, 'tags/v') - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + chmod +x Linux-build/pandoc-crossref + upx Linux-build/pandoc-crossref + chmod +x macOS-build/pandoc-crossref + upx macOS-build/pandoc-crossref + tar cJf assets/pandoc-crossref-Linux-${{github.sha}}.tar.xz -C Linux-build pandoc-crossref pandoc-crossref.1 + tar cJf assets/pandoc-crossref-macOS-${{github.sha}}.tar.xz -C macOS-build pandoc-crossref + cd Windows-build + upx pandoc-crossref.exe + 7z a ../assets/pandoc-crossref-Windows-${{github.sha}}.7z pandoc-crossref.exe + - uses: actions/upload-artifact@v2 with: - tag_name: ${{ github.ref }} - release_name: ${{ github.ref }} - draft: false - prerelease: false - body: | - Linux: ${{ needs.linux.outputs.version }} - macOS: ${{ needs.macos.outputs.version }} - Windows: ${{ needs.windows.outputs.version }} - - name: Upload Release Asset Linux - if: contains(github.ref, 'tags/v') - uses: actions/upload-release-asset@v1.0.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./assets/pandoc-crossref-linux-${{github.sha}}.tar.xz - asset_name: pandoc-crossref-Linux-${{matrix.pandocver}}.tar.xz - asset_content_type: application/x-xz-compressed-tar - - name: Upload Release Asset macOS - if: contains(github.ref, 'tags/v') - uses: actions/upload-release-asset@v1.0.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./assets/pandoc-crossref-macos-${{github.sha}}.tar.xz - asset_name: pandoc-crossref-macOS-${{matrix.pandocver}}.tar.xz - asset_content_type: application/x-xz-compressed-tar - - name: Upload Release Asset Windows + name: release-assets + path: assets + - name: Generate description + shell: bash + run: | + echo -n "" > description.md + for i in *-build; do + os="${i%-build}" + desc="$(cat $i/version.txt)" + echo "${os}: ${desc}" >> description.md + echo ::set-output name=${os}::${desc} + done + echo "description.md" + cat description.md + id: description + - name: Create release if: contains(github.ref, 'tags/v') - uses: actions/upload-release-asset@v1.0.1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./assets/pandoc-crossref-windows-${{github.sha}}.7z - asset_name: pandoc-crossref-Windows-${{matrix.pandocver}}.7z - asset_content_type: application/x-7z-compressed + run: | + set -x + assets=() + for asset in assets/*; do + assets+=("-a" "$asset") + done + tag_name="${GITHUB_REF##*/}" + echo -en "$tag_name\n\n" > release.md + cat description.md >> release.md + echo "release.md" + cat release.md + hub release create "${assets[@]}" -F "release.md" "$tag_name" + rm release.md + rm description.md - name: Extract branch name shell: bash - run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" + run: echo "::set-output name=branch::${GITHUB_REF#refs/heads/}" id: extract_branch - name: Upload to Bintray if: "!contains(github.ref, 'tags/v')" @@ -253,9 +169,9 @@ jobs: filesGlob: ./assets/* createPkg: true versionDescription: | - Linux: ${{ needs.linux.outputs.version }} - macOS: ${{ needs.macos.outputs.version }} - Windows: ${{ needs.windows.outputs.version }} + Linux: ${{steps.description.outputs.Linux}} + macOS: ${{steps.description.outputs.macOS}} + Windows: ${{steps.description.outputs.Windows}} licenses: 'GPL-2.0,GPL-3.0-or-later' build-stack: diff --git a/.gitignore b/.gitignore index bbedae6a..9ca87321 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ static-build .pandoc-* pandoc cabal.project.local +cabal.project.local~ dist dist-newstyle cabal.sandbox.config diff --git a/cabal.project b/cabal.project index 77f84bc7..44989487 100644 --- a/cabal.project +++ b/cabal.project @@ -1,5 +1,5 @@ packages: . package pandoc - ghc-options: +RTS -A64m -RTS + ghc-options: -j +RTS -A64m -RTS package pandoc-crossref - ghc-options: +RTS -A64m -RTS + ghc-options: -j +RTS -A64m -RTS diff --git a/misc/Linux-build-cabal-config b/misc/Linux-build-cabal-config new file mode 100644 index 00000000..b139f4d2 --- /dev/null +++ b/misc/Linux-build-cabal-config @@ -0,0 +1,14 @@ +package * + debug-info: False + ghc-options: -fPIC -fasm -optl-static -optl-pthread +RTS -A64m -RTS + static: True + relocatable: True + split-sections: True + executable-stripping: True + shared: False +packages: . +package pandoc + ghc-options: -j +RTS -A64m -RTS +package pandoc-crossref + flags: +enable_flaky_tests + ghc-options: -j +RTS -A64m -RTS diff --git a/misc/Windows-build-cabal-config b/misc/Windows-build-cabal-config new file mode 100644 index 00000000..3df97f59 --- /dev/null +++ b/misc/Windows-build-cabal-config @@ -0,0 +1,10 @@ +package * + debug-info: False + split-sections: True + executable-stripping: True +packages: . +package pandoc + ghc-options: +RTS -A64m -RTS +package pandoc-crossref + flags: +enable_flaky_tests + ghc-options: +RTS -A64m -RTS diff --git a/misc/macOS-build-cabal-config b/misc/macOS-build-cabal-config new file mode 100644 index 00000000..160a8df5 --- /dev/null +++ b/misc/macOS-build-cabal-config @@ -0,0 +1,9 @@ +package * + debug-info: False + executable-stripping: True +packages: . +package pandoc + ghc-options: -j +RTS -A64m -RTS +package pandoc-crossref + flags: +enable_flaky_tests + ghc-options: -j +RTS -A64m -RTS diff --git a/pandoc-crossref.cabal b/pandoc-crossref.cabal index 311f7b09..511dd4cf 100644 --- a/pandoc-crossref.cabal +++ b/pandoc-crossref.cabal @@ -1,6 +1,6 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.34.2. +-- This file has been generated from package.yaml by hpack version 0.33.0. -- -- see: https://github.com/sol/hpack -- From 4d307285d6c1119eb2094d779fb3ad447c103c84 Mon Sep 17 00:00:00 2001 From: "Jan-T. Brinkmann" Date: Sat, 29 Aug 2020 04:49:33 +0200 Subject: [PATCH 11/25] [README] hint at Windows installation via scoop (#276) https://scoop.sh/ --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 92cdcb00..f2654b91 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,7 @@ time of writing, pandoc-crossref is provided on the following platforms - FreeBSD official binary package [textproc/hs-pandoc-crossref](https://www.freshports.org/textproc/hs-pandoc-crossref/) - Any Linux distribution (via [Linuxbrew](https://docs.brew.sh/Linuxbrew)) - Gentoo Linux (via gentoo-haskell overlay) +- Windows (via [scoop](https://scoop.sh/)) ### Building from Hackage with `cabal-install` and Haskell platform From becce7964b926844936f39b7541e0bf1ce03ac34 Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Sat, 29 Aug 2020 05:59:31 +0300 Subject: [PATCH 12/25] [CI] Fix stack build Upstream changed download URI... --- .github/workflows/haskell.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index 79a3e3bc..dc7d399c 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -183,8 +183,8 @@ jobs: - uses: actions/checkout@v2 - name: Install dependencies run: | - wget https://get.haskellstack.org/stable/linux-x86_64-static.tar.gz - tar zxf linux-x86_64-static.tar.gz + wget https://get.haskellstack.org/stable/linux-x86_64.tar.gz + tar zxf linux-x86_64.tar.gz mv stack-*/stack ./ chmod +x ./stack - uses: actions/cache@v1 From 393430d975fd3160b04a9944cdbd402c64ccae55 Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Wed, 2 Sep 2020 11:16:37 +0300 Subject: [PATCH 13/25] [DOCX] Center equation number vertically with tableEqns --- lib/Text/Pandoc/CrossRef/References/Blocks.hs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/Text/Pandoc/CrossRef/References/Blocks.hs b/lib/Text/Pandoc/CrossRef/References/Blocks.hs index e669e0df..600da06a 100644 --- a/lib/Text/Pandoc/CrossRef/References/Blocks.hs +++ b/lib/Text/Pandoc/CrossRef/References/Blocks.hs @@ -270,7 +270,16 @@ replaceBlock opts (Para [Span attrs [Math DisplayMath eq]]) (eq', idx) <- replaceEqn opts attrs eq replaceNoRecurse $ Div attrs [ simpleTable [AlignCenter, AlignRight] [ColWidth 0.9, ColWidth 0.09] - [[[Plain [Math DisplayMath eq']], [Plain [Math DisplayMath $ "(" <> idx <> ")"]]]]] + [[[Plain [Math DisplayMath eq']], [eqnNumber idx]]]] + where + eqnNumber idx + | outFormat opts == Just (Format "docx") + = Div nullAttr [ + RawBlock (Format "openxml") "" + , mathIdx + ] + | otherwise = mathIdx + where mathIdx = Plain [Math DisplayMath $ "(" <> idx <> ")"] replaceBlock _ _ = noReplaceRecurse replaceEqn :: Options -> Attr -> T.Text -> WS (T.Text, T.Text) From 4a5105e31a1f329628d59f50dae4b7d236aa8914 Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Wed, 2 Sep 2020 11:29:13 +0300 Subject: [PATCH 14/25] [LaTeX] Move hypertarget inside equation environment Fixes #275 --- lib/Text/Pandoc/CrossRef/References/Blocks.hs | 17 +++++++++-------- test/m2m/delim/expect.tex | 8 ++++---- test/m2m/equations-auto/expect.tex | 16 ++++++++-------- test/m2m/equations-tables-auto/expect.tex | 16 ++++++++-------- test/m2m/equations-tables/expect.tex | 8 ++++---- test/m2m/equations/expect.tex | 8 ++++---- test/m2m/links-names/expect.tex | 8 ++++---- test/m2m/links/expect.tex | 8 ++++---- test/test-pandoc-crossref.hs | 2 +- 9 files changed, 46 insertions(+), 45 deletions(-) diff --git a/lib/Text/Pandoc/CrossRef/References/Blocks.hs b/lib/Text/Pandoc/CrossRef/References/Blocks.hs index 600da06a..802e8b95 100644 --- a/lib/Text/Pandoc/CrossRef/References/Blocks.hs +++ b/lib/Text/Pandoc/CrossRef/References/Blocks.hs @@ -292,22 +292,23 @@ replaceEqn opts (label, _, attrs) eq = do idxTxt = stringify idxStr return (eq', idxTxt) -replaceInline :: Options -> Inline -> WS (ReplacedResult Inline) -replaceInline opts (Span attrs@(label,_,_) [Math DisplayMath eq]) +replaceInline :: Options -> [Inline] -> WS (ReplacedResult [Inline]) +replaceInline opts (Span attrs@(label,_,_) [Math DisplayMath eq]:xs) | "eq:" `T.isPrefixOf` label || T.null label && autoEqnLabels opts - = replaceNoRecurse . Span attrs . (:[]) =<< case outFormat opts of + = replaceNoRecurse . (<>xs) =<< case outFormat opts of f | isLatexFormat f -> - pure . RawInline (Format "latex") - $ "\\begin{equation}"<>eq<>mkLaTeXLabel label<>"\\end{equation}" - _ -> Math DisplayMath . fst <$> replaceEqn opts attrs eq -replaceInline opts (Image attr@(label,_,attrs) alt img@(_, tit)) + pure [RawInline (Format "latex") "\\begin{equation}" + , Span attrs [RawInline (Format "latex") eq] + , RawInline (Format "latex") $ mkLaTeXLabel label <> "\\end{equation}"] + _ -> pure . Span attrs . (:[]) . Math DisplayMath . fst <$> replaceEqn opts attrs eq +replaceInline opts (Image attr@(label,_,attrs) alt img@(_, tit):xs) | "fig:" `T.isPrefixOf` label && "fig:" `T.isPrefixOf` tit = do idxStr <- replaceAttr opts (Right label) (lookup "label" attrs) alt imgRefs let alt' = case outFormat opts of f | isLatexFormat f -> alt _ -> applyTemplate idxStr alt $ figureTemplate opts - replaceNoRecurse $ Image attr alt' img + replaceNoRecurse $ Image attr alt' img:xs replaceInline _ _ = noReplaceRecurse replaceSubfigs :: Options -> [Inline] -> WS (ReplacedResult [Inline]) diff --git a/test/m2m/delim/expect.tex b/test/m2m/delim/expect.tex index b4d6085e..50f9eeb8 100644 --- a/test/m2m/delim/expect.tex +++ b/test/m2m/delim/expect.tex @@ -13,20 +13,20 @@ Some of those can be labelled: This is a test file with some referenced equations, line -\protect\hypertarget{eq:0}{}{\begin{equation} this \label{eq:0}\end{equation}} +\begin{equation}\protect\hypertarget{eq:0}{}{ this }\label{eq:0}\end{equation} Some equations might be inside of text, -\protect\hypertarget{eq:1}{}{\begin{equation} for example \label{eq:1}\end{equation}} +\begin{equation}\protect\hypertarget{eq:1}{}{ for example }\label{eq:1}\end{equation} this one. Some equations might be on start of paragraphs: -\protect\hypertarget{eq:2}{}{\begin{equation} start \label{eq:2}\end{equation}} +\begin{equation}\protect\hypertarget{eq:2}{}{ start }\label{eq:2}\end{equation} of paragraph. Other might be on separate paragraphs of their own: -\protect\hypertarget{eq:3}{}{\begin{equation} separate \label{eq:3}\end{equation}} +\begin{equation}\protect\hypertarget{eq:3}{}{ separate }\label{eq:3}\end{equation} Then they can be referenced: diff --git a/test/m2m/equations-auto/expect.tex b/test/m2m/equations-auto/expect.tex index 41544988..c47f7b33 100644 --- a/test/m2m/equations-auto/expect.tex +++ b/test/m2m/equations-auto/expect.tex @@ -1,34 +1,34 @@ This is a test file with some referenced equations, line -{\begin{equation} this \end{equation}} +\begin{equation}{ this }\end{equation} Some equations might be inside of text, -{\begin{equation} for example \end{equation}} this one. +\begin{equation}{ for example }\end{equation} this one. Some equations might be on start of paragraphs: -{\begin{equation} start \end{equation}} of paragraph. +\begin{equation}{ start }\end{equation} of paragraph. Other might be on separate paragraphs of their own: -{\begin{equation} separate \end{equation}} +\begin{equation}{ separate }\end{equation} Some of those can be labelled: This is a test file with some referenced equations, line -\protect\hypertarget{eq:0}{}{\begin{equation} this \label{eq:0}\end{equation}} +\begin{equation}\protect\hypertarget{eq:0}{}{ this }\label{eq:0}\end{equation} Some equations might be inside of text, -\protect\hypertarget{eq:1}{}{\begin{equation} for example \label{eq:1}\end{equation}} +\begin{equation}\protect\hypertarget{eq:1}{}{ for example }\label{eq:1}\end{equation} this one. Some equations might be on start of paragraphs: -\protect\hypertarget{eq:2}{}{\begin{equation} start \label{eq:2}\end{equation}} +\begin{equation}\protect\hypertarget{eq:2}{}{ start }\label{eq:2}\end{equation} of paragraph. Other might be on separate paragraphs of their own: -\protect\hypertarget{eq:3}{}{\begin{equation} separate \label{eq:3}\end{equation}} +\begin{equation}\protect\hypertarget{eq:3}{}{ separate }\label{eq:3}\end{equation} Then they can be referenced: diff --git a/test/m2m/equations-tables-auto/expect.tex b/test/m2m/equations-tables-auto/expect.tex index 41544988..c47f7b33 100644 --- a/test/m2m/equations-tables-auto/expect.tex +++ b/test/m2m/equations-tables-auto/expect.tex @@ -1,34 +1,34 @@ This is a test file with some referenced equations, line -{\begin{equation} this \end{equation}} +\begin{equation}{ this }\end{equation} Some equations might be inside of text, -{\begin{equation} for example \end{equation}} this one. +\begin{equation}{ for example }\end{equation} this one. Some equations might be on start of paragraphs: -{\begin{equation} start \end{equation}} of paragraph. +\begin{equation}{ start }\end{equation} of paragraph. Other might be on separate paragraphs of their own: -{\begin{equation} separate \end{equation}} +\begin{equation}{ separate }\end{equation} Some of those can be labelled: This is a test file with some referenced equations, line -\protect\hypertarget{eq:0}{}{\begin{equation} this \label{eq:0}\end{equation}} +\begin{equation}\protect\hypertarget{eq:0}{}{ this }\label{eq:0}\end{equation} Some equations might be inside of text, -\protect\hypertarget{eq:1}{}{\begin{equation} for example \label{eq:1}\end{equation}} +\begin{equation}\protect\hypertarget{eq:1}{}{ for example }\label{eq:1}\end{equation} this one. Some equations might be on start of paragraphs: -\protect\hypertarget{eq:2}{}{\begin{equation} start \label{eq:2}\end{equation}} +\begin{equation}\protect\hypertarget{eq:2}{}{ start }\label{eq:2}\end{equation} of paragraph. Other might be on separate paragraphs of their own: -\protect\hypertarget{eq:3}{}{\begin{equation} separate \label{eq:3}\end{equation}} +\begin{equation}\protect\hypertarget{eq:3}{}{ separate }\label{eq:3}\end{equation} Then they can be referenced: diff --git a/test/m2m/equations-tables/expect.tex b/test/m2m/equations-tables/expect.tex index 0f4c3167..bd8cc471 100644 --- a/test/m2m/equations-tables/expect.tex +++ b/test/m2m/equations-tables/expect.tex @@ -13,20 +13,20 @@ Some of those can be labelled: This is a test file with some referenced equations, line -\protect\hypertarget{eq:0}{}{\begin{equation} this \label{eq:0}\end{equation}} +\begin{equation}\protect\hypertarget{eq:0}{}{ this }\label{eq:0}\end{equation} Some equations might be inside of text, -\protect\hypertarget{eq:1}{}{\begin{equation} for example \label{eq:1}\end{equation}} +\begin{equation}\protect\hypertarget{eq:1}{}{ for example }\label{eq:1}\end{equation} this one. Some equations might be on start of paragraphs: -\protect\hypertarget{eq:2}{}{\begin{equation} start \label{eq:2}\end{equation}} +\begin{equation}\protect\hypertarget{eq:2}{}{ start }\label{eq:2}\end{equation} of paragraph. Other might be on separate paragraphs of their own: -\protect\hypertarget{eq:3}{}{\begin{equation} separate \label{eq:3}\end{equation}} +\begin{equation}\protect\hypertarget{eq:3}{}{ separate }\label{eq:3}\end{equation} Then they can be referenced: diff --git a/test/m2m/equations/expect.tex b/test/m2m/equations/expect.tex index b4d6085e..50f9eeb8 100644 --- a/test/m2m/equations/expect.tex +++ b/test/m2m/equations/expect.tex @@ -13,20 +13,20 @@ Some of those can be labelled: This is a test file with some referenced equations, line -\protect\hypertarget{eq:0}{}{\begin{equation} this \label{eq:0}\end{equation}} +\begin{equation}\protect\hypertarget{eq:0}{}{ this }\label{eq:0}\end{equation} Some equations might be inside of text, -\protect\hypertarget{eq:1}{}{\begin{equation} for example \label{eq:1}\end{equation}} +\begin{equation}\protect\hypertarget{eq:1}{}{ for example }\label{eq:1}\end{equation} this one. Some equations might be on start of paragraphs: -\protect\hypertarget{eq:2}{}{\begin{equation} start \label{eq:2}\end{equation}} +\begin{equation}\protect\hypertarget{eq:2}{}{ start }\label{eq:2}\end{equation} of paragraph. Other might be on separate paragraphs of their own: -\protect\hypertarget{eq:3}{}{\begin{equation} separate \label{eq:3}\end{equation}} +\begin{equation}\protect\hypertarget{eq:3}{}{ separate }\label{eq:3}\end{equation} Then they can be referenced: diff --git a/test/m2m/links-names/expect.tex b/test/m2m/links-names/expect.tex index b4d6085e..50f9eeb8 100644 --- a/test/m2m/links-names/expect.tex +++ b/test/m2m/links-names/expect.tex @@ -13,20 +13,20 @@ Some of those can be labelled: This is a test file with some referenced equations, line -\protect\hypertarget{eq:0}{}{\begin{equation} this \label{eq:0}\end{equation}} +\begin{equation}\protect\hypertarget{eq:0}{}{ this }\label{eq:0}\end{equation} Some equations might be inside of text, -\protect\hypertarget{eq:1}{}{\begin{equation} for example \label{eq:1}\end{equation}} +\begin{equation}\protect\hypertarget{eq:1}{}{ for example }\label{eq:1}\end{equation} this one. Some equations might be on start of paragraphs: -\protect\hypertarget{eq:2}{}{\begin{equation} start \label{eq:2}\end{equation}} +\begin{equation}\protect\hypertarget{eq:2}{}{ start }\label{eq:2}\end{equation} of paragraph. Other might be on separate paragraphs of their own: -\protect\hypertarget{eq:3}{}{\begin{equation} separate \label{eq:3}\end{equation}} +\begin{equation}\protect\hypertarget{eq:3}{}{ separate }\label{eq:3}\end{equation} Then they can be referenced: diff --git a/test/m2m/links/expect.tex b/test/m2m/links/expect.tex index b4d6085e..50f9eeb8 100644 --- a/test/m2m/links/expect.tex +++ b/test/m2m/links/expect.tex @@ -13,20 +13,20 @@ Some of those can be labelled: This is a test file with some referenced equations, line -\protect\hypertarget{eq:0}{}{\begin{equation} this \label{eq:0}\end{equation}} +\begin{equation}\protect\hypertarget{eq:0}{}{ this }\label{eq:0}\end{equation} Some equations might be inside of text, -\protect\hypertarget{eq:1}{}{\begin{equation} for example \label{eq:1}\end{equation}} +\begin{equation}\protect\hypertarget{eq:1}{}{ for example }\label{eq:1}\end{equation} this one. Some equations might be on start of paragraphs: -\protect\hypertarget{eq:2}{}{\begin{equation} start \label{eq:2}\end{equation}} +\begin{equation}\protect\hypertarget{eq:2}{}{ start }\label{eq:2}\end{equation} of paragraph. Other might be on separate paragraphs of their own: -\protect\hypertarget{eq:3}{}{\begin{equation} separate \label{eq:3}\end{equation}} +\begin{equation}\protect\hypertarget{eq:3}{}{ separate }\label{eq:3}\end{equation} Then they can be referenced: diff --git a/test/test-pandoc-crossref.hs b/test/test-pandoc-crossref.hs index 0f71d658..5077edb6 100644 --- a/test/test-pandoc-crossref.hs +++ b/test/test-pandoc-crossref.hs @@ -307,7 +307,7 @@ main = hspec $ do it "Eqn labels" $ equation "x^2" "some_equation1" <> para (citeGen "eq:some_equation" [1]) - `test` "\\protect\\hypertarget{eq:some_equation1}{}{\\begin{equation}x^2\\label{eq:some_equation1}\\end{equation}}\n\neq.~\\ref{eq:some_equation1}" + `test` "\\begin{equation}\\protect\\hypertarget{eq:some_equation1}{}{x^2}\\label{eq:some_equation1}\\end{equation}\n\neq.~\\ref{eq:some_equation1}" #ifdef FLAKY it "Tbl labels" $ From 8b2b0b542b2d0fcc3b591aa944c680e385144d30 Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Wed, 2 Sep 2020 11:36:23 +0300 Subject: [PATCH 15/25] [CI] Invalidate cache --- .github/workflows/haskell.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index dc7d399c..1d5b6edd 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -42,11 +42,11 @@ jobs: - uses: actions/cache@v2 with: path: .cabal-store - key: ${{runner.os}}-${{matrix.ghcver}}-${{matrix.pandocver}}-${{hashFiles('pandoc-crossref.cabal')}}-${{hashFiles('dist-newstyle/cache/plan.json')}}-r1 + key: r2-${{runner.os}}-${{matrix.ghcver}}-${{matrix.pandocver}}-${{hashFiles('pandoc-crossref.cabal')}}-${{hashFiles('dist-newstyle/cache/plan.json')}} restore-keys: | - ${{runner.os}}-${{matrix.ghcver}}-${{matrix.pandocver}}-${{hashFiles('pandoc-crossref.cabal')}}-${{hashFiles('dist-newstyle/cache/plan.json')}} - ${{runner.os}}-${{matrix.ghcver}}-${{matrix.pandocver}}-${{hashFiles('pandoc-crossref.cabal')}} - ${{runner.os}}-${{matrix.ghcver}}-${{matrix.pandocver}} + r2-${{runner.os}}-${{matrix.ghcver}}-${{matrix.pandocver}}-${{hashFiles('pandoc-crossref.cabal')}}-${{hashFiles('dist-newstyle/cache/plan.json')}} + r2-${{runner.os}}-${{matrix.ghcver}}-${{matrix.pandocver}}-${{hashFiles('pandoc-crossref.cabal')}} + r2-${{runner.os}}-${{matrix.ghcver}}-${{matrix.pandocver}} - shell: bash run: | rm -rvf .cabal-store/ghc-${{matrix.ghcver}}/pandoc-crossref-* From 9bce7b679a40df11f302bef39c8c9980837197fd Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Wed, 2 Sep 2020 11:39:23 +0300 Subject: [PATCH 16/25] Update CHANGELOG --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7f663d8..eaeb2f9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## 0.3.8.0 + +- [LaTeX] Move hypertarget inside equation environment + + Fixes spacing issues in LaTeX/pdf output + +- [DOCX] Center equation number vertically with tableEqns + ## 0.3.7.0 - Support for pandoc-2.10 From 62a712b19c2ed17bdb0e8b504ee6d39438cbd196 Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Wed, 2 Sep 2020 11:40:59 +0300 Subject: [PATCH 17/25] Bump version --- package.yaml | 2 +- pandoc-crossref.cabal | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.yaml b/package.yaml index 3c0b4d04..39aafbfb 100644 --- a/package.yaml +++ b/package.yaml @@ -1,5 +1,5 @@ name: pandoc-crossref -version: '0.3.7.0' +version: '0.3.8.0' synopsis: Pandoc filter for cross-references description: pandoc-crossref is a pandoc filter for numbering figures, equations, tables and cross-references to them. diff --git a/pandoc-crossref.cabal b/pandoc-crossref.cabal index 511dd4cf..b8c92465 100644 --- a/pandoc-crossref.cabal +++ b/pandoc-crossref.cabal @@ -4,10 +4,10 @@ cabal-version: 1.12 -- -- see: https://github.com/sol/hpack -- --- hash: 232423e0b6a509d19ce5c9a2f9de39e0e1a56b2021f29f1ddec8cd41f4a15db8 +-- hash: 16b94461d13008e2ca6ada6c83e8f56a855b54be95bc2d50ee6c0a4367bd1232 name: pandoc-crossref -version: 0.3.7.0 +version: 0.3.8.0 synopsis: Pandoc filter for cross-references description: pandoc-crossref is a pandoc filter for numbering figures, equations, tables and cross-references to them. category: Text From 7ffa96000147ae8b597465112e49ba0d536fd618 Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Wed, 2 Sep 2020 12:47:13 +0300 Subject: [PATCH 18/25] [CI] Bump to GHC 8.10.2 --- .github/workflows/haskell.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index 1d5b6edd..8b603351 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -10,12 +10,12 @@ jobs: pandocver: ["2.10.1"] include: - os: ubuntu-latest - container: 'lierdakil/alpine-haskell:8.10.1-pwsh' - ghcver: '8.10.1' + container: 'lierdakil/alpine-haskell:8.10.2-pwsh' + ghcver: '8.10.2' - os: macos-latest - ghcver: '8.10.1' + ghcver: '8.10.2' - os: windows-latest - ghcver: '8.8.4' + ghcver: '8.10.2' runs-on: ${{ matrix.os }} container: ${{ matrix.container }} steps: From be17d073933f9663b50b29799eaefd7c1962ab3e Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Wed, 2 Sep 2020 14:47:46 +0300 Subject: [PATCH 19/25] [CI] Windows fix r1 --- .github/workflows/haskell.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index 8b603351..07bc90c6 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -25,6 +25,15 @@ jobs: with: ghc-version: ${{matrix.ghcver}} cabal-version: '3.2' + - if: runner.os == 'Windows' + name: patch ghc8.10.2 configuration error + # see https://www.stackage.org/blog/2020/08/ghc-8-10-2-windows-workaround + shell: bash + run: | + which ghc + ghcdir="$(dirname "$(dirname "$(which ghc)")" | sed -r 's!^/(\w)/!\1:/!')" + echo "$ghcdir" + sed -i 's!C:/GitLabRunner/builds/2WeHDSFP/0/ghc/ghc/inplace/!'"$ghcdir"'/!' "$ghcdir/lib/settings" - name: Cabal init shell: pwsh run: | From 04c2e931c1a19e0b8a88ce54e7159e4199bc0eda Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Wed, 2 Sep 2020 16:42:54 +0300 Subject: [PATCH 20/25] [CI] Fix release script --- .github/workflows/haskell.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index 07bc90c6..fa19641b 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -111,7 +111,9 @@ jobs: matrix: pandocver: ["2.10.1"] steps: - - run: apk add --update --no-cache p7zip upx bash tar xz + - run: | + echo 'http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories + apk add --update --no-cache p7zip hub upx bash tar xz - uses: actions/checkout@v2 - uses: actions/download-artifact@v2 - name: Repack assets @@ -144,6 +146,7 @@ jobs: cat description.md id: description - name: Create release + shell: bash if: contains(github.ref, 'tags/v') env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From d3c6e5c062844f7a15d4cca43834a1df37cab9a5 Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Wed, 2 Sep 2020 20:13:44 +0300 Subject: [PATCH 21/25] [CI] Use softprops/action-gh-release --- .github/workflows/haskell.yml | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index fa19641b..3b5fa803 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -142,34 +142,35 @@ jobs: echo "${os}: ${desc}" >> description.md echo ::set-output name=${os}::${desc} done + ver="${GITHUB_REF##*/v}" + echo "### Changelog" >> description.md + sed -rn '/^## *'"${ver}"'/,/^##/ p' CHANGELOG.md | head -n-1 | tail -n+2 >> description.md echo "description.md" cat description.md id: description - - name: Create release + - name: Rename assets for release + if: startsWith(github.ref, 'refs/tags/v') shell: bash - if: contains(github.ref, 'tags/v') - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - set -x - assets=() - for asset in assets/*; do - assets+=("-a" "$asset") + for i in assets/*; do + mv "$i" "${i/-${{github.sha}}/}" done - tag_name="${GITHUB_REF##*/}" - echo -en "$tag_name\n\n" > release.md - cat description.md >> release.md - echo "release.md" - cat release.md - hub release create "${assets[@]}" -F "release.md" "$tag_name" - rm release.md - rm description.md + - name: Create release + if: startsWith(github.ref, 'refs/tags/v') + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: softprops/action-gh-release@v1 + with: + body_path: description.md + files: | + assets/* + fail_on_unmatched_files: true - name: Extract branch name shell: bash run: echo "::set-output name=branch::${GITHUB_REF#refs/heads/}" id: extract_branch - name: Upload to Bintray - if: "!contains(github.ref, 'tags/v')" + if: "!startsWith(github.ref, 'refs/tags/v')" uses: lierdakil/action-bintray-upload@master with: username: lierdakil From b8519c9af98f0418119a2d15d4a55ebe58b24df9 Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Thu, 3 Sep 2020 20:23:41 +0300 Subject: [PATCH 22/25] Fix parsing multiple inlines in block --- lib/Text/Pandoc/CrossRef/References/Blocks.hs | 18 ++++++++++++------ pandoc-crossref.cabal | 5 ++++- test/m2m/multiple-eqn-same-para/expect.md | 3 +++ test/m2m/multiple-eqn-same-para/expect.tex | 5 +++++ test/m2m/multiple-eqn-same-para/input.md | 5 +++++ 5 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 test/m2m/multiple-eqn-same-para/expect.md create mode 100644 test/m2m/multiple-eqn-same-para/expect.tex create mode 100644 test/m2m/multiple-eqn-same-para/input.md diff --git a/lib/Text/Pandoc/CrossRef/References/Blocks.hs b/lib/Text/Pandoc/CrossRef/References/Blocks.hs index 802e8b95..6d017484 100644 --- a/lib/Text/Pandoc/CrossRef/References/Blocks.hs +++ b/lib/Text/Pandoc/CrossRef/References/Blocks.hs @@ -46,7 +46,10 @@ import Data.Default replaceAll :: (Data a) => Options -> a -> WS a replaceAll opts = - runReplace (mkRR (replaceBlock opts) `extRR` replaceInline opts) + runReplace (mkRR (replaceBlock opts) + `extRR` replaceInline opts + `extRR` replaceInlineMany opts + ) . runSplitMath . everywhere (mkT divBlocks `extT` spanInlines opts) where @@ -292,23 +295,26 @@ replaceEqn opts (label, _, attrs) eq = do idxTxt = stringify idxStr return (eq', idxTxt) -replaceInline :: Options -> [Inline] -> WS (ReplacedResult [Inline]) -replaceInline opts (Span attrs@(label,_,_) [Math DisplayMath eq]:xs) +replaceInlineMany :: Options -> [Inline] -> WS (ReplacedResult [Inline]) +replaceInlineMany opts (Span attrs@(label,_,_) [Math DisplayMath eq]:xs) | "eq:" `T.isPrefixOf` label || T.null label && autoEqnLabels opts - = replaceNoRecurse . (<>xs) =<< case outFormat opts of + = replaceRecurse . (<>xs) =<< case outFormat opts of f | isLatexFormat f -> pure [RawInline (Format "latex") "\\begin{equation}" , Span attrs [RawInline (Format "latex") eq] , RawInline (Format "latex") $ mkLaTeXLabel label <> "\\end{equation}"] _ -> pure . Span attrs . (:[]) . Math DisplayMath . fst <$> replaceEqn opts attrs eq -replaceInline opts (Image attr@(label,_,attrs) alt img@(_, tit):xs) +replaceInlineMany _ _ = noReplaceRecurse + +replaceInline :: Options -> Inline -> WS (ReplacedResult Inline) +replaceInline opts (Image attr@(label,_,attrs) alt img@(_, tit)) | "fig:" `T.isPrefixOf` label && "fig:" `T.isPrefixOf` tit = do idxStr <- replaceAttr opts (Right label) (lookup "label" attrs) alt imgRefs let alt' = case outFormat opts of f | isLatexFormat f -> alt _ -> applyTemplate idxStr alt $ figureTemplate opts - replaceNoRecurse $ Image attr alt' img:xs + replaceNoRecurse $ Image attr alt' img replaceInline _ _ = noReplaceRecurse replaceSubfigs :: Options -> [Inline] -> WS (ReplacedResult [Inline]) diff --git a/pandoc-crossref.cabal b/pandoc-crossref.cabal index b8c92465..d4f4969b 100644 --- a/pandoc-crossref.cabal +++ b/pandoc-crossref.cabal @@ -4,7 +4,7 @@ cabal-version: 1.12 -- -- see: https://github.com/sol/hpack -- --- hash: 16b94461d13008e2ca6ada6c83e8f56a855b54be95bc2d50ee6c0a4367bd1232 +-- hash: 59e47ed4453e60fba6e6b4586f3bfd980106f6cc7d80a94903de45f3d7c9e18b name: pandoc-crossref version: 0.3.8.0 @@ -49,6 +49,9 @@ data-files: test/m2m/listing-captions-ids/expect.md test/m2m/listing-captions-ids/expect.tex test/m2m/listing-captions-ids/input.md + test/m2m/multiple-eqn-same-para/expect.md + test/m2m/multiple-eqn-same-para/expect.tex + test/m2m/multiple-eqn-same-para/input.md test/m2m/section-template/expect.md test/m2m/section-template/expect.tex test/m2m/section-template/input.md diff --git a/test/m2m/multiple-eqn-same-para/expect.md b/test/m2m/multiple-eqn-same-para/expect.md new file mode 100644 index 00000000..34bda6c3 --- /dev/null +++ b/test/m2m/multiple-eqn-same-para/expect.md @@ -0,0 +1,3 @@ +Simple test [$$x=y\qquad(1)$$]{#eq:1} [$$x=y\qquad(2)$$]{#eq:2} + +eqns. 1, 2 diff --git a/test/m2m/multiple-eqn-same-para/expect.tex b/test/m2m/multiple-eqn-same-para/expect.tex new file mode 100644 index 00000000..7d91119d --- /dev/null +++ b/test/m2m/multiple-eqn-same-para/expect.tex @@ -0,0 +1,5 @@ +Simple test +\begin{equation}\protect\hypertarget{eq:1}{}{x=y}\label{eq:1}\end{equation} +\begin{equation}\protect\hypertarget{eq:2}{}{x=y}\label{eq:2}\end{equation} + +eqns.~\ref{eq:1}, \ref{eq:2} diff --git a/test/m2m/multiple-eqn-same-para/input.md b/test/m2m/multiple-eqn-same-para/input.md new file mode 100644 index 00000000..49992a5f --- /dev/null +++ b/test/m2m/multiple-eqn-same-para/input.md @@ -0,0 +1,5 @@ +Simple test +$$x=y$${#eq:1} +$$x=y$${#eq:2} + +[@eq:1; @eq:2] From 05c0f4e16b8ed9341ecac3125f4bb21d7585de3e Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Thu, 3 Sep 2020 20:23:48 +0300 Subject: [PATCH 23/25] Update CHANGELOG --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eaeb2f9a..42ccb5a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.3.8.1 + +- Fix parsing multiple inlines in block + ## 0.3.8.0 - [LaTeX] Move hypertarget inside equation environment From 6a5197b8a597a16dbf72e1e2b78a9ed2313f3a2c Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Thu, 3 Sep 2020 20:25:44 +0300 Subject: [PATCH 24/25] Bump version --- package.yaml | 2 +- pandoc-crossref.cabal | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.yaml b/package.yaml index 39aafbfb..d29d4448 100644 --- a/package.yaml +++ b/package.yaml @@ -1,5 +1,5 @@ name: pandoc-crossref -version: '0.3.8.0' +version: '0.3.8.1' synopsis: Pandoc filter for cross-references description: pandoc-crossref is a pandoc filter for numbering figures, equations, tables and cross-references to them. diff --git a/pandoc-crossref.cabal b/pandoc-crossref.cabal index d4f4969b..32c4fa98 100644 --- a/pandoc-crossref.cabal +++ b/pandoc-crossref.cabal @@ -4,10 +4,10 @@ cabal-version: 1.12 -- -- see: https://github.com/sol/hpack -- --- hash: 59e47ed4453e60fba6e6b4586f3bfd980106f6cc7d80a94903de45f3d7c9e18b +-- hash: 60aff0647917782b159c09b84eb53496da9ed0f414fe0eb7d77857567ba27dfb name: pandoc-crossref -version: 0.3.8.0 +version: 0.3.8.1 synopsis: Pandoc filter for cross-references description: pandoc-crossref is a pandoc filter for numbering figures, equations, tables and cross-references to them. category: Text From 2fc3f43f5e76f9e453dd205aba934a207c48e0e9 Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Thu, 3 Sep 2020 20:46:45 +0300 Subject: [PATCH 25/25] [CI] Add some guards --- .github/workflows/haskell.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index 3b5fa803..43629d9e 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -133,6 +133,7 @@ jobs: name: release-assets path: assets - name: Generate description + if: startsWith(github.ref, 'refs/tags/v') shell: bash run: | echo -n "" > description.md @@ -166,6 +167,7 @@ jobs: assets/* fail_on_unmatched_files: true - name: Extract branch name + if: "!startsWith(github.ref, 'refs/tags/v')" shell: bash run: echo "::set-output name=branch::${GITHUB_REF#refs/heads/}" id: extract_branch