Compare commits
No commits in common. "8519fe0b95483f45721e7ec2733faff8b79d2c4d" and "04e7866da10641ad3aa53ff015dfc4a6e86d5198" have entirely different histories.
8519fe0b95
...
04e7866da1
@ -38,8 +38,6 @@ def transcode(value, _base_path):
|
|||||||
def transcode_part2(value):
|
def transcode_part2(value):
|
||||||
value = value.replace(":CODE:UNDER:SCORE:", "_")
|
value = value.replace(":CODE:UNDER:SCORE:", "_")
|
||||||
value = value.replace(":CODE:STAR:", "*")
|
value = value.replace(":CODE:STAR:", "*")
|
||||||
value = value.replace(":CODE:BRACKET:START:", "[")
|
|
||||||
value = value.replace(":CODE:BRACKET:STOP:", "]")
|
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
@ -52,7 +50,5 @@ def replace_code(match):
|
|||||||
#value = value.replace("\n", "<br/>")
|
#value = value.replace("\n", "<br/>")
|
||||||
value = value.replace("_", ":CODE:UNDER:SCORE:")
|
value = value.replace("_", ":CODE:UNDER:SCORE:")
|
||||||
value = value.replace("*", ":CODE:STAR:")
|
value = value.replace("*", ":CODE:STAR:")
|
||||||
value = value.replace("[", ":CODE:BRACKET:START:")
|
|
||||||
value = value.replace("]", ":CODE:BRACKET:STOP:")
|
|
||||||
return '<pre>' + str(value) + '</pre>'
|
return '<pre>' + str(value) + '</pre>'
|
||||||
|
|
||||||
|
@ -3,31 +3,6 @@ from realog import debug
|
|||||||
import sys
|
import sys
|
||||||
from monk import tools
|
from monk import tools
|
||||||
import re
|
import re
|
||||||
import os
|
|
||||||
|
|
||||||
image_base_path = ""
|
|
||||||
|
|
||||||
def simplify_path(aaa):
|
|
||||||
#debug.warning("ploppppp " + str(aaa))
|
|
||||||
st = []
|
|
||||||
aaa = aaa.split("/")
|
|
||||||
for i in aaa:
|
|
||||||
if i == '..':
|
|
||||||
if len(st) > 0:
|
|
||||||
st.pop()
|
|
||||||
else:
|
|
||||||
continue
|
|
||||||
elif i == '.':
|
|
||||||
continue
|
|
||||||
elif i != '':
|
|
||||||
if len(st) > 0:
|
|
||||||
st.append("/" + str(i))
|
|
||||||
else:
|
|
||||||
st.append(str(i))
|
|
||||||
if len(st) == 1:
|
|
||||||
return "/"
|
|
||||||
#debug.error("ploppppp " + str(st))
|
|
||||||
return "".join(st)
|
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
@ -38,12 +13,9 @@ def simplify_path(aaa):
|
|||||||
## @return Transformed string.
|
## @return Transformed string.
|
||||||
##
|
##
|
||||||
def transcode(value, _base_path):
|
def transcode(value, _base_path):
|
||||||
global image_base_path
|
|
||||||
if len(_base_path) != 0:
|
if len(_base_path) != 0:
|
||||||
base_path = (_base_path + '/').replace('/',':IMAGE:UNDER:SCORE::IMAGE:UNDER:SCORE:')
|
base_path = (_base_path + '/').replace('/','__')
|
||||||
image_base_path = _base_path
|
|
||||||
else:
|
else:
|
||||||
image_base_path = ""
|
|
||||||
base_path = ""
|
base_path = ""
|
||||||
# named image : 
|
# named image : 
|
||||||
value = re.sub(r'!\[http://(.*?)\][ \t]*\((.*?)\)',
|
value = re.sub(r'!\[http://(.*?)\][ \t]*\((.*?)\)',
|
||||||
@ -56,96 +28,34 @@ def transcode(value, _base_path):
|
|||||||
p = re.compile('!\[(.*?)\][ \t]*\((.*?)\)')
|
p = re.compile('!\[(.*?)\][ \t]*\((.*?)\)')
|
||||||
value = p.sub(replace_image,
|
value = p.sub(replace_image,
|
||||||
value)
|
value)
|
||||||
#value = re.sub(r':BASE_PATH:',
|
value = re.sub(r':BASE_PATH:',
|
||||||
# r'' + base_path,
|
r'' + base_path,
|
||||||
# value)
|
value)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
element_type_count={"Image":0}
|
|
||||||
|
|
||||||
def transcode_part2(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(":IMAGE:SLASH:", "/")
|
|
||||||
|
|
||||||
|
|
||||||
return value
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def replace_image(match):
|
def replace_image(match):
|
||||||
global image_base_path
|
|
||||||
global element_type_count
|
|
||||||
if match.group() == "":
|
if match.group() == "":
|
||||||
return ""
|
return ""
|
||||||
debug.verbose("Image parse: " + str(match.group()))
|
debug.verbose("Image parse: " + str(match.group()))
|
||||||
#value = '<img src=":BASE_PATH:'
|
value = '<img src=":BASE_PATH:'
|
||||||
value = '<img src="'
|
value += match.groups()[1].replace("/", "__")
|
||||||
value += simplify_path(os.path.join(image_base_path, match.groups()[1])).replace("/", "__")
|
|
||||||
value += '" '
|
value += '" '
|
||||||
|
|
||||||
alt_properties = match.groups()[0].split("|")
|
alt_properties = match.groups()[0].split("|")
|
||||||
alt = False
|
alt = False
|
||||||
center = False
|
|
||||||
right = False
|
|
||||||
left = False
|
|
||||||
showTitle = False
|
|
||||||
title = False
|
|
||||||
type = "Image"
|
|
||||||
for elem in alt_properties:
|
for elem in alt_properties:
|
||||||
if alt == False:
|
if alt == False:
|
||||||
alt = True
|
alt = True
|
||||||
value += 'alt="' + elem + '" '
|
value += 'alt="' + elem + '" '
|
||||||
title = elem
|
|
||||||
continue
|
continue
|
||||||
key_alt, value_alt = elem.split("=")
|
key_alt, value_alt = elem.split("=")
|
||||||
if key_alt == "width":
|
if key_alt == "width":
|
||||||
value += 'width="' + value_alt + '" '
|
value += 'width="' + value_alt + '" '
|
||||||
elif key_alt == "height":
|
elif key_alt == "height":
|
||||||
value += 'height="' + value_alt + '" '
|
value += 'height="' + value_alt + '" '
|
||||||
if key_alt == "align":
|
|
||||||
if value_alt == "center":
|
|
||||||
center = True
|
|
||||||
if value_alt == "right":
|
|
||||||
right = True
|
|
||||||
if value_alt == "left":
|
|
||||||
left = True
|
|
||||||
if key_alt == "type":
|
|
||||||
type = value_alt
|
|
||||||
if key_alt == "titleShow":
|
|
||||||
if elem == "false":
|
|
||||||
showTitle = False
|
|
||||||
else:
|
|
||||||
showTitle = True
|
|
||||||
else:
|
else:
|
||||||
debug.warning("not manage element '" + key_alt + "' in '" + str(match.group()) + "'")
|
debug.warning("not manage element '" + key_alt + "' in '" + str(match.group()) + "'")
|
||||||
value += '/>'
|
value += '/>'
|
||||||
|
|
||||||
if type in element_type_count.keys():
|
|
||||||
element_type_count[type] += 1
|
|
||||||
else:
|
|
||||||
element_type_count[type] = 1
|
|
||||||
|
|
||||||
if showTitle == True:
|
|
||||||
value = "<br/>" + value + "<br/>[" + str(element_type_count[type]) + "] <u><b>" + type + ": </b>" + title + "</u><br/>"
|
|
||||||
|
|
||||||
|
|
||||||
if center == True:
|
|
||||||
value = "<center>" + value + "</center>"
|
|
||||||
elif right == True:
|
|
||||||
value = "<right>" + value + "</right>"
|
|
||||||
elif left == True:
|
|
||||||
value = "<left>" + value + "</left>"
|
|
||||||
|
|
||||||
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
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,12 +44,6 @@ def transcode(value, _base_path):
|
|||||||
|
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def transcode_part2(value):
|
|
||||||
value = value.replace(":LINK:UNDER:SCORE:", "_")
|
|
||||||
value = value.replace(":LINK:STAR:", "*")
|
|
||||||
value = value.replace(":LINK:BRACKET:START:", "[")
|
|
||||||
value = value.replace(":LINK:BRACKET:STOP:", "]")
|
|
||||||
return value
|
|
||||||
|
|
||||||
def replace_link(match):
|
def replace_link(match):
|
||||||
global basic_link_path
|
global basic_link_path
|
||||||
@ -71,9 +65,5 @@ def replace_link(match):
|
|||||||
value += '.html">' + match.groups()[0] + '</a>'
|
value += '.html">' + match.groups()[0] + '</a>'
|
||||||
else:
|
else:
|
||||||
value += '.html">' + match.groups()[1] + '</a>'
|
value += '.html">' + match.groups()[1] + '</a>'
|
||||||
value = value.replace("_", ":LINK:UNDER:SCORE:")
|
|
||||||
value = value.replace("*", ":LINK:STAR:")
|
|
||||||
value = value.replace("[", ":LINK:BRACKET:START:")
|
|
||||||
value = value.replace("]", ":LINK:BRACKET:STOP:")
|
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ import re
|
|||||||
##
|
##
|
||||||
def transcode(value, _base_path):
|
def transcode(value, _base_path):
|
||||||
|
|
||||||
p = re.compile('(\n(\|[^\n\|]*)*\|)*',
|
p = re.compile('((\n\|(.*)\|)*)',
|
||||||
flags=re.DOTALL)
|
flags=re.DOTALL)
|
||||||
value = p.sub(replace_table,
|
value = p.sub(replace_table,
|
||||||
value)
|
value)
|
||||||
@ -38,9 +38,7 @@ def replace_table(match):
|
|||||||
table_index = 0
|
table_index = 0
|
||||||
if match.group() == "":
|
if match.group() == "":
|
||||||
return ""
|
return ""
|
||||||
debug.warning("=============================: Parse TABLE ...")
|
debug.warning("=============================: " + str(match.group()))
|
||||||
debug.warning(str(match.group()))
|
|
||||||
debug.warning("=============================: ")
|
|
||||||
value = '<table class="doc_table">'
|
value = '<table class="doc_table">'
|
||||||
value_global = re.sub(r'\n\|([\t -]*\|)+',
|
value_global = re.sub(r'\n\|([\t -]*\|)+',
|
||||||
r'',
|
r'',
|
||||||
|
@ -58,48 +58,39 @@ def transcode(value, _base_path):
|
|||||||
r'\n==Z==555==Z==\1</h5>',
|
r'\n==Z==555==Z==\1</h5>',
|
||||||
value)
|
value)
|
||||||
|
|
||||||
"""
|
|
||||||
value = re.sub(r'\n###### (.*?)(( |\t)*\{.*\})* ######',
|
value = re.sub(r'\n###### (.*?)(( |\t)*\{.*\})* ######',
|
||||||
r'\n==Z==666==Z==\1</h6>',
|
r'\n==Z==666==Z==\1</h6>',
|
||||||
value)
|
value)
|
||||||
value = re.sub(r'\n###### (.*?)(( |\t)*\{.*\})*',
|
value = re.sub(r'\n###### (.*?)(( |\t)*\{.*\})*',
|
||||||
r'\n==Z==666==Z==\1</h6>',
|
r'\n==Z==666==Z==\1</h6>',
|
||||||
value)
|
value)
|
||||||
"""
|
|
||||||
|
|
||||||
value = re.sub(r'\n##### (.*?)(( |\t)*\{.*\})* #####',
|
value = re.sub(r'\n##### (.*?)(( |\t)*\{.*\})* #####',
|
||||||
r'\n==Z==666==Z==\1</h5>',
|
r'\n==Z==555==Z==\1</h5>',
|
||||||
value)
|
value)
|
||||||
value = re.sub(r'\n##### (.*?)(( |\t)*\{.*\})*\n',
|
value = re.sub(r'\n##### (.*?)(( |\t)*\{.*\})*',
|
||||||
r'\n==Z==666==Z==\1</h5>\n',
|
r'\n==Z==555==Z==\1</h5>',
|
||||||
value)
|
value)
|
||||||
|
|
||||||
value = re.sub(r'\n#### (.*?)(( |\t)*\{.*\})* ####',
|
value = re.sub(r'\n#### (.*?)(( |\t)*\{.*\})* ####',
|
||||||
r'\n==Z==555==Z==\1</h4>',
|
r'\n==Z==444==Z==\1</h4>',
|
||||||
value)
|
value)
|
||||||
value = re.sub(r'\n#### (.*?)(( |\t)*\{.*\})*\n',
|
value = re.sub(r'\n#### (.*?)(( |\t)*\{.*\})*',
|
||||||
r'\n==Z==555==Z==\1</h4>\n',
|
r'\n==Z==444==Z==\1</h4>',
|
||||||
value)
|
value)
|
||||||
|
|
||||||
value = re.sub(r'\n### (.*?)(( |\t)*\{.*\})* ###',
|
value = re.sub(r'\n### (.*?)(( |\t)*\{.*\})* ###',
|
||||||
r'\n==Z==444==Z==\1</h3>',
|
r'\n==Z==333==Z==\1</h3>',
|
||||||
value)
|
value)
|
||||||
value = re.sub(r'\n### (.*)(( |\t)*\{.*\})*\n',
|
value = re.sub(r'\n### (.*?)(( |\t)*\{.*\})*',
|
||||||
r'\n==Z==444==Z==\1</h3>\n',
|
r'\n==Z==333==Z==\1</h3>',
|
||||||
value)
|
value)
|
||||||
|
|
||||||
value = re.sub(r'\n## (.*?)(( |\t)*\{.*\})* ##',
|
value = re.sub(r'\n## (.*?)(( |\t)*\{.*\})* ##',
|
||||||
r'\n==Z==333==Z==\1</h2>',
|
r'\n==Z==222==Z==\1</h2>',
|
||||||
value)
|
value)
|
||||||
value = re.sub(r'\n## (.*?)(( |\t)*\{.*\})*\n',
|
value = re.sub(r'\n## (.*?)(( |\t)*\{.*\})*',
|
||||||
r'\n==Z==333==Z==\1</h2>\n',
|
r'\n==Z==222==Z==\1</h2>',
|
||||||
value)
|
|
||||||
|
|
||||||
value = re.sub(r'\n# (.*?)(( |\t)*\{.*\})* #',
|
|
||||||
r'\n==Z==333==Z==\1</h2>',
|
|
||||||
value)
|
|
||||||
value = re.sub(r'\n# (.*?)(( |\t)*\{.*\})*\n',
|
|
||||||
r'\n==Z==333==Z==\1</h2>\n',
|
|
||||||
value)
|
value)
|
||||||
|
|
||||||
value = re.sub(value_start,
|
value = re.sub(value_start,
|
||||||
|
@ -37,29 +37,18 @@ def transcode(value, _base_path = ""):
|
|||||||
value = MD_Title.transcode(value, _base_path)
|
value = MD_Title.transcode(value, _base_path)
|
||||||
value = MD_IndentAndDot.transcode(value, _base_path)
|
value = MD_IndentAndDot.transcode(value, _base_path)
|
||||||
value = MD_Code.transcode(value, _base_path)
|
value = MD_Code.transcode(value, _base_path)
|
||||||
|
|
||||||
value = MD_Table.transcode(value, _base_path)
|
|
||||||
value = MD_lineReturn.transcode(value, _base_path)
|
value = MD_lineReturn.transcode(value, _base_path)
|
||||||
value = MD_Title.transcode_clean_empty_line_after(value, _base_path)
|
value = MD_Title.transcode_clean_empty_line_after(value, _base_path)
|
||||||
|
value = MD_Text.transcode(value, _base_path)
|
||||||
"""
|
"""
|
||||||
value = BB_Text.transcode(value, _base_path)
|
value = BB_Text.transcode(value, _base_path)
|
||||||
value = BB_Specification.transcode(value, _base_path)
|
value = BB_Specification.transcode(value, _base_path)
|
||||||
"""
|
"""
|
||||||
|
value = MD_Table.transcode(value, _base_path)
|
||||||
value = MD_Image.transcode(value, _base_path)
|
value = MD_Image.transcode(value, _base_path)
|
||||||
value = MD_Link.transcode(value, _base_path)
|
value = MD_Link.transcode(value, _base_path)
|
||||||
value = MD_ResultSelection.transcode(value, _base_path)
|
value = MD_ResultSelection.transcode(value, _base_path)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
value = MD_Text.transcode(value, _base_path)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
value = MD_Code.transcode_part2(value)
|
value = MD_Code.transcode_part2(value)
|
||||||
value = MD_Image.transcode_part2(value)
|
|
||||||
value = MD_Link.transcode_part2(value)
|
|
||||||
return value
|
return value
|
||||||
|
|
||||||
##
|
##
|
||||||
|
Loading…
x
Reference in New Issue
Block a user