Assign a formatted text to a text frame

Previous topic - Next topic

Alcantara

Hello.

In a Python script, I need to insert variable text with complex formatting into a text frame. The text may be something like:

Lorem ipsum <bold>dolor sit</bold> amet, consectetur
adipiscing <italic>elit, sed do eiusmod</italic> tempor
incididunt ut labore et dolore <small>magna aliqua</small>.
Ut enim ad minim veniam, quis nostrud exercitation

I added the text formatting in angle brackets.

The problem is that I don't know in advance which parts of the text should be in bold or italics, so I can't select individual pieces of text to assign formatting to them.

I see in the online help that I can assign an HTML file to a text frame with "scribus.insertHTMLText()".

Is there a way to assign a string containing HTML formatting to a text frame instead of a file?

Tro.

For about two weeks, I have been trying to use the "scribus.insertHTMLText()" function to import HTML text. So far, I have not been able to import it.

The documentation in the Scribus API is incomplete. Depending on the level of detail in the query, the chatGPT query leads to widely varying answers. In any case, the answer is characterized by incorrect statements (mixed-up arguments, invented statements) that contradict the information in the Scribus API.

This means that there are no references to the use of this function on the internet.

When I ask very specifically about the functionality of "scribus.insertHTMLText()", ChatGPT says: "Important: Unfortunately, the documentation on this is very sparse, and there is no official list of which style names Scribus uses or expects internally for <b>, <u>, and others..."

This means that the function "scribus.insertHTMLText()" is half-finished or not functional, and in any case, there is not enough documentation for it to be used.

I am considering contacting the developers.

Yesterday, I managed to achieve differentiated character formatting with "scribus.insertHTMLText()". The formatting does not meet expectations. I don't have any more time available at the moment to try further.

Perhaps we could contact the developers together?

Lynn

If you want to know what issues other people have been having with a function in Scribus and whether the developers have been informed, I recommend searching on the bug tracker. I do not think ChatGPT has crawled the Scribus bug tracker, and even if it had, going to the source is going to be faster.

You can find the bug tracker at https://bugs.scribus.net/view_all_bug_page.php and search by entering your search text in the box next to "apply filter". Then click Apply Filter.

Looking it up, I can see that the insertHTML function was added to the scripter in 2012 when a volunteer wrote it up for scripts they were personally using: https://bugs.scribus.net/view.php?id=11104

At least one other person had issues with html formatting not importing correctly, but never followed up on the bug to provide additional information or documentation so it didn't get follow-up: https://bugs.scribus.net/view.php?id=17380

And a.l.e. filed a bug suggesting the function be replaced last year on the basis of confusing documentation and inability to import text without putting it in a separate file: https://bugs.scribus.net/view.php?id=17360

There were a few other bugs you could read through but those seemed the most relevant. At this point the only way to run the function is on a file, so if you need to import html text it needs to be saved as a file during the run of your script. If you're doing that and it's not bringing in the correct formatting, I'd add a comment to the second bug on that list.