Hello community, here is the log from the commit of package python3-Markups for openSUSE:Factory checked in at 2015-01-08 23:02:58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python3-Markups (Old) and /work/SRC/openSUSE:Factory/.python3-Markups.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python3-Markups" Changes: -------- --- /work/SRC/openSUSE:Factory/python3-Markups/python3-Markups.changes 2014-07-04 17:18:22.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.python3-Markups.new/python3-Markups.changes 2015-01-08 23:02:59.000000000 +0100 @@ -1,0 +2,22 @@ +Thu Jan 8 00:42:40 UTC 2015 - [email protected] + +- specfile: update copyright year + +- changes from Version 0.5.2: + * Fixed loading of Markdown extensions with options. + +- changes from Version 0.5.1: + * Fixed Markdown markup crash on empty files. + * Include documentation in the tarballs. + * Testsuite improvements. + +- changes from Version 0.5: + * Improvements to Markdown markup: + + All math delimeters except "$...$" are now enabled by + default + + "remove_extra" extension now disables formulas support + + It is now possible to specify required extensions in the + first line of the file + * Add Sphinx documentation + +------------------------------------------------------------------- Old: ---- Markups-0.4.tar.gz New: ---- Markups-0.5.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python3-Markups.spec ++++++ --- /var/tmp/diff_new_pack.jVyjK0/_old 2015-01-08 23:03:00.000000000 +0100 +++ /var/tmp/diff_new_pack.jVyjK0/_new 2015-01-08 23:03:00.000000000 +0100 @@ -1,7 +1,7 @@ # -# spec file for package python-Markups +# spec file for package python3-Markups # -# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -13,15 +13,16 @@ # published by the Open Source Initiative. # Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Name: python3-Markups -Version: 0.4 +Version: 0.5.2 Release: 0 -License: BSD-3-Clause Summary: A wrapper around various text markups -Url: http://launchpad.net/python-markups +License: BSD-3-Clause Group: Development/Languages/Python +Url: http://launchpad.net/python-markups Source: https://pypi.python.org/packages/source/M/Markups/Markups-%{version}.tar.gz BuildRequires: python3-devel BuildRequires: python3-nose ++++++ Markups-0.4.tar.gz -> Markups-0.5.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Markups-0.4/MANIFEST.in new/Markups-0.5.2/MANIFEST.in --- old/Markups-0.4/MANIFEST.in 1970-01-01 01:00:00.000000000 +0100 +++ new/Markups-0.5.2/MANIFEST.in 2014-09-10 13:26:49.000000000 +0200 @@ -0,0 +1,5 @@ +include LICENSE +include changelog +include examples/example-template.html +recursive-include docs *.rst conf.py +recursive-include tests *.py *.rst *.html diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Markups-0.4/Markups.egg-info/PKG-INFO new/Markups-0.5.2/Markups.egg-info/PKG-INFO --- old/Markups-0.4/Markups.egg-info/PKG-INFO 1970-01-01 01:00:00.000000000 +0100 +++ new/Markups-0.5.2/Markups.egg-info/PKG-INFO 2014-11-05 18:50:43.000000000 +0100 @@ -0,0 +1,44 @@ +Metadata-Version: 1.1 +Name: Markups +Version: 0.5.2 +Summary: A wrapper around various text markups +Home-page: https://github.com/mitya57/pymarkups +Author: Dmitry Shachnev +Author-email: [email protected] +License: BSD +Description: This module provides a wrapper around the various text markup languages, + such as Markdown_ and reStructuredText_ (these two are supported by default). + + Usage example: + + >>> markup = markups.get_markup_for_file_name("myfile.rst") + >>> markup.name + 'reStructuredText' + >>> markup.attributes[markups.SYNTAX_DOCUMENTATION] + 'http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html' + >>> text = "Hello, world!\n=============\n\nThis is an example **reStructuredText** document." + >>> markup.get_document_title(text) + 'Hello, world!' + >>> markup.get_document_body(text) + '<p>This is an example <strong>reStructuredText</strong> document.</p>\n' + + .. _Markdown: http://daringfireball.net/projects/markdown/ + .. _reStructuredText: http://docutils.sourceforge.net/rst.html + +Platform: UNKNOWN +Classifier: Development Status :: 4 - Beta +Classifier: License :: OSI Approved :: BSD License +Classifier: Operating System :: OS Independent +Classifier: Programming Language :: Python +Classifier: Programming Language :: Python :: 2 +Classifier: Programming Language :: Python :: 2.6 +Classifier: Programming Language :: Python :: 2.7 +Classifier: Programming Language :: Python :: 3 +Classifier: Programming Language :: Python :: 3.0 +Classifier: Programming Language :: Python :: 3.1 +Classifier: Programming Language :: Python :: 3.2 +Classifier: Programming Language :: Python :: 3.3 +Classifier: Programming Language :: Python :: 3.4 +Classifier: Topic :: Text Processing :: Markup +Classifier: Topic :: Text Processing :: General +Classifier: Topic :: Software Development :: Libraries :: Python Modules diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Markups-0.4/Markups.egg-info/SOURCES.txt new/Markups-0.5.2/Markups.egg-info/SOURCES.txt --- old/Markups-0.4/Markups.egg-info/SOURCES.txt 1970-01-01 01:00:00.000000000 +0100 +++ new/Markups-0.5.2/Markups.egg-info/SOURCES.txt 2014-11-05 18:50:44.000000000 +0100 @@ -0,0 +1,33 @@ +LICENSE +MANIFEST.in +README +changelog +setup.py +Markups.egg-info/PKG-INFO +Markups.egg-info/SOURCES.txt +Markups.egg-info/dependency_links.txt +Markups.egg-info/top_level.txt +docs/changelog.rst +docs/conf.py +docs/custom_markups.rst +docs/index.rst +docs/interface.rst +docs/overview.rst +docs/standard_markups.rst +examples/example-template.html +markups/__init__.py +markups/abstract.py +markups/common.py +markups/markdown.py +markups/restructuredtext.py +markups/textile.py +markups/web.py +tests/__init__.py +tests/test_markdown.py +tests/test_public_api.py +tests/test_restructuredtext.py +tests/test_textile.py +tests/test_web.py +tests/data/page.html +tests/data/page.rst +tests/data/template.html \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Markups-0.4/Markups.egg-info/dependency_links.txt new/Markups-0.5.2/Markups.egg-info/dependency_links.txt --- old/Markups-0.4/Markups.egg-info/dependency_links.txt 1970-01-01 01:00:00.000000000 +0100 +++ new/Markups-0.5.2/Markups.egg-info/dependency_links.txt 2014-11-05 18:50:43.000000000 +0100 @@ -0,0 +1 @@ + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Markups-0.4/Markups.egg-info/top_level.txt new/Markups-0.5.2/Markups.egg-info/top_level.txt --- old/Markups-0.4/Markups.egg-info/top_level.txt 1970-01-01 01:00:00.000000000 +0100 +++ new/Markups-0.5.2/Markups.egg-info/top_level.txt 2014-11-05 18:50:43.000000000 +0100 @@ -0,0 +1 @@ +markups diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Markups-0.4/PKG-INFO new/Markups-0.5.2/PKG-INFO --- old/Markups-0.4/PKG-INFO 2013-11-30 10:26:00.000000000 +0100 +++ new/Markups-0.5.2/PKG-INFO 2014-11-05 18:50:44.000000000 +0100 @@ -1,8 +1,8 @@ Metadata-Version: 1.1 Name: Markups -Version: 0.4 +Version: 0.5.2 Summary: A wrapper around various text markups -Home-page: http://launchpad.net/python-markups +Home-page: https://github.com/mitya57/pymarkups Author: Dmitry Shachnev Author-email: [email protected] License: BSD @@ -38,6 +38,7 @@ Classifier: Programming Language :: Python :: 3.1 Classifier: Programming Language :: Python :: 3.2 Classifier: Programming Language :: Python :: 3.3 +Classifier: Programming Language :: Python :: 3.4 Classifier: Topic :: Text Processing :: Markup Classifier: Topic :: Text Processing :: General Classifier: Topic :: Software Development :: Libraries :: Python Modules diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Markups-0.4/changelog new/Markups-0.5.2/changelog --- old/Markups-0.4/changelog 2013-11-30 10:22:15.000000000 +0100 +++ new/Markups-0.5.2/changelog 2014-11-05 18:47:59.000000000 +0100 @@ -1,3 +1,28 @@ +Version 0.5.2, 2014-11-05 +========================= + +* Fixed loading of Markdown extensions with options. + +Version 0.5.1, 2014-09-16 +========================= + +* Fixed Markdown markup crash on empty files. +* Include documentation in the tarballs. +* Testsuite improvements. + +Version 0.5, 2014-07-25 +======================= + +* Improvements to Markdown markup: + + + All math delimeters except ``$...$`` are now enabled by + default + + ``remove_extra`` extension now disables formulas support + + It is now possible to specify required extensions in the + first line of the file + +* Add Sphinx documentation + Version 0.4, 2013-11-30 ======================= diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Markups-0.4/docs/changelog.rst new/Markups-0.5.2/docs/changelog.rst --- old/Markups-0.4/docs/changelog.rst 1970-01-01 01:00:00.000000000 +0100 +++ new/Markups-0.5.2/docs/changelog.rst 2014-09-10 13:26:49.000000000 +0200 @@ -0,0 +1,11 @@ +======================== +Python-Markups changelog +======================== + +This changelog only lists the most important changes that +happened in Python-Markups. Please see the `Git log`_ for +the full list of changes. + +.. _`Git log`: https://github.com/mitya57/pymarkups/commits/master + +.. include:: ../changelog diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Markups-0.4/docs/conf.py new/Markups-0.5.2/docs/conf.py --- old/Markups-0.4/docs/conf.py 1970-01-01 01:00:00.000000000 +0100 +++ new/Markups-0.5.2/docs/conf.py 2014-09-10 13:26:49.000000000 +0200 @@ -0,0 +1,262 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# Python-Markups documentation build configuration file, created by +# sphinx-quickstart on Mon Jul 21 14:51:00 2014. +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +sys.path.insert(0, os.path.abspath('..')) + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.autodoc', +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'Python-Markups' +copyright = u'2014, Dmitry Shachnev' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +from markups import __version_tuple__ + +# The short X.Y version. +version = '%d.%d' % __version_tuple__[:2] +# The full version, including alpha/beta/rc tags. +release = '%d.%d.%d' % __version_tuple__ + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ['_build'] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +#keep_warnings = False + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'nature' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# "<project> v<release> documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +#html_static_path = [] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +#html_extra_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a <link> tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = 'Python-Markupsdoc' + + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { +# The paper size ('letterpaper' or 'a4paper'). +#'papersize': 'letterpaper', + +# The font size ('10pt', '11pt' or '12pt'). +#'pointsize': '10pt', + +# Additional stuff for the LaTeX preamble. +#'preamble': '', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + ('index', 'Python-Markups.tex', u'Python-Markups Documentation', + u'Dmitry Shachnev', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ('index', 'python-markups', u'Python-Markups Documentation', + [u'Dmitry Shachnev'], 1) +] + +# If true, show URL addresses after external links. +#man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ('index', 'Python-Markups', u'Python-Markups Documentation', + u'Dmitry Shachnev', 'Python-Markups', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +#texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +#texinfo_no_detailmenu = False diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Markups-0.4/docs/custom_markups.rst new/Markups-0.5.2/docs/custom_markups.rst --- old/Markups-0.4/docs/custom_markups.rst 1970-01-01 01:00:00.000000000 +0100 +++ new/Markups-0.5.2/docs/custom_markups.rst 2014-09-10 13:26:49.000000000 +0200 @@ -0,0 +1,63 @@ +============== +Custom Markups +============== + +Registering the markup module +============================= + +Any third-party markup should be placed in the same directory +as built-in markups. To get that directory, use: + +>>> import markups +>>> print(markups.__path__) + +Every module should have :data:`markup` property pointing to +the markup class. + +To register the markup, one should append the markup name to +file named ``pymarkups.txt`` in the +:ref:`configuration directory <configuration-directory>`. + +To check if the module was found by Python-Markups, one can check +if the module is present in return value of +:func:`~markups.get_custom_markups` function. + +Importing third-party modules +============================= + +A markup must not directly import any third party Python module it uses +at file level. Instead, it should check the module availability in +:meth:`~markups.abstract.AbstractMarkup.available` static method. + +That method can try to import the needed modules, and return ``True`` in +case of success, and ``False`` in case of failure. + +Implementing methods +==================== + +Any markup must inherit from :class:`~markups.abstract.AbstractMarkup` +class. + +Third-party markups must implement +:meth:`~markups.abstract.AbstractMarkup.get_document_body` method, which +is the main method of any markup. + +Other methods that are optional: + + * :meth:`~markups.abstract.AbstractMarkup.get_document_title`; + * :meth:`~markups.abstract.AbstractMarkup.get_javascript`; + * :meth:`~markups.abstract.AbstractMarkup.get_stylesheet`. + +Using the cache +=============== + +Markups are provided with :attr:`~markups.abstract.AbstractMarkup._cache` +dictionary that can contain any data shared between subsequent calls to +markup methods. Attribute :attr:`~markups.abstract._enable_cache` +indicates whether or not the cache should be used (set to ``False`` by +default). + +For example, :meth:`~markups.abstract.AbstractMarkup.get_whole_html` +method sets :attr:`~markups.abstract._enable_cache` to ``True``, then +subsequently retrieves document title, body, javascript and stylesheet, +and sets :attr:`~markups.abstract._enable_cache` back to ``False``. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Markups-0.4/docs/index.rst new/Markups-0.5.2/docs/index.rst --- old/Markups-0.4/docs/index.rst 1970-01-01 01:00:00.000000000 +0100 +++ new/Markups-0.5.2/docs/index.rst 2014-09-24 12:18:51.000000000 +0200 @@ -0,0 +1,39 @@ +=================================== +Python-Markups module documentation +=================================== + +Introduction to Python-Markups +============================== + +Python-Markups is a module that provides unified interface for using +various markup languages, such as Markdown, reStructuredText, and +Textile. It is also possible for clients to create and register their +own markup languages. + +The output language Python-Markups works with is HTML. Stylesheets and +JavaScript sections are supported. + +The abstract interface that any markup implements is +:class:`~markups.abstract.AbstractMarkup`. + +Contents +======== + +.. toctree:: + + overview + interface + standard_markups + custom_markups + changelog + +Links +===== + +* Python-Markups source code is hosted on GitHub_. +* You can get the source tarball from PyPI_. +* It is also packaged in Debian_. + +.. _GitHub: https://github.com/mitya57/pymarkups +.. _PyPI: https://pypi.python.org/pypi/Markups +.. _Debian: https://packages.debian.org/sid/source/pymarkups diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Markups-0.4/docs/interface.rst new/Markups-0.5.2/docs/interface.rst --- old/Markups-0.4/docs/interface.rst 1970-01-01 01:00:00.000000000 +0100 +++ new/Markups-0.5.2/docs/interface.rst 2014-09-10 13:26:49.000000000 +0200 @@ -0,0 +1,11 @@ +================ +Markup interface +================ + +The main class for interacting with markups is :class:`~markups.abstract.AbstractMarkup`. + +However, you shouldn't create direct instances of that class. Instead, use one of the +:doc:`standard markup classes <standard_markups>`. + +.. autoclass:: markups.abstract.AbstractMarkup + :members: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Markups-0.4/docs/overview.rst new/Markups-0.5.2/docs/overview.rst --- old/Markups-0.4/docs/overview.rst 1970-01-01 01:00:00.000000000 +0100 +++ new/Markups-0.5.2/docs/overview.rst 2014-09-10 13:26:49.000000000 +0200 @@ -0,0 +1,43 @@ +============ +API overview +============ + +For the very basic usage of Python-Markups, one should import +some markup class from :mod:`markups`, create an instance +of that class, and use the methods provided by +:class:`~markups.abstract.AbstractMarkup`: + +>>> import markups +>>> markup = markups.ReStructuredTextMarkup() +>>> markup.get_document_body('*reStructuredText* test') +'<p><em>reStructuredText</em> test</p>\n' + +For advanced usage (like dynamically choosing the markup class), +one may use one of the functions documented below. + +Getting lists of available markups +================================== + +.. autofunction:: markups.get_all_markups +.. autofunction:: markups.get_available_markups +.. autofunction:: markups.get_custom_markups + +Getting a specific markup +========================= + +.. autofunction:: markups.get_markup_for_file_name +.. autofunction:: markups.find_markup_class_by_name + +.. _configuration-directory: + +Configuration directory +======================= + +Some markups can provide configuration files that the user may use +to change the behavior. + +These files are stored in a single configuration directory. + +If :envvar:`XDG_CONFIG_HOME` is defined, then the configuration +directory is it. Otherwise, it is :file:`.config` subdirectory in +the user's home directory. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Markups-0.4/docs/standard_markups.rst new/Markups-0.5.2/docs/standard_markups.rst --- old/Markups-0.4/docs/standard_markups.rst 1970-01-01 01:00:00.000000000 +0100 +++ new/Markups-0.5.2/docs/standard_markups.rst 2014-09-10 13:26:49.000000000 +0200 @@ -0,0 +1,80 @@ +================ +Built-in markups +================ + +These markups are available by default: + +Markdown markup +=============== + +Markdown_ markup uses Python-Markdown_ as a backend. + +There are several ways to enable `Python-Markdown extensions`. + +* List extensions in a file named :file:`markdown-extensions.txt` in + the :ref:`configuration directory <configuration-directory>`, + separated by newline. The extensions will be automatically applied + to all documents. +* If :file:`markdown-extensions.txt` is placed into working directory, + all documents in that directory will get extensions listed in that + file. +* If first line of a document contains ":samp:`Required extensions: + {ext1 ext2 ...}`", that list will be applied to a document. +* Finally, one can programmatically pass list of extension names to + :class:`markups.MarkdownMarkup` constructor. + +Additionally to features provided by Python-Markdown, this markup also +supports a syntax for LaTeX-style math formulas (powered by MathJax_). +The delimiters are: + +================ =============== +Inline math Standalone math +================ =============== +``$...$`` [#f1]_ ``$$...$$`` +``\(...\)`` ``\[...\]`` +================ =============== + +.. [#f1] To enable single-dollar-sign delimiter, one should enable + virtual ``mathjax`` extension. + +The `Python-Markdown Extra`_ set of extensions is enabled by default. +To disable it, one can enable virtual ``remove_extra`` extension +(which also completely disables LaTeX formulas support). + +The default file extension associated with Markdown markup is ``.mkd``, +though many other extensions (including ``.md`` and ``.markdown``) are +supported as well. + +.. _Markdown: http://daringfireball.net/projects/markdown/ +.. _Python-Markdown: https://pythonhosted.org/Markdown/ +.. _MathJax: http://www.mathjax.org/ +.. _`Python-Markdown extensions`: http://pythonhosted.org/Markdown/extensions/ +.. _`Python-Markdown Extra`: http://pythonhosted.org/Markdown/extensions/extra.html + +.. autoclass:: markups.MarkdownMarkup + +reStructuredText markup +======================== + +This markup provides support for reStructuredText_ language (the language +this documentation is written in). It uses Docutils_ Python module. + +The file extension associated with reStructuredText markup is ``.rst``. + +.. _reStructuredText: http://docutils.sourceforge.net/rst.html +.. _Docutils: http://docutils.sourceforge.net/ + +.. autoclass:: markups.ReStructuredTextMarkup + +Textile markup +============== + +This markup provides support for Textile language. It uses python-textile_ +module. + +The file extension associated with Textile markup is ``.textile``. + +.. _Textile: http://textile.sitemonks.com/ +.. _python-textile: https://github.com/sebix/python-textile + +.. autoclass:: markups.TextileMarkup diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Markups-0.4/markups/__init__.py new/Markups-0.5.2/markups/__init__.py --- old/Markups-0.4/markups/__init__.py 2013-11-30 10:24:24.000000000 +0100 +++ new/Markups-0.5.2/markups/__init__.py 2014-11-05 18:48:19.000000000 +0100 @@ -1,6 +1,6 @@ # This file is part of python-markups module # License: BSD -# Copyright: (C) Dmitry Shachnev, 2012 +# Copyright: (C) Dmitry Shachnev, 2012-2014 import os import sys @@ -9,7 +9,7 @@ from markups.restructuredtext import ReStructuredTextMarkup from markups.textile import TextileMarkup -__version_tuple__ = (0, 4) +__version_tuple__ = (0, 5, 2) __version__ = '.'.join(map(str, __version_tuple__)) builtin_markups = [MarkdownMarkup, ReStructuredTextMarkup, TextileMarkup] @@ -17,6 +17,10 @@ # Public API def get_custom_markups(): + """ + :returns: list of registered :doc:`custom markups <custom_markups>` + :rtype: list of markup classes + """ try: list_file = open(os.path.join(CONFIGURATION_DIR, 'pymarkups.txt')) except IOError: @@ -34,9 +38,19 @@ return custom_markups def get_all_markups(): + """ + :returns: list of all markups (both standard and custom ones) + :rtype: list of markup classes + """ return builtin_markups + get_custom_markups() def get_available_markups(): + """ + :returns: list of all available markups (markups whose + :meth:`~markups.abstract.AbstractMarkup.available` + method returns True) + :rtype: list of markup classes + """ available_markups = [] for markup in get_all_markups(): if markup.available(): @@ -44,6 +58,25 @@ return available_markups def get_markup_for_file_name(filename, return_class=False): + """ + :param filename: name of the file + :type filename: str + :param return_class: if true, this function will return + a class rather than an instance + :type return_class: bool + + :returns: a markup with + :attr:`~markups.abstract.AbstractMarkup.file_extensions` + attribute containing extension of `filename`, if found, + otherwise ``None`` + + >>> import markups + >>> markup = markups.get_markup_for_file_name('foo.mkd') + >>> markup.get_document_body('**Test**') + '<p><strong>Test</strong></p>\\n' + >>> markups.get_markup_for_file_name('bar.rst', return_class=True) + <class 'markups.restructuredtext.ReStructuredTextMarkup'> + """ markup_class = None for markup in get_all_markups(): for extension in markup.file_extensions: @@ -55,6 +88,16 @@ return markup_class(filename=filename) def find_markup_class_by_name(name): + """ + :returns: a markup with + :attr:`~markups.abstract.AbstractMarkup.name` + attribute matching `name`, if found, otherwise ``None`` + :rtype: class + + >>> import markups + >>> markups.find_markup_class_by_name('textile') + <class 'markups.textile.TextileMarkup'> + """ for markup in get_all_markups(): if markup.name.lower() == name.lower(): return markup diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Markups-0.4/markups/abstract.py new/Markups-0.5.2/markups/abstract.py --- old/Markups-0.4/markups/abstract.py 2013-11-23 09:44:51.000000000 +0100 +++ new/Markups-0.5.2/markups/abstract.py 2014-09-10 13:26:49.000000000 +0200 @@ -1,35 +1,76 @@ # This file is part of python-markups module # License: BSD -# Copyright: (C) Dmitry Shachnev, 2012 +# Copyright: (C) Dmitry Shachnev, 2012-2014 class AbstractMarkup(object): - """Abstract class for markup languages""" + """Abstract class for markup languages. + :param filename: optional name of the file + :type filename: str + """ + + #: name of the markup visible to user + name = '' + #: various attributes, like links to website and syntax documentation + attributes = {} + #: indicates which file extensions are associated with the markup file_extensions = () + #: the default file extension + default_extension = '' def __init__(self, filename=None): self.filename = filename - self.enable_cache = False - self.cache = {} + self._enable_cache = False + self._cache = {} + @staticmethod def available(): + """ + :returns: whether the markup is ready for use + + (for example, whether the required third-party + modules are importable) + :rtype: bool + """ return True def get_document_title(self, text): + """ + :returns: the document title + :rtype: str + """ return '' def get_document_body(self, text): + """ + :returns: the contents of the ``<body>`` HTML tag + :rtype: str + """ raise NotImplementedError def get_stylesheet(self, text=''): + """ + :returns: the contents of ``<style type="text/css">`` HTML tag + :rtype: str + """ return '' def get_javascript(self, text='', webenv=False): + """ + :returns: one or more HTML tags to be inserted into the document + ``<head>``. + :rtype: str + """ return '' def get_whole_html(self, text, custom_headers='', include_stylesheet=True, fallback_title='', webenv=False): - self.enable_cache = True + """ + :returns: the full contents of the HTML document (unless overridden + this is a combination of the previous methods) + :rtype: str + """ + self._enable_cache = True body = self.get_document_body(text) stylesheet = ('<style type="text/css">\n' + self.get_stylesheet(text) + '</style>\n' if include_stylesheet else '') @@ -38,8 +79,8 @@ title = fallback_title title_string = ('<title>' + title + '</title>\n') if title else '' javascript = self.get_javascript(text, webenv) - self.enable_cache = False - self.cache = {} + self._enable_cache = False + self._cache = {} return ( '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\n' '<html>\n<head>\n' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Markups-0.4/markups/markdown.py new/Markups-0.5.2/markups/markdown.py --- old/Markups-0.4/markups/markdown.py 2013-11-23 09:44:51.000000000 +0100 +++ new/Markups-0.5.2/markups/markdown.py 2014-11-05 18:42:39.000000000 +0100 @@ -5,6 +5,7 @@ from __future__ import absolute_import import os +import re import sys import markups.common as common from markups.abstract import AbstractMarkup @@ -22,8 +23,15 @@ </script> ''' +extensions_re = re.compile(r'required.extensions: ([ \w]+)', flags=re.IGNORECASE) + class MarkdownMarkup(AbstractMarkup): - """Markdown language""" + """Markup class for Markdown language. + Inherits :class:`~markups.abstract.AbstractMarkup`. + + :param extensions: list of extension names + :type extensions: list + """ name = 'Markdown' attributes = { common.LANGUAGE_HOME_PAGE: 'http://daringfireball.net/projects/markdown/', @@ -48,11 +56,29 @@ except IOError: return [] else: - extensions = [line.rstrip() for line in extensions_file] + extensions = [line.rstrip() for line in extensions_file + if not line.startswith('#')] extensions_file.close() return extensions + def _get_global_extensions(self, filename): + extensions = self._load_extensions_list_from_file( + os.path.join(common.CONFIGURATION_DIR, 'markdown-extensions.txt')) + local_directory = os.path.dirname(filename) if filename else '' + extensions += self._load_extensions_list_from_file( + os.path.join(local_directory, 'markdown-extensions.txt')) + return extensions + + def _get_document_extensions(self, text): + lines = text.splitlines() + match = extensions_re.search(lines[0]) if lines else None + if match: + return match.group(1).strip().split() + return [] + def _check_extension_exists(self, extension_name): + if '(' in extension_name: + extension_name = extension_name[:extension_name.find('(')] try: __import__('markdown.extensions.'+extension_name, {}, {}, ['markdown.extensions']) @@ -63,31 +89,33 @@ return False return True - def _get_mathjax_patterns(self, markdown): + def _get_mathjax_patterns(self): def handle_match_inline(m): - node = markdown.util.etree.Element('script') + node = self.markdown.util.etree.Element('script') node.set('type', 'math/tex') - node.text = markdown.util.AtomicString(m.group(3)) + node.text = self.markdown.util.AtomicString(m.group(3)) return node - + def handle_match(m): - node = markdown.util.etree.Element('script') + node = self.markdown.util.etree.Element('script') node.set('type', 'math/tex; mode=display') - node.text = markdown.util.AtomicString(m.group(3)) + node.text = self.markdown.util.AtomicString(m.group(3)) if '\\begin' in m.group(2): - node.text = markdown.util.AtomicString(m.group(2) + + node.text = self.markdown.util.AtomicString(m.group(2) + m.group(3) + m.group(4)) return node - + inlinemathpatterns = ( - markdown.inlinepatterns.Pattern(r'(?<!\\|\$)(\$)([^\$]+)(\$)'), - markdown.inlinepatterns.Pattern(r'(?<!\\)(\\\()(.+?)(\\\))') + self.markdown.inlinepatterns.Pattern(r'(?<!\\|\$)(\$)([^\$]+)(\$)'), # $...$ + self.markdown.inlinepatterns.Pattern(r'(?<!\\)(\\\()(.+?)(\\\))') # \(...\) ) mathpatterns = ( - markdown.inlinepatterns.Pattern(r'(?<!\\)(\$\$)([^\$]+)(\$\$)'), - markdown.inlinepatterns.Pattern(r'(?<!\\)(\\\[)(.+?)(\\\])'), - markdown.inlinepatterns.Pattern(r'(?<!\\)(\\begin{[a-z]+\*?})(.+)(\\end{[a-z]+\*?})') + self.markdown.inlinepatterns.Pattern(r'(?<!\\)(\$\$)([^\$]+)(\$\$)'), # $$...$$ + self.markdown.inlinepatterns.Pattern(r'(?<!\\)(\\\[)(.+?)(\\\])'), # \[...\] + self.markdown.inlinepatterns.Pattern(r'(?<!\\)(\\begin{[a-z]+\*?})(.+)(\\end{[a-z]+\*?})') ) + if not self.mathjax: + inlinemathpatterns = inlinemathpatterns[1:] patterns = [] for pattern in inlinemathpatterns: pattern.handleMatch = handle_match_inline @@ -97,43 +125,46 @@ patterns.append(pattern) return patterns + def _apply_extensions(self): + extensions = (self.requested_extensions or + self.global_extensions) + self.document_extensions + # Remove duplicate entries + extensions = list(set(extensions)) + # We have two "virtual" extensions + self.mathjax = ('mathjax' in extensions) + self.remove_mathjax = ('remove_extra' in extensions) + if 'remove_extra' in extensions: + extensions.remove('remove_extra') + elif 'extra' not in extensions: + extensions.append('extra') + if self.mathjax: + extensions.remove('mathjax') + for extension in extensions: + if not extension: + extensions.remove(extension) + continue + if not self._check_extension_exists(extension): + sys.stderr.write('Extension "%s" does not exist.\n' % extension) + extensions.remove(extension) + self.md = self.markdown.Markdown(extensions, output_format='html4') + for i, pattern in enumerate(self._get_mathjax_patterns()): + self.md.inlinePatterns.add('mathjax%d' % i, pattern, '<escape') + self.extensions = extensions + def __init__(self, filename=None, extensions=None): AbstractMarkup.__init__(self, filename) import markdown - if extensions is None: - self.extensions = self._load_extensions_list_from_file( - os.path.join(common.CONFIGURATION_DIR, 'markdown-extensions.txt')) - local_directory = os.path.split(filename)[0] if filename else '.' - if not local_directory: local_directory = '.' - self.extensions += self._load_extensions_list_from_file( - os.path.join(local_directory, 'markdown-extensions.txt')) - # Remove duplicate entries - self.extensions = list(set(self.extensions)) - else: - self.extensions = extensions - # We have two virtual extensions - if 'remove_extra' in self.extensions: - self.extensions.remove('remove_extra') - else: - self.extensions.append('extra') - self.mathjax = ('mathjax' in self.extensions) - if self.mathjax: - self.extensions.remove('mathjax') - for extension in self.extensions: - if not self._check_extension_exists(extension): - sys.stderr.write('Failed loading extension %s\n' % extension) - self.extensions.remove(extension) - self.md = markdown.Markdown(self.extensions, output_format='html4') - if self.mathjax: - patterns = self._get_mathjax_patterns(markdown) - for i, pattern in enumerate(patterns): - self.md.inlinePatterns.add('mathjax%d' % i, pattern, '<escape') + self.markdown = markdown + self.requested_extensions = extensions or [] + self.global_extensions = self._get_global_extensions(filename) + self.document_extensions = [] + self._apply_extensions() def get_document_title(self, text): + if not 'body' in self._cache: + self.get_document_body(text) if 'meta' not in self.extensions: return '' - if not 'body' in self.cache: - self.get_document_body(text) if hasattr(self.md, 'Meta') and 'title' in self.md.Meta: return str.join(' ', self.md.Meta['title']) else: @@ -145,10 +176,8 @@ return '' def get_javascript(self, text='', webenv=False): - if not self.mathjax: - return '' - if 'body' in self.cache: - body = self.cache['body'] + if 'body' in self._cache: + body = self._cache['body'] else: body = self.get_document_body(text) if not '<script type="math/tex' in body: @@ -158,7 +187,11 @@ def get_document_body(self, text): self.md.reset() + document_extensions = self._get_document_extensions(text) + if document_extensions or self.document_extensions: + self.document_extensions = document_extensions + self._apply_extensions() converted_text = self.md.convert(text) + '\n' - if self.enable_cache: - self.cache['body'] = converted_text + if self._enable_cache: + self._cache['body'] = converted_text return converted_text diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Markups-0.4/markups/restructuredtext.py new/Markups-0.5.2/markups/restructuredtext.py --- old/Markups-0.4/markups/restructuredtext.py 2013-11-23 09:44:51.000000000 +0100 +++ new/Markups-0.5.2/markups/restructuredtext.py 2014-09-10 13:26:49.000000000 +0200 @@ -6,7 +6,15 @@ from markups.abstract import AbstractMarkup class ReStructuredTextMarkup(AbstractMarkup): - """reStructuredText language""" + """Markup class for reStructuredText language. + Inherits :class:`~markups.abstract.AbstractMarkup`. + + :param settings_overrides: optional dictionary of overrides for the + `Docutils settings`_ + :type settings_overrides: dict + + .. _`Docutils settings`: http://docutils.sourceforge.net/docs/user/config.html + """ name = 'reStructuredText' attributes = { common.LANGUAGE_HOME_PAGE: 'http://docutils.sourceforge.net/rst.html', @@ -33,12 +41,12 @@ self._publish_parts = publish_parts def publish_parts(self, text): - if 'rest_parts' in self.cache: - return self.cache['rest_parts'] + if 'rest_parts' in self._cache: + return self._cache['rest_parts'] parts = self._publish_parts(text, source_path=self.filename, writer_name='html', settings_overrides=self.overrides) - if self.enable_cache: - self.cache['rest_parts'] = parts + if self._enable_cache: + self._cache['rest_parts'] = parts return parts def get_document_title(self, text): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Markups-0.4/markups/textile.py new/Markups-0.5.2/markups/textile.py --- old/Markups-0.4/markups/textile.py 2013-11-30 10:19:54.000000000 +0100 +++ new/Markups-0.5.2/markups/textile.py 2014-09-10 13:26:49.000000000 +0200 @@ -8,7 +8,9 @@ from markups.abstract import AbstractMarkup class TextileMarkup(AbstractMarkup): - """Textile language""" + """Markup class for Textile language. + Inherits :class:`~markups.abstract.AbstractMarkup`. + """ name = 'Textile' attributes = { common.LANGUAGE_HOME_PAGE: 'http://textile.sitemonks.com/', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Markups-0.4/markups/web.py new/Markups-0.5.2/markups/web.py --- old/Markups-0.4/markups/web.py 2013-11-29 11:44:25.000000000 +0100 +++ new/Markups-0.5.2/markups/web.py 2014-09-10 13:26:49.000000000 +0200 @@ -36,7 +36,7 @@ if not os.path.isfile(filename): return False return (markups.get_markup_for_file_name(filename) is not None) - + self._init_template() for fname in filter(is_supported_file, os.listdir(self.working_dir)): self._process_page(fname) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Markups-0.4/setup.cfg new/Markups-0.5.2/setup.cfg --- old/Markups-0.4/setup.cfg 1970-01-01 01:00:00.000000000 +0100 +++ new/Markups-0.5.2/setup.cfg 2014-11-05 18:50:44.000000000 +0100 @@ -0,0 +1,5 @@ +[egg_info] +tag_date = 0 +tag_svn_revision = 0 +tag_build = + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Markups-0.4/setup.py new/Markups-0.5.2/setup.py --- old/Markups-0.4/setup.py 2013-11-23 09:44:51.000000000 +0100 +++ new/Markups-0.5.2/setup.py 2014-09-10 13:26:49.000000000 +0200 @@ -4,6 +4,16 @@ from distutils.core import setup, Command from markups import __version__ as version +try: + from sphinx.setup_command import BuildDoc +except ImportError: + BuildDoc = None + +try: + from setuptools.command.upload_docs import upload_docs +except ImportError: + upload_docs = None + long_description = \ """This module provides a wrapper around the various text markup languages, such as Markdown_ and reStructuredText_ (these two are supported by default). @@ -37,6 +47,7 @@ 'Programming Language :: Python :: 3.1', 'Programming Language :: Python :: 3.2', 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', 'Topic :: Text Processing :: Markup', 'Topic :: Text Processing :: General', 'Topic :: Software Development :: Libraries :: Python Modules' @@ -49,14 +60,18 @@ def finalize_options(self): pass def run(self): - import tests - oldargv, sys.argv = sys.argv, ['setup.py test', '-v'] - try: - tests.main() - except SystemExit as e: - if e.code: - raise - sys.argv = oldargv + from unittest.main import main + testprogram = main(module=None, argv=sys.argv[:1], verbosity=2, exit=False) + if not testprogram.result.wasSuccessful(): + sys.exit(1) + +cmdclass = {} +if sys.version_info[0] >= 3: + cmdclass['test'] = run_tests +if BuildDoc: + cmdclass['build_sphinx'] = BuildDoc +if upload_docs: + cmdclass['upload_docs'] = upload_docs setup_args = { 'name': 'Markups', @@ -65,13 +80,10 @@ 'long_description': long_description, 'author': 'Dmitry Shachnev', 'author_email': '[email protected]', - 'url': 'http://launchpad.net/python-markups', + 'url': 'https://github.com/mitya57/pymarkups', 'packages': ['markups'], 'license': 'BSD', + 'cmdclass': cmdclass, 'classifiers': classifiers } - -if sys.version_info[0] >= 3: - setup_args['cmdclass'] = {'test': run_tests} - setup(**setup_args) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Markups-0.4/tests/__init__.py new/Markups-0.5.2/tests/__init__.py --- old/Markups-0.4/tests/__init__.py 2013-11-23 09:44:51.000000000 +0100 +++ new/Markups-0.5.2/tests/__init__.py 2014-09-10 13:26:49.000000000 +0200 @@ -1,12 +1,4 @@ -import sys -import unittest - -def main(): - if sys.version_info[0] >= 3: - from unittest.main import main - main(module=None) - else: - unittest.main() +from unittest.main import main if __name__ == '__main__': - main() + main(module=None, verbosity=2) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Markups-0.4/tests/test_markdown.py new/Markups-0.5.2/tests/test_markdown.py --- old/Markups-0.4/tests/test_markdown.py 2013-11-25 19:21:55.000000000 +0100 +++ new/Markups-0.5.2/tests/test_markdown.py 2014-11-05 18:45:19.000000000 +0100 @@ -3,7 +3,6 @@ # Copyright: (C) Dmitry Shachnev, 2012 from markups import MarkdownMarkup -import os import unittest tables_source = \ @@ -51,6 +50,9 @@ </dl> ''' +mathjax_header = \ +'<!--- Type: markdown; Required extensions: mathjax --->\n\n' + mathjax_source = \ r'''$i_1$ some text \$escaped\$ $i_2$ @@ -109,10 +111,22 @@ class MarkdownTest(unittest.TestCase): maxDiff = None + def test_empty_file(self): + markup = MarkdownMarkup() + self.assertEqual(markup.get_document_body(''), '\n') + def test_extensions_loading(self): markup = MarkdownMarkup() self.assertFalse(markup._check_extension_exists('nonexistent')) + self.assertFalse(markup._check_extension_exists('nonexistent(someoption)')) self.assertTrue(markup._check_extension_exists('meta')) + self.assertTrue(markup._check_extension_exists('meta(someoption)')) + + def test_extensions_parameters(self): + markup = MarkdownMarkup(extensions=['toc(anchorlink=1)']) + html = markup.get_document_body('## Header') + self.assertEqual(html, + '<h2 id="header"><a class="toclink" href="#header">Header</a></h2>\n') def test_extra(self): markup = MarkdownMarkup() @@ -124,13 +138,35 @@ def test_remove_extra(self): markup = MarkdownMarkup(extensions=['remove_extra']) html = markup.get_document_body(tables_source) - self.assertNotEqual(html, tables_output) + self.assertNotIn(html, '<table>') + + def test_remove_extra_document_extension(self): + markup = MarkdownMarkup(extensions=[]) + html = markup.get_document_body( + 'Required-Extensions: remove_extra\n\n' + + tables_source) + self.assertNotIn(html, '<table>') + + def test_remove_extra_removes_mathjax(self): + markup = MarkdownMarkup() + html = markup.get_document_body('$$1$$') + self.assertNotIn(html, 'math/tex') def test_meta(self): - markup = MarkdownMarkup(extensions=['meta']) - title = markup.get_document_title('Title: Hello, world!\n\nSome text here.') + markup = MarkdownMarkup() + text = ('Required-Extensions: meta\n' + 'Title: Hello, world!\n\n' + 'Some text here.') + title = markup.get_document_title(text) self.assertEqual('Hello, world!', title) + def test_default_math(self): + # by default $...$ delimeter should be disabled + markup = MarkdownMarkup(extensions=[]) + self.assertEqual('<p>$1$</p>\n', markup.get_document_body('$1$')) + self.assertEqual('<p>\n<script type="math/tex; mode=display">1</script>\n</p>\n', + markup.get_document_body('$$1$$')) + def test_mathjax(self): markup = MarkdownMarkup(extensions=['mathjax']) # Escaping should work @@ -140,14 +176,16 @@ body = markup.get_document_body(mathjax_source) self.assertEqual(mathjax_output, body) + def test_mathjax_document_extension(self): + markup = MarkdownMarkup() + text = mathjax_header + mathjax_source + body = markup.get_document_body(text) + self.assertEqual(mathjax_header + mathjax_output, body) + def test_mathjax_multiline(self): markup = MarkdownMarkup(extensions=['mathjax']) body = markup.get_document_body(mathjax_multiline_source) self.assertEqual(mathjax_multiline_output, body) - def tearDown(self): - if os.path.exists('markdown-extensions.txt'): - os.remove('markdown-extensions.txt') - if __name__ == '__main__': unittest.main() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Markups-0.4/tests/test_restructuredtext.py new/Markups-0.5.2/tests/test_restructuredtext.py --- old/Markups-0.4/tests/test_restructuredtext.py 2013-11-30 10:19:43.000000000 +0100 +++ new/Markups-0.5.2/tests/test_restructuredtext.py 2014-09-10 13:26:49.000000000 +0200 @@ -17,7 +17,7 @@ markup = ReStructuredTextMarkup() text = markup.get_document_body(basic_text) title = markup.get_document_title(basic_text) - markup.enable_cache = True + markup._enable_cache = True text_from_cache = markup.get_document_body(basic_text) title_from_cache = markup.get_document_title(basic_text) text_expected = \ -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
