diff options
author | David Luevano Alvarado <david@luevano.xyz> | 2023-02-14 01:38:17 -0600 |
---|---|---|
committer | David Luevano Alvarado <david@luevano.xyz> | 2023-02-14 01:38:17 -0600 |
commit | 0e46f2cd0a2f6a972da76ec92d10bb77cd3c7f37 (patch) | |
tree | 941ae7aecf3221865de7a0c5823fae48bee20592 /src | |
parent | a7f3be739f23cb2a8fbadd61785855e0dfa5b06a (diff) |
add boilerplate code, rename repo
Diffstat (limited to 'src')
-rw-r--r-- | src/pymdvar/__init__.py | 3 | ||||
-rw-r--r-- | src/pymdvar/pymdvar.py | 19 |
2 files changed, 22 insertions, 0 deletions
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 |