View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0017360 | Scribus | Scripter | public | 2025-01-01 11:00 | 2025-02-25 16:18 |
Reporter | ale | Assigned To | |||
Priority | normal | Severity | minor | Reproducibility | N/A |
Status | new | Resolution | open | ||
Product Version | 1.7.0.svn | ||||
Summary | 0017360: deprecate insertHtmlText() and replace it by one or several "better" functions with better arguments | ||||
Description | currently, insertHtmlText(): - can only insert content from files and not from strings - does not default to utf-8 as encoding - does not provide a way to set the encoding (and it's not clearly defined how the encoding is detected) - can insert content from any supported file format (i've tested it with a markdown file) - the type of the content depends on the extension of the file - in the UI the corresponding function is found under "import" and "get text", not "insert". i'd like to suggest to deprecate this function. in place of it, i'd like to propose a new function with several named optional arguments: insertFormattedText( source: the filename (path) or the content to be inserted [name=None]: the name of the target frame (by default the current selected frame) [encoding=None]: if not defined, the encoding is automatically detected from the content (if possible; the default should be utf-8) [format=None]: if not defined the format is guessed from the extension (default behavior is '.txt') [read_file=True]: if true, the source is a filename; otherwise, source contains the content to be inserted [style_prefix=None]: if None, the name of the frame is used; ) this having been said, if i recall correctly, some of the formats supported by scribus have a pop up asking for more settings. i still have to check if those differ between formats: if it's the case, it might be better to have one function per format... (if we need multiple functions, we might keep insertHtmlText() and complete it with the additional arguments) | ||||
Tags | No tags attached. | ||||
Patch | No | ||||
|
IIUC it is just calling `gt.launchImporter', see https://github.com/scribusproject/scribus/blob/b2420e8808a525af5db5ec1ee4a33e0d75f3a7c8/scribus/plugins/scriptplugin/cmdtext.cpp#L669 . Note, my C++ knowledge is limited. However, I imported an ODT file with para/char styles and everything was nicely imported! So, it seems to me s/importHtmlText/importTextFile/ is good enough :-) |
|
Since it is not exclusively about HTML, IMO it is a kind of bug and a quick solution would be to create a new function name to end this confusion. |
|
yes it imports anything, but, as an example, you cannot import from a temporary file, if that file has not the "correct" extension. and if you already have a string -- as an example to make it simple to insert formatted text by using some inline html --, the only way to insert it, is by using a temporary file... also, 99% of the files inserted will be utf-8... but there is no way to force the import to use that (and, as wrote above, it's not clear to me, how the encoding is detected). finally, nice that in your example it worked well. in the case i had to solve, it was not that way. i don't recall the details, but it was a simple generated text that needed to be imported into scribus and i had to go through multiple hops to get the text into scribus. it was rather painful. |
Date Modified | Username | Field | Change |
---|---|---|---|
2025-01-01 11:00 | ale | New Issue | |
2025-01-01 11:51 | ale | Summary | deprecate insertHtmlText() and replace it by one or several "better" functions with a => deprecate insertHtmlText() and replace it by one or several "better" functions with better arguments |
2025-02-24 23:04 | jirib | Note Added: 0052118 | |
2025-02-24 23:05 | jirib | Note Added: 0052119 | |
2025-02-25 16:18 | ale | Note Added: 0052122 |