From 15d2722381853c09ee6f61e66de2023000706ab4 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Wed, 2 Sep 2020 12:24:47 +0200 Subject: [PATCH] [DEV] add counting of images --- monk/codeMarkDown/MD_Image.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/monk/codeMarkDown/MD_Image.py b/monk/codeMarkDown/MD_Image.py index 3d87565..2087584 100644 --- a/monk/codeMarkDown/MD_Image.py +++ b/monk/codeMarkDown/MD_Image.py @@ -70,8 +70,13 @@ def transcode_part2(value): value = value.replace(":IMAGE:SLASH:", "/") return value + +element_type_count={"Image":0} + + def replace_image(match): global image_base_path + global element_type_count if match.group() == "": return "" debug.verbose("Image parse: " + str(match.group())) @@ -116,14 +121,15 @@ def replace_image(match): else: debug.warning("not manage element '" + key_alt + "' in '" + str(match.group()) + "'") value += '/>' - value = value.replace("_", ":IMAGE:UNDER:SCORE:") - value = value.replace("*", ":IMAGE:STAR:") - value = value.replace("[", ":IMAGE:BRACKET:START:") - value = value.replace("]", ":IMAGE:BRACKET:STOP:") - value = value.replace(":BASE:IMAGE:UNDER:SCORE:PATH:", ":BASE_PATH:") + + if type in element_type_count.keys(): + element_type_count[type] += 1 + else: + element_type_count[type] = 1 if showTitle == True: - value = "
" + value + "
Image: " + title + "
" + value = "
" + value + "
[" + str(element_type_count[type]) + "] " + type + ": " + title + "
" + if center == True: value = "
" + value + "
" @@ -132,6 +138,12 @@ def replace_image(match): elif left == True: value = "" + value + "" + value = value.replace("_", ":IMAGE:UNDER:SCORE:") + value = value.replace("*", ":IMAGE:STAR:") + value = value.replace("[", ":IMAGE:BRACKET:START:") + value = value.replace("]", ":IMAGE:BRACKET:STOP:") + value = value.replace(":BASE:IMAGE:UNDER:SCORE:PATH:", ":BASE_PATH:") + return value