summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Luevano Alvarado <david@luevano.xyz>2023-02-14 01:38:17 -0600
committerDavid Luevano Alvarado <david@luevano.xyz>2023-02-14 01:38:17 -0600
commit0e46f2cd0a2f6a972da76ec92d10bb77cd3c7f37 (patch)
tree941ae7aecf3221865de7a0c5823fae48bee20592
parenta7f3be739f23cb2a8fbadd61785855e0dfa5b06a (diff)
add boilerplate code, rename repo
-rw-r--r--README.md2
-rw-r--r--pyproject.toml6
-rw-r--r--requirements.txt1
-rw-r--r--setup.cfg33
-rw-r--r--setup.py7
-rw-r--r--src/pymdvar/__init__.py3
-rw-r--r--src/pymdvar/pymdvar.py19
7 files changed, 70 insertions, 1 deletions
diff --git a/README.md b/README.md
index 64ea605..e844e38 100644
--- a/README.md
+++ b/README.md
@@ -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