diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | pyproject.toml | 6 | ||||
-rw-r--r-- | requirements.txt | 1 | ||||
-rw-r--r-- | setup.cfg | 33 | ||||
-rw-r--r-- | setup.py | 7 | ||||
-rw-r--r-- | src/pymdvar/__init__.py | 3 | ||||
-rw-r--r-- | src/pymdvar/pymdvar.py | 19 |
7 files changed, 70 insertions, 1 deletions
@@ -1,2 +1,2 @@ -# python-markdown-variables +# pymdvar Python's Markdown extension to insert variables diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..e74c9ec --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,6 @@ +[build-system] +requires = [ + "setuptools>=42", + "wheel" +] +build-backend = "setuptools.build_meta" diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..6ca7f7a --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +Markdown>=3.4.1
\ No newline at end of file diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..640e3e0 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,33 @@ +[metadata] +name = pymdvar +author = David Luevano Alvarado +author_email = david@luevano.xyz +summary = Python-Markdown extension to insert variables +description_file = README.md +license = GPLv3 +home_page = https://github.com/luevano/pymdvar +classifiers = + Programming Language :: Python :: 3 + License :: OSI Approved :: GNU General Public License v3 (GPLv3) + Operating System :: Unix + Topic :: Text Processing :: Markup :: HTML + Topic :: Text Processing :: Markup :: Markdown +keywords = + python + markdown + +[files] +packages = + pymdvar + +[bdist_wheel] +universal = 0 + +[options] +package_dir = + = src +packages = find: +include_package_data=True + +[options.packages.find] +where = src diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..8770a01 --- /dev/null +++ b/setup.py @@ -0,0 +1,7 @@ +from setuptools import setup + +setup( + setup_requires=['pbr'], + pbr=True, + long_description_content_type="text/markdown" +) diff --git a/src/pymdvar/__init__.py b/src/pymdvar/__init__.py new file mode 100644 index 0000000..b64a3b6 --- /dev/null +++ b/src/pymdvar/__init__.py @@ -0,0 +1,3 @@ +from .pymdvar import VariableExtension + +__all__ = ['VariableExtension']
\ No newline at end of file diff --git a/src/pymdvar/pymdvar.py b/src/pymdvar/pymdvar.py new file mode 100644 index 0000000..aa62cfd --- /dev/null +++ b/src/pymdvar/pymdvar.py @@ -0,0 +1,19 @@ +from markdown.extensions import Extension +from markdown.inlinepatterns import Pattern + +VARIABLE_RE = r'\$\{(\w+)\}' + + +class VariablePattern(Pattern): + def handleMatch(self, m): + variable = m.group(2) + return variable + + +def makeExtension(*args, **kwargs): + return VariableExtension(*args, **kwargs) + + +class VariableExtension(Extension): + def extendMarkdown(self, md): + md.inlinePatterns.register(VariablePattern(VARIABLE_RE), 'var', 175)
\ No newline at end of file |