# Template file for 'pandoc'
pkgname=pandoc
# Keep in sync with http://www.stackage.org/lts
version=3.1.11.1
revision=1
_sidenote_version=0.23.0.0
_crossref_version=0.3.17.0
create_wrksrc=yes
build_style=haskell-stack
stackage="lts-22.13"
make_build_args="
 --flag pandoc:embed_data_files
 --flag=lua:pkg-config"
hostmakedepends="pkg-config unzip wget"
makedepends="zlib-devel lua54-devel tar"
short_desc="Universal converter between markup formats"
maintainer="Orphaned <orphan@voidlinux.org>"
license="GPL-2.0-or-later, BSD-3-Clause"
homepage="http://johnmacfarlane.net/pandoc/"
distfiles="https://hackage.haskell.org/package/pandoc-${version}/pandoc-${version}.tar.gz
 https://hackage.haskell.org/package/pandoc-cli-${version}/pandoc-cli-${version}.tar.gz
 https://hackage.haskell.org/package/pandoc-sidenote-${_sidenote_version}/pandoc-sidenote-${_sidenote_version}.tar.gz
 https://hackage.haskell.org/package/pandoc-crossref-${_crossref_version}/pandoc-crossref-${_crossref_version}.tar.gz"
checksum="ef968d654000e5b21943573039fee92b132b547790fb1471f363abeb09dbcf79
 b7c8200012e22059410c70c1dab522eed151ca276c0a0d50c825c06df8d0c249
 2722ca9cf7bed62658f669a3ec2026de0e0e80941b499a25e660adcf977eec2d
 8eb1fab686654cbbb7d2aa651d08b194a9634c3645df1d8d081a7e463db76f9a"
nocross=yes
nopie_files="
 /usr/bin/pandoc
 /usr/bin/pandoc-sidenote
 /usr/bin/pandoc-crossref"

post_install() {
	vman pandoc-cli-${version}/man/pandoc.1
	vlicense pandoc-${version}/COPYRIGHT LICENSE
}

# pandoc filters should be built with pandoc to ensure compatibility and speed up compiliation
pandoc-sidenote_package() {
	depends="pandoc-${version}_${revision}"
	short_desc="Pandoc filter to convert Markdown-style footnotes into sidenotes"
	short_desc+=" - version ${_sidenote_version}"
	license="MIT"
	pkg_install() {
		vmove usr/bin/pandoc-sidenote
		vlicense pandoc-sidenote-${_sidenote_version}/LICENSE
	}
}

pandoc-crossref_package() {
	depends="pandoc-${version}_${revision}"
	short_desc="Pandoc filter for cross-references"
	short_desc+=" - version ${_crossref_version}"
	license="GPL-2.0-or-later"
	pkg_install() {
		vmove usr/bin/pandoc-crossref
		$DESTDIR/usr/bin/pandoc -s -t man pandoc-crossref-${_crossref_version}/docs/index.md -o pandoc-crossref-${_crossref_version}/docs/pandoc-crossref.1
		vman pandoc-crossref-${_crossref_version}/docs/pandoc-crossref.1
	}
}
