Scribus > Beginner Talk

Replace carriage returns with blank spaces

(1/2) > >>

ClaraMontseny:
Hello everyone,

I copied a pdf text into my scribus file so it has a lot of carriage returns. I want to replace those carriage returns with blank spaces. Normally, when I use InDesign I make use of GREP. I have explored the 'Search/Replace' settings but I see no options for what I need. Can anyone help me? Thank you very much!

JavierSam:
Hello everyone.
I am in a similar situation to Clara.
Does anyone know of a way to solve it?

JavierSam:
ok, I just found a possible solution using a script.
It is based on this one:
https://wiki.scribus.net/canvas/Clean-up_the_imported_text_based_on_the_Slovak_typographic_rules
with a small modification.
Copy the following code and save it as a .PY file.
Then run the script from Scribus with the selected text frame.

--- Code: ---#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""

adapted from
https://wiki.scribus.net/canvas/Clean-up_the_imported_text_based_on_the_Slovak_typographic_rules

"""

import sys
import re

try:
    import scribus
except ImportError,err:
    print 'This Python script is written for the Scribus scripting interface. It can only be run from within Scribus.'
    sys.exit(1)

if not scribus.haveDoc():
    scribus.messageBox('Warning', 'You should open a document.', scribus.ICON_WARNING, scribus.BUTTON_OK)
    sys.exit(1)
if scribus.selectionCount() == 0:
    scribus.messageBox('Warning', 'You should select a text frame.', scribus.ICON_WARNING, scribus.BUTTON_OK)
    sys.exit(1)
if scribus.selectionCount() > 1:
    scribus.messageBox('Warning', 'You should select one text frame.', scribus.ICON_WARNING, scribus.BUTTON_OK)
    sys.exit(1)

replacements = (
    # double carriage return to carriage return
    (u'\u000d'+u'\u000d'+r'+',u'\u000d'),
)

d = scribus.getSelectedObject()

if scribus.getObjectType(d) != 'TextFrame':
    scribus.messageBox('Warning', 'You should select a text frame.', scribus.ICON_WARNING, scribus.BUTTON_OK)
    sys.exit(1)
else:
    for item in replacements:
        content = unicode(scribus.getAllText(d))
        p = re.compile(item[0])
        r = re.finditer(p, content)
        for i in reversed(tuple(r)):
            count = i.end()-i.start()
            scribus.selectText(i.start(), count, d)
            scribus.deleteText(d)
            scribus.insertText(item[1], i.start(), d)
    scribus.setRedraw(True)
    scribus.docChanged(True)
    scribus.messageBox('Info', 'Script finished successfully.', scribus.ICON_INFORMATION, scribus.BUTTON_OK)

--- End code ---

Engineering_text:
Not what the original poster was asking for, but there is another work around for those not wanting to run a script might be helpful here. I cut and pasted the pdf text into a word processor, then saved the file in an old word doc format -which Scribus can import- and the extra carriage returns were removed. I happen to use home version of Word Perfect, but for the Linux world there are a variety of free word processors.

You probably know this already, but many word processors also allow for making all the tab and carriage returns visible characters so that you can run "find and replace" to get rid of extra spaces, tabs, and carriage returns. To the extent I can, I like to do all the writing and story editing (grammar, spelling, revisions, etc.)  in a word processor, then pull that into Scribus.

utnik:
hi all

'search and replace' works in scribus, but you can't insert the carriage return direct in the search field. you need to copy it from your text and paste it into the search field. (you won't see see it either - but it works…)

utnik

Navigation

[0] Message Index

[#] Next page

Go to full version