diff --git a/py-packages/markslider/markslider/markslider.py b/py-packages/markslider/markslider/markslider.py index c0e4a51..6316506 100755 --- a/py-packages/markslider/markslider/markslider.py +++ b/py-packages/markslider/markslider/markslider.py @@ -20,7 +20,7 @@ """Markslider: a slideshow engine based on markdown.""" __author__ = "Ville Rantanen " -__version__ = "1.3" +__version__ = "1.3.1" import sys, os, argparse, re, datetime from argparse import ArgumentParser @@ -28,6 +28,10 @@ import traceback, tty, termios, subprocess, signal sys.path.append(os.path.dirname(os.path.realpath(__file__))) import ansicodes, md_color +try: + import climage +except ImportError: + pass HL = ">" EOS = "# End of Slides" @@ -59,6 +63,7 @@ class slide_reader: self.files = files self.reader = None self.opts = opts + self.scrsize = get_console_size() self.pages = 0 self.page = 0 self.file_start_page = [] @@ -236,8 +241,10 @@ class slide_reader: if command != None: return self.launch(command) image = self.re_image_convert.match(s) - if image != None: + try: return self.convert_image(image) + except Exception: + pass return [s] def launch(self, command): @@ -263,17 +270,16 @@ class slide_reader: # return [s] def convert_image(self, image): - """comnvert image using tags ![]()> + """convert image using tags ![]()> Remove empty lines from beginning and end of stdout. """ # ~ 2=title # ~ 3=image command - output = subprocess.check_output( - "convert %s JPEG:- | jp2a --colors --width=70 -" % (image.group(3),), - shell=True, + width = max(5, self.scrsize[1] - 10) + output = climage.convert( + image.group(3), + is_unicode=True, is_truecolor=True, is_256color=False, is_16color=False, is_8color=False, width=width, palette="default" ) - if type(output) == bytes: - output = output.decode("utf-8") output = output.split("\n") while len(output[0].strip()) == 0: if len(output) == 1: @@ -283,11 +289,8 @@ class slide_reader: if len(output) == 1: return [""] del output[-1] - return_value = [image.group(1)] - return_value.extend(output) - # ~ return_value.append(image.group(4)) + return_value = [image.group(1), *output] return return_value - # return [s] def rename_duplicates(self): @@ -382,7 +385,7 @@ Special syntaxes: * Text after a "# End of Slides" is not shown * Execute shell: ` command -switch `! Beware of malicious code! * Execute and print output: ` command `> Beware of malicious code! - * Convert images to ASCII, with jp2a: ![](file.jpg)> + * Convert images to ANSI, with climage: ![](file.jpg)> Keyboard shortcuts: """ diff --git a/py-packages/markslider/setup.py b/py-packages/markslider/setup.py index bbdaf3c..41421a3 100644 --- a/py-packages/markslider/setup.py +++ b/py-packages/markslider/setup.py @@ -18,6 +18,6 @@ setup( keywords=["Markdown", "Slideshow"], entry_points = {'console_scripts': 'markslider = markslider.markslider:main'}, install_requires = [ - 'pygments' + 'pygments', 'climage' ] ) diff --git a/reporting/qolop b/reporting/qolop index c7b9ad8..1565fb5 100755 --- a/reporting/qolop +++ b/reporting/qolop @@ -117,7 +117,7 @@ _qCol() { for ((arg=1;arg<=$#;arg++)) { val=${!arg} [[ ${color_keys} = *" $val "* ]] || { echo "No such color code '${val}'" >&2; return 1; } - printf ${!val} + printf "${!val}" } } diff --git a/skel/Makefile b/skel/Makefile new file mode 100644 index 0000000..a66e31c --- /dev/null +++ b/skel/Makefile @@ -0,0 +1,28 @@ + +.PHONY: help + +help: ## *:・゚✧*:・゚✧ This help *:・゚✧*:・゚✧ + @printf "\033[36;1m %14s \033[0;32;1m %s\033[0m\n" Target Description + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \ + awk ' \ + BEGIN {FS = ":.*?## "}; \ + { if ( $$1 != "-") { \ + printf "\033[31;1;40m[ \033[36;1;40m%14s \033[31;1;40m]\033[0;32;1m %s\033[0m\n", $$1, $$2 \ + } else { \ + printf " \033[0;33;1m=^= %-25s =^=\033[0m\n", $$2 \ + } \ + } \ + ' + +-: ## Building +################################### + +build: ## Build image + echo docker build -t image . + +-: ## Running +################################### + + +run: ## Run image + echo docker run image