I scan documents using the OCR feature in iOS 15 and use a simple mail action afterwards. How do I remove all line breaks before sending the text?
Thanks!
I scan documents using the OCR feature in iOS 15 and use a simple mail action afterwards. How do I remove all line breaks before sending the text?
Thanks!
There are a number of example actions for removing line breaks in the Directory. The Strip Line Feeds one works on the text selection, if you search there are a few others as well.
Is there anything that will remove line breaks but preserve paragraph breaks?
A line break is indicated by a new line character. How would you define a âparagraph breakâ? Two successive new lines, two or more successive new lines, or something else?
Iâve bumped Strip Line Feeds to the top of my first action group. Itâs very useful. Using copy-paste the IOS OCR feature interprets both the visual end of a text line and a paragraph as a line break (single new line character).
The last line of text in a paragraph that breaks /n
on the page./n
And a new paragraph starts but again only with a single line break. /n
So it doesnât seem possible to parse say two new line characters as a paragraph?
Do you mean the action you are using doesnât do this rather than it not being possible? I donât see why an action couldnât search for a new line not immediately followed or preceded by a second one and replace it with a ânullâ string to remove single newline characters.
I think the problem is that the OCRâd text (using the iOS OCR method in iOS 15) places a single newline character both within a paragraph and at the end of a paragraph. There are no double newline characters.
Ah, thanks. So the point is that itâs the Apple OCR thatâs not distinguishing line spacing correctly and making what would be a paragraph spacing I distinguishable from a soft wrap - which the OCR would rightly read as a new line as it is not analysing the text for context.
Yes, I think that is correct. I went to the Apple Feedback site and submitted a bug report for the Camera app.
When I use the step Include Action and set it to Strip Line Feed, nothing happens when using this action this way (no line breaks removed). How do I integrate it properly in my workflow?
Thanks!
That depends on what your starting with, and your action you are including in. The include step would often be sufficient to incorporate into another action, but really you need to share that and some sample text to provide a clear idea of what you have.
So sorry for the slow response. Yes, I would say a âparagraphâ break is two line breaks. I suppose it could be two or more as well.
To remove singular line breaks (ones that are not followed by one or more other line breaks) in the content of the current draft, the following two lines can be added to a script step in an action. The first line does a substitution using a regular expression match, and the second line saves the update.
draft.content = draft.content.replace(/([^\n])\n([^\n])/gm,"$1$2");
draft.update();
Hope that helps.
It works perfectly! Thank you! This is going to save a lot of time and tedious work.
Is that available as an Action in the directory?
I had not uploaded it as it was proposed to include as part of an action. But here you go, and do please consider subscribing to Drafts so you can create your own actions, as well as get access to the pro features.