Parseing text (within paragraphs, withing text frames)

Previous topic - Next topic


I wish parse all the text within a Scribus document. I assume that I will have to traverse the pages, the text frames within the page, the paragraphs within the text frames, the characters within the paragraph.
I would then like to apply UI defined character styles to selected chunks of characters within each paragraph. The documents are books of plays with a few hundred pages.

FYI. I maintained compilers for 20 years and have nearly 100,000 lines of Python code, some of which relate to special purpose compilers for microprocessors.

I am trying to overcome the lack of character style importing from ODT. I can detect, by character syntax, the presence of stage directions, lighting tech notes, and sound tech notes, which must be cast to specific character styles within paragraphs with "dialog" style attached.

I notice that the SLA files are just XML. Maybe I should do this outside of Scribus?

Greg P

As a starting point, you might have a look at Autoquote, one of the scripts included with Scribus, and also on the wiki

Both of these scan a text frame at the atomic level, character by character, so one could go from there to match some string.
You can then use the setStyle() command to apply your style to selected text.

I have to say though that I don't know if Scripter is the way to go. From Story Editor, there is a Search/Replace function under Edit, which will search for a string and allow you to replace with altered text or style.


I need to do a very similar task, the difference being that I'm not a python expert.
I was excited about the search/replace suggestion, but I don't think it will work for my purposes.
First of all, it doesn't appear to support regular expressions. I need to match the characters "<<" and ">>" and all the text in between.
Secondly, I'm trying to change the selected characters to italics. This would require a character style rather than a paragraph style. The latter would set my entire paragraph to italics, which I don't want to do.
Is my conclusion correct, or is there some feature I've missed?