Objective: Display of moderately-formatted help text, or other instructional text. You’re reading a positive example right now.
Should handle
relative font sizing (for titles and headings)
bold, italic, underline
proportional and monospaced fonts
superscript and subscript (e.g., for minor math effects)
numbered and unnumbered lists
word wrap
Raw format may be a subset of XHTML, XML, Markdown, ReStructuredText (such as used to build Python’s documentation), etc… Strictly limited, for good security and performance.
While this could be done, in principle, via a Canvas, that would require a fair bit of code, to respect margins et al. It would probably be better to translate into HTML, thus leveraging the browser’s built-in display features.
I think it’d be awesome to just have some component that lets me insert actual HTML. I know that’s a big escape hatch to have right in the toolbox, but I’m not really sure how I should do <p>Hello <b>World</b></p> in Anvil right now, let alone something like colouring certain letters in a string (in HTML I’d just do <span style='color:red'> or whatever).
Thank you immensely! I hope to look closer at this later.
A long time ago I had plans to use ReStructured Text. It made sense to me, since an RST-to-HTML converter, docutils, is already available on the server, and RST is Python’s standard for documentation.
Eventually, RST’s extension mechanism could be leveraged for specifying data-entry widgets, e.g., for direct insertion into the running text. Does Markdown have such a mechanism?
You’re right, direct insertion of HTML is a potential minefield. This is why I think that using a markup language is on the right track. Even if malformed, it can still be displayed as-is, and still look semi-reasonable.
I just did a test for a project I’m working on, and if you put the mistune.py file from https://github.com/lepture/mistune into a server module running Python 3, you can use it from other server modules to convert Markdown to HTML.
I have a custom HTML form whose HTML property is set to the result of that conversion, and then that custom form gets embedded into another form so that the Markdown result is only part of the final form that gets displayed.
It’d be nice if a Markdown library were added to the available server modules, but until then this is a way to do the conversion for display purposes.
mistune.py will not run in the client due to its reliance on the inspect module, which isn’t available in Skulpt.
We’ve just installed mistune in the Server Module environment. So you can now convert Markdown to HTML without needing to copy-paste the mistune module into Anvil.
I’ve since switched to using BBCode, which worked better for customizing for my app. Can we also get the BBCode module installed on the server? https://pypi.org/project/bbcode/
to enact the highlighting. Obviously you could wrap this in a JavaScript function and call_js every time you want to refresh the highlighting. So in my Skulpt example, you could put the code in an Anvil TextArea (instead of an HTML textarea) and call_js to the highlighting function from the change event handler.
Something changed and this is no longer able to read the html contents from the rich text editor. If you open the clone link you can see what happens. The error returned is:
ExternalError: ReferenceError: WrappedPythonValue is not defined at [email_drafter, line 15]
I noticed this because in my real project which I use the text editor, it suddenly stopped working. It used to work and nothing changed in the clone link, so do you think this a jquery issue, an anvil issue, or a quill issue?