Initial commit: Klammertext source distribution

Curated source subset assembled by klammertext-dev's doc/make_dist.sh: the Klammermachine (mac), the Standard Klammer Set (sks), the commands (com), editor plugins and install guides (doc), a test subset (tst), and lib/bin placeholders. Builds with 'make -C com'.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-18 18:48:23 +02:00
commit 2ba7ceee7a
272 changed files with 27634 additions and 0 deletions

58
sks/kutil/klammer_base.py Normal file
View File

@@ -0,0 +1,58 @@
import pprint
import re
import kutil
def unescape_ktesc(s):
"""Resolve KTESC escape markers back to original characters.
Use this for argument values used programmatically (filenames, etc.)."""
def replace(match):
hex_chars = match.group(1)
result = ''
for i in range(0, len(hex_chars), 4):
result += chr(int(hex_chars[i:i+4], 16))
return result
return re.sub(r'KTESC([0-9a-f]+)KTESC', replace, s)
class Klammer_base:
def __init__(self, K):
#args = {k:escape(v) for k, v in K.__dict__.items()
args = {k:v for k, v in K.__dict__.items()
if not k.startswith('__')}
for key in args:
setattr(self, key, args[key])
#setattr(self, "_klammer_name", klammer_name)
#pprint.pprint(self.__dict__)
def html(self):
#return '[{}: HTML]'.format(self.__class__.__name__)
return None
def tex(self):
#return '[{}: LaTeX]'.format(self.__class__.__name__)
return None
def txt(self):
#return '[{}: Plain text]'.format(self.__class__.__name__)
return None
def show(self, label=""):
if label:
print(label)
pprint.pprint(self.__dict__)
def __str__(self):
result = None
if self.K_target == 'html':
result = self.html()
elif self.K_target in {'tex', 'pdf'}:
result = kutil.escape(self.tex())
elif self.K_target == 'txt':
result = self.txt()
if result is None:
#print(self.__dict__)
raise Exception(
f'Target "{self.K_target}" is undefined for klammer "@{self.K_klammer}"')
return result