30 lines
1.2 KiB
GDScript3
30 lines
1.2 KiB
GDScript3
|
extends Node
|
||
|
|
||
|
@onready
|
||
|
var core = get_node("/root/core")
|
||
|
var fsizes = {"text":"16","h1":"29","h2":"24","h3":"19","h4":"14","h5":"9","h6":"4"}
|
||
|
|
||
|
func parse(content:String) -> String:
|
||
|
var parse_text = ""
|
||
|
for line in content.split("\n",false):
|
||
|
var line_mod = line
|
||
|
if line_mod.begins_with("######"):
|
||
|
line_mod = line_mod.replace("######","[font_size=" + fsizes["h6"] + "]") + "[/font_size]"
|
||
|
elif line_mod.begins_with("#####"):
|
||
|
line_mod = line_mod.replace("#####","[font_size=" + fsizes["h5"] + "]") + "[/font_size]"
|
||
|
elif line_mod.begins_with("####"):
|
||
|
line_mod = line_mod.replace("####","[font_size=" + fsizes["h4"] + "]") + "[/font_size]"
|
||
|
elif line_mod.begins_with("###"):
|
||
|
line_mod = line_mod.replace("###","[font_size=" + fsizes["h3"] + "]") + "[/font_size]"
|
||
|
elif line_mod.begins_with("##"):
|
||
|
line_mod = line_mod.replace("##","[font_size=" + fsizes["h2"] + "]") + "[/font_size]"
|
||
|
elif line_mod.begins_with("#"):
|
||
|
line_mod = line_mod.replace("#","[font_size=" + fsizes["h1"] + "]") + "[/font_size]"
|
||
|
else:
|
||
|
line_mod = "[font_size=" + fsizes["text"] + "]" + line_mod + "[/font_size]"
|
||
|
parse_text = parse_text + line_mod + "\n"
|
||
|
return parse_text
|
||
|
|
||
|
func initialize() -> void:
|
||
|
core.setready()
|