%define pkg_name    pandoc
%define pkg_version 2.4
%define pkg_release 1%{?_dist_release}

Summary:     general markup converter
Summary(ja): 汎用マークアップ変換ツール

Name:    %{pkg_name}
Version: %{pkg_version}
Release: %{pkg_release}

License: GPLv2+
Group:   Applications/Text
URL:     http://hackage.haskell.org

Source0: packages

Source11: pandoc-2.4.tar.gz
Source12: pandoc.cabal

BuildRoot: %{_tmppath}/%{pkg_name}-%{version}-root

BuildRequires: ghc haskell-platform
BuildRequires: libffi-devel gmp-devel zlib-devel

BuildRequires: libghc-data-default-class
BuildRequires: libghc-dlist
BuildRequires: libghc-old-locale
BuildRequires: libghc-aeson
BuildRequires: libghc-semigroups
BuildRequires: libghc-http-client-tls
BuildRequires: libghc-haddock-library
BuildRequires: libghc-build-pandoc

BuildRequires: docbook-utils docbook-utils-pdf docbook-style-xsl

Requires: libffi

Vendor: Project Vine
Distribution: Vine Linux
Packager: ara_t


%description
Pandoc is a Haskell library for converting from one markup format to another,
 and a command-line tool that uses this library.
It can read markdown and (subsets of) HTML, reStructuredText, LaTeX, DocBook,
MediaWiki markup, Haddock markup, OPML, Emacs Org-mode, and Textile,
 and it can write markdown, reStructuredText, HTML,
LaTeX (including rendering as plain PDF or beamer slide shows),
ConTeXt, DocBook, OPML, OpenDocument, ODT, Word docx, RTF, MediaWiki, Textile,
 groff man pages, GNU Texinfo, plain text, Emacs Org-Mode, AsciiDoc, InDesign
 ICML, EPUB (v2 or v3), FictionBook2, and several kinds of HTML/javascript
 slide shows  (S5, Slidy, Slideous, DZSlides, reveal.js).

Pandoc extends standard markdown syntax with footnotes, embedded LaTeX,
 definition lists, tables, and other features.
A compatibility mode is provided for those who need a drop-in replacement for
 Markdown.pl.

In contrast to existing tools for converting markdown to HTML,
 which use regex substitutions, pandoc has a modular design:
 it consists of a set of readers, which parse text in a given format
 and produce a native representation of the document,
 and a set of writers, which convert this native representation into a target
 format.
Thus, adding an input or output format requires only adding a reader or writer.

%description -l ja
Pandoc はあるマークアップ形式から別の形式に変換するHaskellライブラリで、
また、このライブラリを使ったコマンドラインツールです。
markdown、HTML (のサブセット)、reStructuredText、 LaTeX、DocBook、
MediaWikiマークアップ、Haddockマークアップ、OPML、Emacs Org-mode、
およびTextileを読み取り、
markdown、reStructuredText、HTML、LaTeX (プレインPDFまたはbeamerスライドショー
での描画を含む)、ConTeXt、DocBook、OPML、OpenDocument、ODT、Word docx、RTF、
MediaWiki、Textile、groff manページ、GNU Texinfo、プレーンテキスト、
Emacs Org-Mode、AsciiDoc、InDesign ICML、EPUB (v2 または v3)、FictionBook2、
およびいくつかの種類のHTML/javascriptスライドショー
(S5, Slidy, Slideous, DZSlides, reveal.js) に書き出せます。

Pandocは標準的なmarkdownの文法に脚注、組み込み LaTeX、定義リスト、表、
およびその他の機能を拡張しています。
Markdown.plの気軽な置き換えを希望する方向けに互換モードを提供しています。

markdownからHTMLに変換する既存のツールは正規表現で置換していますが、
これらとは異なり、pandoc はモジュール式の設計になっています:
テキストを指定された形式でパースし、文書のネイティブ表現を生成するリーダ一式、
および、このネイティブ表現を対象とする形式に変換するライタ一式で構成されて
います。したがって、入力または出力形式を追加するにはリーダやライタを追加する
ことだけが必要です。


%package libs
Summary:  Library of pandoc
Group:    Development/Libraries

