diff options
author | Qrius <[email protected]> | 2025-04-23 14:25:05 +0200 |
---|---|---|
committer | Qrius <[email protected]> | 2025-04-23 14:25:08 +0200 |
commit | 45f9f608d39289131548a0e1d7962617cf3c028e (patch) | |
tree | e3d359223e3b11ac810e618fe34e7ecfe1f8990e | |
parent | 16b4248e7d307e3e32f73892332087a239b195ac (diff) | |
download | skaldpress-45f9f608d39289131548a0e1d7962617cf3c028e.tar.gz skaldpress-45f9f608d39289131548a0e1d7962617cf3c028e.zip |
Prepare deb packaging, switch markdown dependency
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | Makefile | 40 | ||||
-rw-r--r-- | README | 92 | ||||
-rw-r--r-- | debian/changelog | 5 | ||||
-rw-r--r-- | debian/compat | 1 | ||||
-rw-r--r-- | debian/control | 12 | ||||
-rw-r--r-- | debian/files | 2 | ||||
-rwxr-xr-x | debian/rules | 7 | ||||
-rw-r--r-- | pyproject.toml | 6 | ||||
-rw-r--r-- | setup.py | 8 | ||||
-rw-r--r-- | src/skaldpress/__init__.py | 3 | ||||
-rw-r--r-- | src/smp/__init__.py | 1 | ||||
-rw-r--r-- | src/smp/builtins.py | 16 |
13 files changed, 142 insertions, 55 deletions
@@ -12,3 +12,7 @@ venv/ # due to using nox and pytest .nox .cache +debian/skaldpress/ +debian/.debhelper/ +debian/debhelper-build-stamp +debian/skaldpress.substvars diff --git a/Makefile b/Makefile deleted file mode 100644 index 8394bbf..0000000 --- a/Makefile +++ /dev/null @@ -1,40 +0,0 @@ -.PHONY: test build minorbump publish install clean - -venv/bin/tt: src/timetracker/*.py venv - . venv/bin/activate && \ - python -m pip install -e .[dev] - -venv: pyproject.toml - python3 -m venv venv - -build: venv - . venv/bin/activate && \ - python -m pip install build twine && \ - python -m build && \ - python -m twine check dist/* - -minorbump: - . venv/bin/activate && \ - bumpver update --patch - -publish: minorbump build - . venv/bin/activate && \ - twine upload dist/* - -install: venv - python -m pip install . - -clean: - rm -rf venv - rm -rf dist - -test: - . venv/bin/activate && \ - black --check src && \ - mypy src/ && \ - pyflakes src/ && \ - ./tests/test_macro_processor.sh && \ - ./tests/test_skaldpress.sh && \ - ./tests/test_unittests.sh - - @@ -0,0 +1,92 @@ +SMP(1) General Commands Manual SMP(1) + +name + Skaldpress Macro Processor - Macro processor + +SYNOPSIS + smp [input_file] + +DESCRIPTION + smp smp is a macro processor, made specifically for a usecase when doing templating of websites. + + Macros + include(<file>) + Includes a file in-place, performing macro-expansion on it. NOTE, THERE IS NO LOOP PROTECTION HERE! + + include_varbatim(<file>) + Same as include, but does not expand macros. + + define(<macro_name> [, <macro content>]) + This defines a macro, optionally with some content. The optional content will be expanded immediately, and later the already processed content will be included in the output. + + ifdef(<macro_name>, <output if defined> [, <output if not defined>]) + + ifndef(<macro_name>, <output if not defined> [, <output if defined>]) + + ifeq(<arg1>, <arg2>, <output if equal> [, <output if not equal>]) + + ifneq(<arg1>, <arg2>, <output if not equal> [, <output if equal>]) + + shell(<command>) + Runs command on shell, and includes the command output in the output + + expr(<arg1>, <arg2>, ..., <argN>) + Shorthand for running the expr command, expands all arguments, and executes it on the shell. + + define_array(<macro_name>) + Defines a macro as a array, this can later be used with macros like array_push and array_each. + + array_push(<macro_name>, <value>[, <additional value(s)>]) + On a macro that is defined as a array, this will add one or more elements. + + array_each(<macro_name>, <template macro>]) + Push any arguments to array macro Process each element in a array as a macro-invokation on the second argument Not the best way to do this, it is not sensibly recursive. + + array_size(<macro_name>) + Will return number of elements in a macro array. + + explode(<array_name>, <delimiter>, <input>) + Explode a input into individual array elements. + + format_time(<format>, <time>) + Format a RFC3339-timestamp to the specified format. Format is similar to strftime. Only available if the time-feature was enabled during compilation. + + html_from_markdown(<markdown>) + If compiled with markdown, this macro will convert it's argument from markdown to html. It will process it's input twice before actually doing the conversion. This is to remove the outer quotes of a argument. So you + should probably always quote arguments to this. + + wodl(<url>) + If compiled with deadlinks, this macro will always return it's argument. But it will also perform a request to the link, and emit a warning if it it doesn't return HTTP 200 OK. This will significantly slow down compile + times! + + Compile-Time Feature Flags + There are some compile-time flags that can enable/disable features, most are enabled by default, and exist either because they trigger a external dependency, or because they are unlikely to work without glibc. + + readline + Enabled by default. Enables the use of libc readline in REPL mode. If not enabled, normal stdio will be used for input. + + Requires readline to be installed on the system. + + time + Enabled by default. Enables the format_time-macro, this will compile the chrono dependency to format time. + + markdown + Enabled by default. Enabled the html_from_markdown-macro, this will compile the markdown dependency. And can convert markdown into html. + + deadlinks + Enabled by default. Enabled the wodl-macro, this will compile the minreq dependency. Allows testing the return code of links, and warns when the request is unsuccessful. + + guile + If compiled with guile, the macro processor supports running guile-code inline. This is enabled with %()% in the input, and anything inside the parantheses will be evaluated as guile. + + Requires libguile-3.0 to be installed on the system. + + Experimental feature! + +OPTIONS + If a input file is provided, that will be processed. If not, a sort of interactive REPL will be started instead. + +SEE ALSO + skaldpress(1) + + 2024-06-08 SMP(1) diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..71809b0 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +skaldpress (3.0.0) unstable; urgency=low + * Rewrite in python, make it more malleable + -- Qrius <[email protected]> Wed, 26 Mar 2025 09:16:00 +0000 + + diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..f599e28 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +10 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..d7d8c3e --- /dev/null +++ b/debian/control @@ -0,0 +1,12 @@ +Source: skaldpress +Maintainer: Qrius <[email protected]> +Section: python +Priority: optional +Build-Depends: dh-python, python3-setuptools, python3, dpkg-dev, debhelper (>= 9) +Standards-Version: 4.5.1 +Rules-Requires-Root: no + +Package: skaldpress +Architecture: any +Depends: python3, python3-markdown-it +Description: Skaldpress diff --git a/debian/files b/debian/files new file mode 100644 index 0000000..da7ff26 --- /dev/null +++ b/debian/files @@ -0,0 +1,2 @@ +skaldpress_3.0.0_amd64.buildinfo python optional +skaldpress_3.0.0_amd64.deb python optional diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..ffefe86 --- /dev/null +++ b/debian/rules @@ -0,0 +1,7 @@ +#!/usr/bin/make -f +#export PYBUILD_NAME=skaldpress +#export DEB_BUILD_OPTIONS=nocheck +#export PYBUILD_SYSTEM=setuptools + +%: + dh $@ --with python3 --buildsystem=pybuild diff --git a/pyproject.toml b/pyproject.toml index 2af6d31..88737b4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,11 +1,10 @@ -# https://packaging.python.org/en/latest/tutorials/packaging-projects/#choosing-a-build-backend [build-system] requires = ["setuptools"] build-backend = "setuptools.build_meta" [project] name = "skaldpress" -version = "1.0.0" # REQUIRED, although can be dynamic +version = "3.0.0" description = "" readme = "README" requires-python = ">=3.10" @@ -23,7 +22,7 @@ classifiers = [ "Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3 :: Only", ] -dependencies = ["markdown", "py-gfm"] +dependencies = ["markdown-it-py"] [project.optional-dependencies] dev = ["check-manifest", "black", "pyflakes", "mypy", "types-Markdown", "pyinstrument"] @@ -36,4 +35,3 @@ test = ["coverage"] smp = "smp:main" skaldpress = "skaldpress.main:main" -[tool.setuptools] diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..3efdd1d --- /dev/null +++ b/setup.py @@ -0,0 +1,8 @@ +from setuptools import setup, find_packages + +setup( + name='skaldpress', + packages=find_packages(where='src'), + package_dir={'': 'src'}, +) + diff --git a/src/skaldpress/__init__.py b/src/skaldpress/__init__.py index f00b84f..a89b06b 100644 --- a/src/skaldpress/__init__.py +++ b/src/skaldpress/__init__.py @@ -1,4 +1,5 @@ -__version__ = "0.0.1" +__version__ = "3.0.0" + # import skaldpress.smp_macros # # __all__ = [ diff --git a/src/smp/__init__.py b/src/smp/__init__.py index 898e683..4cfc534 100644 --- a/src/smp/__init__.py +++ b/src/smp/__init__.py @@ -1,4 +1,3 @@ -__version__ = "0.0.1" import smp.macro_processor import smp.builtins diff --git a/src/smp/builtins.py b/src/smp/builtins.py index a9e1977..e4a3429 100644 --- a/src/smp/builtins.py +++ b/src/smp/builtins.py @@ -5,11 +5,8 @@ import urllib.request import urllib.error import urllib.parse import datetime -import markdown -from markdown.extensions.tables import TableExtension -from markdown.extensions.fenced_code import FencedCodeExtension +from markdown_it import MarkdownIt from skaldpress.metadata_parser import extract_parse_yaml_metadata -from gfm import AutolinkExtension, TaskListExtension # type: ignore from typing import Any @@ -172,11 +169,12 @@ def smp_builtin_format_time(macro_processor, format, time): def smp_builtin_html_from_markdown(macro_processor, text, extensions=list()): text = macro_processor.process_input(text) - extensions.append(TableExtension()) - extensions.append(FencedCodeExtension()) - extensions.append(AutolinkExtension()) - extensions.append(TaskListExtension(max_depth=2)) - return markdown.markdown(text, extensions=extensions) + md = ( + MarkdownIt("commonmark", {"breaks": True, "html": True}) + .enable("table") + .enable("list") + ) + return md.render(text) def _smp_builtin_template_content(): |