Fixing Markdown implementation
This commit is contained in:
parent
23eb62aa33
commit
932e44e9c6
2 changed files with 101 additions and 28 deletions
|
@ -47,15 +47,28 @@ from UI import UI_color
|
||||||
|
|
||||||
def Open(win, filename, name):
|
def Open(win, filename, name):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# This function will parse a Markdown (.md) file into a readable python
|
# This function will parse a Markdown (.md) file into a readable python
|
||||||
# dictionary object. That you can use for various things.
|
# dictionary object. That you can use for various things.
|
||||||
try:
|
try:
|
||||||
|
|
||||||
# If the file is local. AKA exists in the folder. And can be read.
|
# If the file is local. AKA exists in the folder. And can be read.
|
||||||
# Also it could be not .md
|
# Also it could be not .md
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if not filename.endswith(".md"):
|
if not filename.endswith(".md"):
|
||||||
1/0 # Quick fail switch
|
1/0 # Quick fail switch
|
||||||
|
|
||||||
|
# Sometimes a language File is provided. let's
|
||||||
|
# look for it.
|
||||||
|
|
||||||
|
l = win.settings["Language"]
|
||||||
|
|
||||||
|
if os.path.exists(os.getcwd()+"/"+filename[:-3]+"_"+l+".md"):
|
||||||
|
filename = filename[:-3]+"_"+l+".md"
|
||||||
|
|
||||||
md = open(filename)
|
md = open(filename)
|
||||||
md = md.read()
|
md = md.read()
|
||||||
|
|
||||||
|
@ -68,7 +81,21 @@ def Open(win, filename, name):
|
||||||
oscalls.Open(filename)
|
oscalls.Open(filename)
|
||||||
win.current["mdfs"][name] = win.current["mdfs"]["failsafe"]
|
win.current["mdfs"][name] = win.current["mdfs"]["failsafe"]
|
||||||
|
|
||||||
|
|
||||||
|
# A few things before I gonna make everything. The - [ ] and the - [X] things.
|
||||||
|
# This is the stuff I want to change to the corresponding icons.
|
||||||
|
|
||||||
|
md = md.replace("- [ ]", "![](settings/themes/Default/icons/unchecked.png)")
|
||||||
|
md = md.replace("- [X]", "![](settings/themes/Default/icons/checked.png)")
|
||||||
|
md = md.replace("- [x]", "![](settings/themes/Default/icons/checked.png)")
|
||||||
|
md = md.replace("- ", "• ")
|
||||||
|
|
||||||
|
# This one is risky. I want to remove all the ../ so there will not be a
|
||||||
|
# mistake.
|
||||||
|
|
||||||
|
md = md.replace("../", "")
|
||||||
|
|
||||||
|
# Spliting it for the read.
|
||||||
md = md.split("\n")
|
md = md.split("\n")
|
||||||
|
|
||||||
# First thing is I was to read the headings and convert it into a tree.
|
# First thing is I was to read the headings and convert it into a tree.
|
||||||
|
@ -328,8 +355,11 @@ def draw(outlayer, win, name, x, y, width, height):
|
||||||
|
|
||||||
if name not in win.current["mdfs"]:
|
if name not in win.current["mdfs"]:
|
||||||
win.current["mdfs"][name] = ""
|
win.current["mdfs"][name] = ""
|
||||||
|
|
||||||
|
|
||||||
filename = win.current["mdfs"][name]
|
filename = win.current["mdfs"][name]
|
||||||
|
filename = filename.replace("../", "")
|
||||||
|
win.current["mdfs"][name] = filename
|
||||||
|
|
||||||
# The # sing usually calls for search with in the text.
|
# The # sing usually calls for search with in the text.
|
||||||
|
|
||||||
|
@ -376,7 +406,7 @@ def draw(outlayer, win, name, x, y, width, height):
|
||||||
UI_elements.text(outlayer, win, "markdown_name",
|
UI_elements.text(outlayer, win, "markdown_name",
|
||||||
x+10,
|
x+10,
|
||||||
y+5,
|
y+5,
|
||||||
int(width)-20,
|
int(width)-120,
|
||||||
40,
|
40,
|
||||||
set_text=filename,
|
set_text=filename,
|
||||||
fill=False)
|
fill=False)
|
||||||
|
@ -395,7 +425,7 @@ def draw(outlayer, win, name, x, y, width, height):
|
||||||
win.current["mdfs"][name] = win.text["markdown_name"]["text"]
|
win.current["mdfs"][name] = win.text["markdown_name"]["text"]
|
||||||
|
|
||||||
UI_elements.roundrect(outlayer, win,
|
UI_elements.roundrect(outlayer, win,
|
||||||
x+int(width)-50,
|
x+int(width)-150,
|
||||||
y+5,
|
y+5,
|
||||||
40,
|
40,
|
||||||
40,
|
40,
|
||||||
|
@ -407,6 +437,41 @@ def draw(outlayer, win, name, x, y, width, height):
|
||||||
|
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# I want to include 2 button to the top raw besides the adress bar.
|
||||||
|
# A button to open the file in the standard application. ( Edit )
|
||||||
|
# A button to open the NoABug repository version ( NotABug )
|
||||||
|
|
||||||
|
# EDIT
|
||||||
|
|
||||||
|
def do():
|
||||||
|
oscalls.Open(filename)
|
||||||
|
|
||||||
|
UI_elements.roundrect(outlayer, win,
|
||||||
|
x+int(width)-100,
|
||||||
|
y+5,
|
||||||
|
40,
|
||||||
|
40,
|
||||||
|
10,
|
||||||
|
button=do,
|
||||||
|
icon="edit",
|
||||||
|
tip=talk.text("edit_markdown"))
|
||||||
|
|
||||||
|
# NOTABUG
|
||||||
|
|
||||||
|
def do():
|
||||||
|
oscalls.Open("https://notabug.org/jyamihud/VCStudio/src/master/"+filename)
|
||||||
|
|
||||||
|
UI_elements.roundrect(outlayer, win,
|
||||||
|
x+int(width)-50,
|
||||||
|
y+5,
|
||||||
|
40,
|
||||||
|
40,
|
||||||
|
10,
|
||||||
|
button=do,
|
||||||
|
icon="notabug",
|
||||||
|
tip=talk.text("notabug_markdown"))
|
||||||
|
|
||||||
|
|
||||||
# Now let's draw the bastard. We are going to do it the same way as in the
|
# Now let's draw the bastard. We are going to do it the same way as in the
|
||||||
# script writer. But rather simplified. For example we are not making an
|
# script writer. But rather simplified. For example we are not making an
|
||||||
|
@ -513,11 +578,7 @@ def draw(outlayer, win, name, x, y, width, height):
|
||||||
elif "image" in block[0]:
|
elif "image" in block[0]:
|
||||||
|
|
||||||
|
|
||||||
if newY:
|
|
||||||
current_Y = current_Y + newY + 40
|
|
||||||
tyleX = 10
|
|
||||||
newX = 10
|
|
||||||
newY = 0
|
|
||||||
|
|
||||||
# ICONS
|
# ICONS
|
||||||
|
|
||||||
|
@ -544,6 +605,12 @@ def draw(outlayer, win, name, x, y, width, height):
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
|
if newY:
|
||||||
|
current_Y = current_Y + newY + 40
|
||||||
|
tyleX = 10
|
||||||
|
newX = 10
|
||||||
|
newY = 0
|
||||||
|
|
||||||
UI_elements. image(layer, win, block[2],
|
UI_elements. image(layer, win, block[2],
|
||||||
tyleX,
|
tyleX,
|
||||||
current_Y + win.scroll["markdown"]-15,
|
current_Y + win.scroll["markdown"]-15,
|
||||||
|
@ -555,10 +622,18 @@ def draw(outlayer, win, name, x, y, width, height):
|
||||||
imH = 40
|
imH = 40
|
||||||
imW = 40
|
imW = 40
|
||||||
|
|
||||||
tyleX = tyleX + imW
|
|
||||||
|
|
||||||
newX = imW + 40
|
bx = tyleX
|
||||||
newY = imH - 20
|
by = current_Y
|
||||||
|
|
||||||
|
if imW < width/2:
|
||||||
|
tyleX = tyleX + imW
|
||||||
|
|
||||||
|
newX = imW + 40
|
||||||
|
newY = imH - 20
|
||||||
|
else:
|
||||||
|
tyleX = 10
|
||||||
|
current_Y = current_Y + imH
|
||||||
|
|
||||||
# LINKED IMAGES
|
# LINKED IMAGES
|
||||||
|
|
||||||
|
@ -574,6 +649,7 @@ def draw(outlayer, win, name, x, y, width, height):
|
||||||
win.current["mdfs"]["failsafe"] = filename
|
win.current["mdfs"]["failsafe"] = filename
|
||||||
win.current["mdfs"][name] = block[3]
|
win.current["mdfs"][name] = block[3]
|
||||||
win.current["current_help_selected"] = ""
|
win.current["current_help_selected"] = ""
|
||||||
|
win.scroll["markdown"] = 0
|
||||||
else:
|
else:
|
||||||
oscalls.Open(block[3])
|
oscalls.Open(block[3])
|
||||||
|
|
||||||
|
@ -602,8 +678,8 @@ def draw(outlayer, win, name, x, y, width, height):
|
||||||
|
|
||||||
# Full on image
|
# Full on image
|
||||||
|
|
||||||
UI_elements.roundrect(layer, win, tyleX-imW,
|
UI_elements.roundrect(layer, win, bx,
|
||||||
current_Y + win.scroll["markdown"]-15,imW, imH,10,
|
by + win.scroll["markdown"]-15,imW, imH,10,
|
||||||
button=do,
|
button=do,
|
||||||
offset=[x,y],
|
offset=[x,y],
|
||||||
tip=block[3],
|
tip=block[3],
|
||||||
|
@ -658,6 +734,7 @@ def draw(outlayer, win, name, x, y, width, height):
|
||||||
win.current["mdfs"]["failsafe"] = filename
|
win.current["mdfs"]["failsafe"] = filename
|
||||||
win.current["mdfs"][name] = block[2]
|
win.current["mdfs"][name] = block[2]
|
||||||
win.current["current_help_selected"] = ""
|
win.current["current_help_selected"] = ""
|
||||||
|
win.scroll["markdown"] = 0
|
||||||
elif block[2].startswith("#"):
|
elif block[2].startswith("#"):
|
||||||
win.current["mdfs"][name] = win.current["mdfs"][name] + block[2]
|
win.current["mdfs"][name] = win.current["mdfs"][name] + block[2]
|
||||||
win.current["current_help_selected"] = ""
|
win.current["current_help_selected"] = ""
|
||||||
|
|
|
@ -164,28 +164,28 @@ def layer(win, call):
|
||||||
["Markdown", "LICENSE.md"],
|
["Markdown", "LICENSE.md"],
|
||||||
],
|
],
|
||||||
talk.text("documentation_installation"):[
|
talk.text("documentation_installation"):[
|
||||||
["scene", "https://notabug.org/jyamihud/VCStudio/wiki/Documenation+%7C+Installation+%7C+Version+20.128"],
|
["Markdown", "wiki/docs/Installation.md"],
|
||||||
["video", "https://open.lbry.com/@blender-organizer:5/rnd0001-4061:1?r=7YADjAZEbHJg8n4qV5rAuBh5Hca7cZQK"]
|
["video", "https://open.lbry.com/@blender-organizer:5/rnd0001-4061:1?r=7YADjAZEbHJg8n4qV5rAuBh5Hca7cZQK"]
|
||||||
],
|
],
|
||||||
talk.text("documentation_project_manager"):[
|
talk.text("documentation_project_manager"):[
|
||||||
["scene", "https://notabug.org/jyamihud/VCStudio/wiki/Documenation+%7C+Project+Manager+%7C+Version+20.128"],
|
["Markdown", "wiki/docs/Project-Manager.md"],
|
||||||
["video", "https://open.lbry.com/@blender-organizer:5/Victorious-Children-Studio-Organizer-%28-VCStudio-%29---Project-Manager-Tutorial---Creating-Projects---Scanning-the-OS---Settings:7?r=7YADjAZEbHJg8n4qV5rAuBh5Hca7cZQK"]
|
["video", "https://open.lbry.com/@blender-organizer:5/Victorious-Children-Studio-Organizer-%28-VCStudio-%29---Project-Manager-Tutorial---Creating-Projects---Scanning-the-OS---Settings:7?r=7YADjAZEbHJg8n4qV5rAuBh5Hca7cZQK"]
|
||||||
],
|
],
|
||||||
talk.text("documentation_story_editor"):[
|
talk.text("documentation_story_editor"):[
|
||||||
["scene", "https://notabug.org/jyamihud/VCStudio/wiki/Documenation+%7C+Story+Editor+%7C+Version+20.128+"]
|
["Markdown", "wiki/docs/Story-Editor.md"],
|
||||||
],
|
],
|
||||||
talk.text("documentation_script_writer"):[
|
talk.text("documentation_script_writer"):[
|
||||||
["scene", "https://notabug.org/jyamihud/VCStudio/wiki/Documenation+%7C+Script+Writer+%7C+Version+20.128"]
|
["Markdown", "wiki/docs/Script-Writer.md"],
|
||||||
],
|
],
|
||||||
talk.text("documentation_analytics"):[
|
talk.text("documentation_analytics"):[
|
||||||
["scene", "https://notabug.org/jyamihud/VCStudio/wiki/Documenation+%7C+Analytics+%7C+Version+20.128"]
|
["Markdown", "wiki/docs/Analytics.md"],
|
||||||
],
|
],
|
||||||
talk.text("documentation_assets"):[
|
talk.text("documentation_assets"):[
|
||||||
["scene", "https://notabug.org/jyamihud/VCStudio/wiki/Documenation+%7C+Assets+%7C+Version+20.128"],
|
["Markdown", "wiki/docs/Assets.md"],
|
||||||
["update", "https://notabug.org/jyamihud/VCStudio/wiki/Version+20.1211+%28Asset+Manager+Alpha+++Default+Blend+Files++Project%27s+Settings%29"]
|
["update", "https://notabug.org/jyamihud/VCStudio/wiki/Version+20.1211+%28Asset+Manager+Alpha+++Default+Blend+Files++Project%27s+Settings%29"]
|
||||||
],
|
],
|
||||||
talk.text("documentation_link_assets"):[
|
talk.text("documentation_link_assets"):[
|
||||||
["scene", "https://notabug.org/jyamihud/VCStudio/wiki/Documenation+%7C+Linking+Assets+%7C+Version+20.128"],
|
["Markdown", "wiki/docs/LinkingAssets.md"],
|
||||||
["update", "https://notabug.org/jyamihud/VCStudio/wiki/Version+20.1263+%28+Linking+Assets+++Configuring+Assets+%29"]
|
["update", "https://notabug.org/jyamihud/VCStudio/wiki/Version+20.1263+%28+Linking+Assets+++Configuring+Assets+%29"]
|
||||||
],
|
],
|
||||||
talk.text("documentation_render"):[
|
talk.text("documentation_render"):[
|
||||||
|
@ -224,6 +224,7 @@ def layer(win, call):
|
||||||
def do():
|
def do():
|
||||||
|
|
||||||
win.text["in_help"]["text"] = ""
|
win.text["in_help"]["text"] = ""
|
||||||
|
win.scroll["markdown"] = 0
|
||||||
if name != win.current["current_help_selected"]:
|
if name != win.current["current_help_selected"]:
|
||||||
win.current["current_help_selected"] = name
|
win.current["current_help_selected"] = name
|
||||||
else:
|
else:
|
||||||
|
@ -270,15 +271,10 @@ def layer(win, call):
|
||||||
|
|
||||||
if entry[0] == "Markdown":
|
if entry[0] == "Markdown":
|
||||||
|
|
||||||
# Sometimes a language File is provided. let's
|
|
||||||
# look for it.
|
|
||||||
|
|
||||||
l = win.settings["Language"]
|
|
||||||
|
|
||||||
if os.path.exists(os.getcwd()+"/"+entry[1][:-3]+"_"+l+".md"):
|
|
||||||
entry[1] = entry[1][:-3]+"_"+l+".md"
|
|
||||||
|
|
||||||
win.current["mdfs"]["help_markdown"] = entry[1]
|
win.current["mdfs"]["help_markdown"] = entry[1]
|
||||||
|
|
||||||
#win.current["current_help_selected"] = ""
|
#win.current["current_help_selected"] = ""
|
||||||
|
|
||||||
continue
|
continue
|
||||||
|
@ -336,7 +332,7 @@ def layer(win, call):
|
||||||
|
|
||||||
# Report Bug Button
|
# Report Bug Button
|
||||||
def do():
|
def do():
|
||||||
os.system("xdg-open https://notabug.org/jyamihud/VCStudio/issues/new")
|
os.system("xdg-open https://notabug.org/jyamihud/VCStudio/issues")
|
||||||
|
|
||||||
|
|
||||||
UI_elements.roundrect(layer, win,
|
UI_elements.roundrect(layer, win,
|
||||||
|
|
Loading…
Reference in a new issue