#
# spec file for package python-Markdown
#
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


Name:           python-Markdown
Version:        2.6.5
Release:        36.1
Summary:        Python implementation of Markdown
License:        BSD-3-Clause
Group:          Development/Languages/Python
Url:            http://packages.python.org/Markdown/
Source:         http://pypi.python.org/packages/source/M/Markdown/Markdown-%{version}.tar.gz
BuildRequires:  python-PyYAML
BuildRequires:  python-devel
BuildRequires:  python-nose
BuildRequires:  python-xml
Requires:       python-xml
Requires(post):	update-alternatives
Requires(postun):	update-alternatives
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Provides:       python-markdown = %{version}
Obsoletes:      python-markdown < %{version}
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
%{!?python_sitelib: %global python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
%else
BuildArch:      noarch
%endif

%description
This is a Python implementation of John Gruber's [Markdown][]. 
It is almost completely compliant with the reference implementation,
though there are a few known issues. See [Features][] for information 
on what exactly is supported and what is not. Additional features are 
supported by the [Available Extensions][].

%prep
%setup -q -n Markdown-%{version}
# Fix encoding
find . -type f -not -name py.png -print0 | xargs -0 sed -i "s|\r$||"

%build
python setup.py build

%install
python setup.py install --prefix=%{_prefix} --root=%{buildroot}

# update-alternatives
mv %{buildroot}%{_bindir}/markdown_py %{buildroot}%{_bindir}/markdown_py-%{py_ver}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
touch %{buildroot}%{_sysconfdir}/alternatives/markdown_py
ln -sf %{_sysconfdir}/alternatives/markdown_py %{buildroot}%{_bindir}/markdown_py

%if 0%{?suse_version} && 0%{?suse_version} > 1110
%check
python run-tests.py
%endif

%post
update-alternatives \
	--install %{_bindir}/markdown_py markdown_py %{_bindir}/markdown_py-%{py_ver} 20

%postun
if [ $1 -eq 0 ] ; then
	update-alternatives --remove markdown_py %{_bindir}/markdown_py-%{py_ver}
fi

%files
%defattr(-,root,root,-)
%doc LICENSE.md README.md docs/*
%ghost %{_sysconfdir}/alternatives/markdown_py
%{_bindir}/markdown_py
%{_bindir}/markdown_py-%{py_ver}
%{python_sitelib}/Markdown-%{version}-py%{py_ver}.egg-info
%{python_sitelib}/markdown

%changelog
* Wed Nov 25 2015 benoit.monin@gmx.fr
- update to version 2.6.5: bugfix release
* Sat Nov  7 2015 benoit.monin@gmx.fr
- update to version 2.6.4: bugfix release
* Tue Oct 27 2015 benoit.monin@gmx.fr
- update to version 2.6.3: bugfix release
* Tue Apr 21 2015 benoit.monin@gmx.fr
- update to version 2.6.2: bugfix release
* Tue Mar 10 2015 benoit.monin@gmx.fr
- update to version 2.6.1: bugfix release
  The (new) yaml option has been removed from the Meta-Data
  Extension as it was buggy
* Fri Feb 20 2015 benoit.monin@gmx.fr
- update to version 2.6:
  * `safe_mode` Deprecated
  * Positional Arguments Deprecated
  * "Shortened" Extension Names Deprecated
  * Extension Configuration as Part of Extension Name Deprecated
  * HeaderId Extension Pending Deprecation
  * The `configs` Keyword is Deprecated
  * Official Support for PyPy
  * YAML Style Meta-Data
  * Table of Contents Extension Refactored
  * Pygments can now be disabled
  * Miscellaneous
* Mon Nov 24 2014 benoit.monin@gmx.fr
- update to version 2.5.2: bugfix release
* Fri Oct  3 2014 benoit.monin@gmx.fr
- update to version 2.5.1: bugfix release
* Tue Sep 16 2014 benoit.monin@gmx.fr
- update to version 2.5:
  * The force_linenos config key on the CodeHilite extension has
    been deprecated.
  * Both safe_mode and the associated html_replacement_text
    keywords will be deprecated in version 2.6.
  * Positional arguments on the markdown.Markdown() function are
    pending deprecation.
  * The builtin extensions did not require the full path to be
    provided. This behavior will be deprecated in version 2.6.
  * The previously documented method of appending the extension
    configs as a string to the extension name will be deprecated in
    version 2.6.
  * The Smarty extension has had a number of additional
    configuration settings added.
  * Named extensions can now point to any module and/or Class on
    your PYTHONPATH.
  * The extension configuration code has been refactored.
  * The command line interface now accepts a --extensions_config
    (or -c).
  * The amonition extension is no longer considered experimental.
  * Various bug fixes have been made.
- add python-PyYAML to BuildRequires: needed for tests
* Wed Jul  9 2014 i@marguerite.su
- fix conflicts with python3-Markdown
  * both use update-alternatives
* Mon May 26 2014 hpj@urpla.net
- disable tests for 11.1 and SLES 10 builds
* Mon Feb 17 2014 benoit.monin@gmx.fr
- update to version 2.4:
  * the "force_linenos" config setting of the CodeHilite extension
    has been marked as Deprecated.
  * URLs are no longer percent-encoded.
  * the Smarty Extension has been added, which implements
    SmartyPants.
  * the Table of Contents Extension now supports new permalink
    option for creating Sphinx-style anchor links.
  * it is now possible to enable Markdown formatting inside HTML
    blocks by appending `markdown=1` to opening tag attributes.
  * The code blocks now support emphasizing some of the code lines.
  * Various bug fixes have been made.
- fix CRLF in all files: upstream converted to DOS encoding
* Wed Jan 15 2014 benoit.monin@gmx.fr
- update to version 2.3.1:
  no changelog
- additional changes from version 2.3.0:
  * Support has been dropped for Python 2.5.
  * All classes are now "new-style" classes.
  * "safe_mode" has been further restricted.
  * The ids assigned to footnotes now contain a dash (`-`) rather
    than a colon (`:`) when `output_format` it set to "html5" or
    "xhtml5".
  * The "force_linenos" config setting of the CodeHilite extension
    has been marked as Pending Deprecation and a new setting
    "linenums" has been added to replace it.
  * The "RSS" extension has been removed.
  * The "HTML Tidy" Extension has been removed.
  * The entire code base now universally runs in Python 2 and
    Python 3 without any need for running the 2to3 conversion tool.
  * The Admonition Extension has been added.
  * Various bug fixes have been made.
- drop sed call to remove shebangs: fixed upstream
* Thu Nov 22 2012 saschpe@suse.de
- Update to version 2.2.1:
  + Python-Markdown 2.2.1 is a bug-fix release. No new features have been added.
    However, at least one bug fix does not work in Python 2.4 so that version of
    Python is no longer supported. For a full list of changes, see the git log.
* Mon Jul 23 2012 saschpe@suse.de
- Initial version