smarty
Smarty extension for Python-Markdown.
Adds conversion of ASCII dashes, quotes and ellipses to their HTML entity equivalents.
See https://pythonhosted.org/Markdown/extensions/smarty.html for documentation.
Author: 2013, Dmitry Shachnev mitya57@gmail.com
All changes Copyright 2013-2014 The Python Markdown Project
License: BSD
SmartyPants license:
Copyright (c) 2003 John Gruber http://daringfireball.net/ All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-
Neither the name "SmartyPants" nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
This software is provided by the copyright holders and contributors "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.
smartypants.py license:
smartypants.py is a derivative work of SmartyPants. Copyright (c) 2004, 2007 Chad Miller http://web.chad.org/
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
This software is provided by the copyright holders and contributors "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.
Attributes
punctClass = '[!"#\\$\\%\'()*+,-.\\/:;<=>?\\@\\[\\\\\\]\\^_`{|}~]'
module-attribute
endOfWordClass = '[\\s.,;:!?)]'
module-attribute
closeClass = '[^\\ \\t\\r\\n\\[\\{\\(\\-\\u0002\\u0003]'
module-attribute
openingQuotesBase = '(\\s| |--|–|—|&[mn]dash;|–|—)'
module-attribute
substitutions = {'mdash': '—', 'ndash': '–', 'ellipsis': '…', 'left-angle-quote': '«', 'right-angle-quote': '»', 'left-single-quote': '‘', 'right-single-quote': '’', 'left-double-quote': '“', 'right-double-quote': '”'}
module-attribute
singleQuoteStartRe = "^'(?=%s\\B)" % punctClass
module-attribute
doubleQuoteStartRe = '^"(?=%s\\B)' % punctClass
module-attribute
doubleQuoteSetsRe = '"\'(?=\\w)'
module-attribute
singleQuoteSetsRe = '\'"(?=\\w)'
module-attribute
decadeAbbrRe = "(?<!\\w)'(?=\\d{2}s)"
module-attribute
openingDoubleQuotesRegex = '%s"(?=\\w)' % openingQuotesBase
module-attribute
closingDoubleQuotesRegex = '"(?=\\s)'
module-attribute
closingDoubleQuotesRegex2 = '(?<=%s)"' % closeClass
module-attribute
openingSingleQuotesRegex = "%s'(?=\\w)" % openingQuotesBase
module-attribute
closingSingleQuotesRegex = "(?<=%s)'(?!\\s|s\\b|\\d)" % closeClass
module-attribute
closingSingleQuotesRegex2 = "(?<=%s)'(\\s|s\\b)" % closeClass
module-attribute
remainingSingleQuotesRegex = "'"
module-attribute
remainingDoubleQuotesRegex = '"'
module-attribute
HTML_STRICT_RE = HTML_RE + '(?!\\>)'
module-attribute
Classes
SubstituteTextPattern(pattern, replace, markdown_instance)
Bases: HtmlPattern
Text pattern substitution handler.
Replaces matches with some text.
Source code in pyrevitlib/pyrevit/coreutils/markdown/extensions/smarty.py
Attributes
pattern = pattern
instance-attribute
compiled_re = re.compile('^(.*?)%s(.*)$' % pattern, re.DOTALL | re.UNICODE)
instance-attribute
safe_mode = False
instance-attribute
replace = replace
instance-attribute
markdown = markdown_instance
instance-attribute
Functions
getCompiledRegExp()
type()
unescape(text)
Return unescaped text given text with an inline placeholder.
Source code in pyrevitlib/pyrevit/coreutils/markdown/inlinepatterns.py
handleMatch(m)
SmartyExtension(*args, **kwargs)
Bases: Extension
Smarty Extension.
Source code in pyrevitlib/pyrevit/coreutils/markdown/extensions/smarty.py
Attributes
config = {'smart_quotes': [True, 'Educate quotes'], 'smart_angled_quotes': [False, 'Educate angled quotes'], 'smart_dashes': [True, 'Educate dashes'], 'smart_ellipses': [True, 'Educate ellipses'], 'substitutions': [{}, 'Overwrite default substitutions']}
instance-attribute
substitutions = dict(substitutions)
instance-attribute
Functions
getConfig(key, default='')
Return a setting for the given key or an empty string.
getConfigs()
getConfigInfo()
setConfig(key, value)
Set a config setting for key
with the given value
.
Source code in pyrevitlib/pyrevit/coreutils/markdown/extensions/__init__.py
setConfigs(items)
Set multiple config settings given a dict or list of tuples.