Fixing Markdown implementation

This commit is contained in:
Jeison Yehuda Amihud (Blender Dumbass) 2021-05-10 19:52:14 +00:00
parent 23eb62aa33
commit 932e44e9c6
2 changed files with 101 additions and 28 deletions

View file

@ -47,15 +47,28 @@ from UI import UI_color
def Open(win, filename, name):
# This function will parse a Markdown (.md) file into a readable python
# dictionary object. That you can use for various things.
try:
# If the file is local. AKA exists in the folder. And can be read.
# Also it could be not .md
if not filename.endswith(".md"):
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 = md.read()
@ -69,6 +82,20 @@ def Open(win, filename, name):
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")
# First thing is I was to read the headings and convert it into a tree.
@ -329,7 +356,10 @@ def draw(outlayer, win, name, x, y, width, height):
if name not in win.current["mdfs"]:
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.
@ -376,7 +406,7 @@ def draw(outlayer, win, name, x, y, width, height):
UI_elements.text(outlayer, win, "markdown_name",
x+10,
y+5,
int(width)-20,
int(width)-120,
40,
set_text=filename,
fill=False)
@ -395,7 +425,7 @@ def draw(outlayer, win, name, x, y, width, height):
win.current["mdfs"][name] = win.text["markdown_name"]["text"]
UI_elements.roundrect(outlayer, win,
x+int(width)-50,
x+int(width)-150,
y+5,
40,
40,
@ -408,6 +438,41 @@ def draw(outlayer, win, name, x, y, width, height):
except:
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
# script writer. But rather simplified. For example we are not making an
# editor. But only a reader. So we don't need the selection. And we don't
@ -513,11 +578,7 @@ def draw(outlayer, win, name, x, y, width, height):
elif "image" in block[0]:
if newY:
current_Y = current_Y + newY + 40
tyleX = 10
newX = 10
newY = 0
# ICONS
@ -544,6 +605,12 @@ def draw(outlayer, win, name, x, y, width, height):
else:
if newY:
current_Y = current_Y + newY + 40
tyleX = 10
newX = 10
newY = 0
UI_elements. image(layer, win, block[2],
tyleX,
current_Y + win.scroll["markdown"]-15,
@ -555,10 +622,18 @@ def draw(outlayer, win, name, x, y, width, height):
imH = 40
imW = 40
bx = tyleX
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
@ -574,6 +649,7 @@ def draw(outlayer, win, name, x, y, width, height):
win.current["mdfs"]["failsafe"] = filename
win.current["mdfs"][name] = block[3]
win.current["current_help_selected"] = ""
win.scroll["markdown"] = 0
else:
oscalls.Open(block[3])
@ -602,8 +678,8 @@ def draw(outlayer, win, name, x, y, width, height):
# Full on image
UI_elements.roundrect(layer, win, tyleX-imW,
current_Y + win.scroll["markdown"]-15,imW, imH,10,
UI_elements.roundrect(layer, win, bx,
by + win.scroll["markdown"]-15,imW, imH,10,
button=do,
offset=[x,y],
tip=block[3],
@ -658,6 +734,7 @@ def draw(outlayer, win, name, x, y, width, height):
win.current["mdfs"]["failsafe"] = filename
win.current["mdfs"][name] = block[2]
win.current["current_help_selected"] = ""
win.scroll["markdown"] = 0
elif block[2].startswith("#"):
win.current["mdfs"][name] = win.current["mdfs"][name] + block[2]
win.current["current_help_selected"] = ""

View file

@ -164,28 +164,28 @@ def layer(win, call):
["Markdown", "LICENSE.md"],
],
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"]
],
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"]
],
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"):[
["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"):[
["scene", "https://notabug.org/jyamihud/VCStudio/wiki/Documenation+%7C+Analytics+%7C+Version+20.128"]
["Markdown", "wiki/docs/Analytics.md"],
],
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"]
],
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"]
],
talk.text("documentation_render"):[
@ -224,6 +224,7 @@ def layer(win, call):
def do():
win.text["in_help"]["text"] = ""
win.scroll["markdown"] = 0
if name != win.current["current_help_selected"]:
win.current["current_help_selected"] = name
else:
@ -270,15 +271,10 @@ def layer(win, call):
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["current_help_selected"] = ""
continue
@ -336,7 +332,7 @@ def layer(win, call):
# Report Bug Button
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,