daenvil / markdownlabel Goto Github PK
View Code? Open in Web Editor NEWA custom Godot node that extends RichTextLabel to use Markdown instead of BBCode.
License: MIT License
A custom Godot node that extends RichTextLabel to use Markdown instead of BBCode.
License: MIT License
Right now, some syntax elements are missing a way of setting some of their properties. For example, images have width
, height
, etc. BBCode has to be used to set those properties.
The attribute syntax described at CommonMark could be implemented to fix this.
For example:
![img](res://some-image.png){width=400 height=500}
The same could be used to set custom heading anchors, e.g.:
# Some heading {#some-custom-anchor}
This is not a priority since most sites that use markdown don't allow this syntax. It would just be a nice to have so we don't have to use BBCode inside Markdown for things like this.
Override the text
property setter so it modifies the markdown_text
property instead of the inherited text
property.
This would make the usage consistent with the other label nodes, as with both Label and RichTextLabel you do label.text = "something"
, while this is useless in MarkdownLabel, where you currently need to do label.markdown_text = "something"
.
This would make the usage clearer, and the inspector interface cleaner.
Tried this code as shown in Godot proposal #1056 but it is not working for some reason:
func _validate_property(property: Dictionary):
if property.name in ["bbcode_enabled", "text"]:
property.usage = PROPERTY_USAGE_NO_EDITOR
Right now unhandled links default to being used as "https://" + meta
and instead I think there should be emitted as a signal so another script can listen for the link click
The use for this would be for maybe having a different script load something, or showing a tooltip. Just a way to have a different script listen for a click and then responding to it.
Here's a rough example:
# a new signal for handling unhandled links
signal unhandled_link(meta)
@export var automatic_links := true
# new toggle for the signal option
@export var emit_signal_for_unhandled_links := true;
func _on_meta_clicked(meta: Variant) -> void:
if not automatic_links:
return
# ... same as before ...
if emit_signal_for_unhandled_links:
unhandled_link.emit(meta)
else:
# original implementation
OS.shell_open("https://" + meta)
This would allow for link click logic to be handled by a different class, for example one that shows like... a tooltip, or shows a different page.
You could also use a non Markdown custom handler. For example I initially used f^
to denote a desire to call a function
[Hello Click Me!](f^ShowAlert)
signal link_signal(meta)
func _on_meta_clicked(meta: Variant) -> void:
if meta.begins_with("f^"):
link_signal.emit(meta)
Just an idea I had after using it for a bit
Display checkboxes when parsing [] and [x].
It should also provide a signal when the state changes.
Update the docs with the additions of #8.
Hello!
I was wondering how hard it would be for me to add my own custom syntax? Such as;
?[variableToQuery](Text to display if the variable is true, or that the function that takes that string and looks it up in a dictionary of tags.)
I suspect that I would need to fork, and edit somewhere in this space? :(
# Images
var img_pattern := "\\!\\[(.*?)\\]\\((.*?)\\)"
Im just looking around for methods to create variable text without creating a parser from scratch myself ๐
Many thanks - Gene
I think it could be possible using RichTextLabel.scroll_to_line()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.