Requires: haskell-platform-dep
Requires: libghc-data-default-class
Requires: libghc-dlist
Requires: libghc-old-locale
Requires: libghc-aeson
Requires: libghc-semigroups
Requires: libghc-http-client-tls
Requires: libghc-haddock-library
Requires: libghc-build-pandoc

%description libs
Librariy of pandoc for building pandoc-citeproc and pandoc-crossref


%prep
%{__rm} -rf ${RPM_BUILD_ROOT}

%build
%ghc_pkg_init

cd %{_builddir}
for pkg in `cat %{SOURCE0}`; do
    %{__tar} xzf %{_sourcedir}/${pkg}.tar.gz
    pushd ${pkg}
        %ghc_fix_dependencies ${pkg}
        %cabal_configure1 ${pkg}
        %cabal_build
        %cabal_haddock
        %cabal_copy_resister ${pkg}
    popd
done


%install
%{__mkdir_p} ${RPM_BUILD_ROOT}%{_mandir}/man1

# copy documents and mannual
pushd %{_builddir}/%{name}-%{version}
    %{__cp} \
     BUGS changelog CONTRIBUTING.md COPYING.md COPYRIGHT \
     MANUAL.txt README.md \
     ${RPM_BUILD_ROOT}%{_docdir}/%{name}-%{version}
    %{__cp} man/pandoc.1 ${RPM_BUILD_ROOT}%{_mandir}/man1/
popd


%clean
%{__rm} -rf ${RPM_BUILD_ROOT}

%post libs
%ghc_pkg_recache

%postun libs
%ghc_pkg_recache


%files
%defattr(-, root, root)
%{_bindir}/pandoc
%{_datadir}/%{name}-%{version}/
%{_docdir}/%{name}-%{version}/
%{_mandir}/man1/

%files libs
%defattr(-, root, root)
%{_libdir}/ghc-%{ghc_version}/
%{_libdir}/ghc-lib/%{name}-%{version}/


%changelog
* Mon Dec 17 2018 Toshiaki Ara <ara_t@384.jp> 2.4-1
- update to 2.4
- build using ghc-8.6.3

* Thu Aug 09 2018 Toshiaki Ara <ara_t@384.jp> 2.2.3.2-1
- update to 2.2.3.2
- build using ghc-8.4.3-2
- drop BuildRequires: yaml

* Sat Jul 21 2018 Toshiaki Ara <ara_t@384.jp> 2.2.2-1
- update to 2.2.2
- build using ghc-8.4.3

* Fri May 18 2018 Toshiaki Ara <ara_t@384.jp> 2.2.1-1
- update to 2.2.1
- rebuild using ghc-8.4.2
- rewrite using macro

* Tue Jan 09 2018 Toshiaki Ara <ara_t@384.jp> 2.0.6-1
- update to 2.0.6
- build using ghc-8.2.2

* Tue Feb 21 2017 Toshiaki Ara <ara_t@384.jp> 1.19.2.1-2
- update to 1.19.2.1
- build using ghc-8.0.2

* Fri Feb 03 2017 Toshiaki Ara <ara_t@384.jp> 1.17.1-2
- rebuild using ghc-8.0.1

* Sat Jun 18 2016 Toshiaki Ara <ara_t@384.jp> 1.17.1-1
- update to 1.17.1

* Fri May 06 2016 Toshiaki Ara <ara_t@384.jp> 1.17.0.3-5
- update to 1.17.0.3
- add BuildRequires: libghc-build-pandoc
- provide pandoc-libs for building pandoc-citeproc and pacdoc-crossref
- delete subpackages: pandoc-citeproc and pacdoc-crossref

* Tue Apr 12 2016 Toshiaki Ara <ara_t@384.jp> 1.16.0.2-5
- correct SPEC file

* Mon Mar 07 2016 Toshiaki Ara <ara_t@384.jp> 1.16.0.2-4
- correct pandoc-citeproc error

* Tue Mar 01 2016 Toshiaki Ara <ara_t@384.jp> 1.16.0.2-2
- rebuild under dependent rpm packages

* Sun Feb 21 2016 Toshiaki Ara <ara_t@384.jp> 1.16.0.2-2
- rebuild under ghc-7.10.3 and haskell-platform-2015.7.10.3

* Sun Feb 07 2016 Toshiaki Ara <ara_t@384.jp> 1.16.0.2-1
- new package
