Working Example of styledtext or markdown

Does anyone have any unicode working example of either styledtext or markdown that shows how to parse text and then save it? I’ve spent several hours looking for some this morning and haven’t come up with a complete one that I don’t have to debug.

be more specific…
Are you talking about intaking a file containing HTML, RTF or some other style and then doing what with it?
or are you talking about parsing the contents of the StyledText in a TextArea (if so, read about styleruns)

I am really interested in the parsing of any format that can be used with a textarea. I know they handle rtf and other formats. What I’m also interested in is a working example of reading and writing and how it handles it. If you know of a complete current example that works with styleruns, that is even better.

when you have better explanation, perhaps I can help… but you are being way to vague.
Here you are attempting to play the part of the “Business Analyst” trying to describe the “problem” to the “developer” (this forum), but your “functional specifications” are inadequate

and if you wish to learn about style runs… the is plenty of information in the Xojo supplied documents.

I’m really looking for something that works

Great… but you have not explained what “WORKS” is…

If you explained what you want to achieve exactly ?

Have-you read this: RTFData ?

That said, the most important line there is:
The RTF parser supports only the features found in the StyledText class.

There is no built-in function for:
have an image in your rtf
rules
save pasted rtf from outside of the Xojo build application.

Between others.

That is why people above ask you what you want to do.

Edit:
I forgot to ask: have you done a search in this forum about RTF ?

In my start I wrote I had tried several examples. They either aren’t able to do a simple run in the debugger without getting errors or if they do they they aren’t complete. They don’t do something simple like read and write. I know how to open or close a stream, but only with straight text. I don’t know what structures (tables or arrays or whatever) that I have to concatenate into an rtf or whatever file.

Because it is not that way to do it.

Let me say it differently. The example projects that come with XOJO don’t work

ok… I’m sorry, but I have to put this topic on ignore… we are going around in circles, and to me that is a waste of time. Hopefully the poster will realize this, and post a legit questions… until then… good luck!

This is a working code only if you set the TextArea (TA below) Styled to TRUE in the IDE:

[code]// Open a rtf file
Dim RAWFI As FolderItem
Dim RAWTIS As TextInputStream

RAWFI = GetOpenFolderItem("")
RAWTIS = TextInputStream.Open(RAWFI)
TA.StyledText.RTFData = RAWTIS.ReadAll
RAWTIS.Close[/code]

Edit: a minima code; used to show how to Openan RTF file. Errors can occure in real life usage (use try end try…)
There is a save TextEdit to RTF example inthedocumentation.

Edit 2: if you do not set the TextArea (TA below) Styled to TRUE in the IDE, you will get a crash in the Debugger at run time…

Edit 3: not tested save RTF to file

Dim f As FolderItem = GetSaveFolderItem(TextTypes.TextRtf, "TestSaveRTF") If f <> Nil Then Dim s As TextOutputStream = TextOutputStream.Create(f) s.Write(TextArea1.StyledText.RTFData) End If

Only Styled and plain text
No “other formats” like markdown html etc

Arthur, unless you grab yourself and really try to make sense, you will get nowhere fast.
Last week I posted code to load RTF here : Show RTF File content with formatting on Text Area - macOS - Xojo Programming Forum

I strongly suggest you read it, as well as
http://documentation.xojo.com/index.php/StyledText.RTFData The example there shows how to save RTF.

http://documentation.xojo.com/index.php/StyledText
http://documentation.xojo.com/index.php/TextOutputStream
http://documentation.xojo.com/index.php/TextInputStream

Do your homework, and once you know a bit more about what is available, you will feel more comfortable.

Remember: the Styled property HAVE to be set to TRUE in the IDE and the MultiLine property have to be set to ON.

If you do not do that to your TextArea, any attempt to load a rtf file will fail (StyledText is Nil…).

This is in the documentation for TextArea.

I can see why I frustrated so many people. In my initial post I didn’t mention that the word code or program but simply text. I really meant an example program that I could look at the code.

I keep forgetting that XOJO is alot different from RealBasic. It can now read in styled text into a textarea and properly display it without much work from the programmer, I think. I don’t have a need for that as there are usually programs that will do that.

This is an example of the text I made:
?? ?? (???) mustache (???) ?beard? (???) sideburns, (Brit) sideboards (?? ??) goatee (???·? ??) ?whiskers?¶??? ??? grow a mustache[beard]¶??? ??? stroke one’s beard¶??? ?? shave (oneself); shave one’s face; have a shave¶?? ??? ??? ?? He is growing a beard.¶?? ? ??? Please shave. You need to shave.¶?? ??? ?? ??? ???. My facial hair[beard] tends to grow fast. Noun; Body Part 18 4 2011-10-14

A line of text that I work with has 12 fields. It is a Tab-delimited file and the ¶ serve as line-breaks. The pair ? ? of harpoons serve as keyword indicators to the program that characters (words or sentences) in between are to be made bold and underlined. My problem is those harpoon characters are shrunk to a single character point and it impacts the text that follows. The harpoons are still often underlined. It would be nice if I had a different way of reading and writing keywords.

The keyword text that I currently can make bold is ?whiskers? and it would show up as whiskers underlined. but I also want to be able to pull out the word “beard” and “goatee” in a similar way. In some cases I’d like even more keywords. So, I need to include in my text ways to separate out those words and then treat them as styled text.

What I really want to know is better ways to handle reading in and saving specifically several keywords and give them attributes of some text such as Bold or colored text. The information (html version ) is saved in a .txt or .rtf or .md or .html file but it probably goes in code to some kind of table or list, but I have no idea where. I need this because I want to be able to have in one line of text several synonyms, and be able to pull them out programmatically.

That is the reason why I want to know how to turn .html .xml .rtf into styled text. That is why I’m looking ways to parse out this data.
I noticed the book XML with XOJO by Dakin, but I don’t know if that will work for this.
Suggestions?

You can store text using xml and reload it.

Storing styleslike Bold, Italic, in xml, html,jason or what formated you can conceived text is not as easy as to store styled text in rtf.

Some answers people gave to you holds the answer.

You can either select programatically the word selstart and length, then apply a Style (Bold, Italic, )a color, a Font (TextFont) a size (textSize), etc.

The description of all of these and much more is here : search in the Properties: SelXxxx. You can also search for StyleRun, etc.

Edit: Before I forgot… excepted rtf, all of these are available in REALbasic, then Real Studio…

Arthur:

did you real the pdf book: “Introduction to Programming with Xojo.pdf” ?

If no, you can reach important information on pages starting at 155 and following. Maybe.

The section name is “9.7 Hands On With Files”, the shared example name is “StyledTextEditor.xojo_binary_project”.

Also, read the information here and here .

parse the original text in a database (sqlite) with one field per language.
then generate the text the way you want, the style you want, for each choosen word
you could also show the words in a listbox. the styledtext is not mandatory.