UI TextView Individual Words
I am creating an app with Pythonista that lets you write Markdown, and preview it in a built-in browser, or in Safari. But I have been using Editorial for quite some time now, and it has the ability to (in the editor) show bolded text for individual words automatically while typing, even before previewing you get a basic idea of what it'll look like.
I want to do something similar in my app, with Pythonista. While typing the Markdown in the editor (which is a TextView), I want to automatically change fonts and sizes of individual characters and words, not the whole TextView's overall font and size.
Does this make sense to anyone? If so, please help me out here. I've tried a few ways to do this, but so far I am thinking it is not currently possible with Pythonista.
It can be done with objc, but this is not trivial, and prone to crashing if you are not careful. in objc this is called attributed text.
See the few files starting with attrib in
for some simple examples.
ywangd implemented a very stable and robust implementation of ANSI color codes in stash.
What i would suggest is that instead of using a TextView, use a WebView. Since there are markdown to html converters readily available, it will be easier for you to understand and ultimately implement -- objc in python is not for the faint of heart.
😕 alright. Thanks for the information.
If you cannot get the text coloring to work, you might take a look at MarkdownView - the main goal there was to make the distance between viewing the HTML and editing in markdown as short as possible. And the additional markdown editing keys could be useful as well, even if you make your own editor.
@JonB thanks for the help. I will definitely check that out!