4

I'm trying to edit some xhtml on Sigil.

With the command "<p>([a-z]) I'm able to find all paragraphs that begin with lower case. That tells me that they shouldn't be separate from the previous one. It's just a conversion issue.

What should I do to delete both the < p> from that paragraph and the </p> from the previous one in order to join the two blocks of text into one single paragraph??

It looks something like this:

<p> ... that is why relationships</p>

<p> are not what they should be.

And it should be:

<p> that is why relationships are not what they should be.</p>
  • I miss Sigil. I wish it were still being developed. – Paulb Sep 26 '15 at 12:34
  • Sigil is being developed. The latest pre-release has some bugs, though.. – Nemo XXX Oct 2 '15 at 5:41
  • What OS are you running Sigil on? Windows? – Bulrush Jun 28 '16 at 14:37
  • What OS are you running Sigil on? Windows? All of them. :-) However, it doesn't really matter, because it works the same on all of them. – Nemo XXX Jun 29 '16 at 21:10
3

The following regex should cover most cases.

Find:

([[:lower:]],*;*:*)</p>\s+<p[^>]*>\s*([[:lower:]])

Replace:

\1 \2
1

Sigil's regex engine is kind of fussy; I'm not sure that the anonymous answer above would work.

I answered this on Quora, but I'll post the answer again here, because it seems like that would be helpful:

Ah. Let me guess. You're converting from a PDF. You have my sympathy. :-)

I've done this. Here's the search expression I used:

([a-z]|,|;)</p>\s+<p>

That found paragraphs that ended without a period, exclamation point, question mark, or right double quotes. (Since I'm assuming you're working from a PDF of a print document, I didn't include in the query all of the other possible marks, since, for instance, a left double quotation mark is extremely unlikely to come at the end of a text line.)

The replace expression was simply this:

\1 

Note that there's a space after the wildcard, so that you don't end up smooshing words together.

That should get rid of the unwanted paragraph breaks and splice your text together properly.

Unfortunately, if you've got letters reproduced in the book or some other text format that has paragraphs ending in commas, semicolons, or lower case letters, you'll have to do Replace/Find and go case by case rather than Replace All.

  • Sigil's regex engine is kind of fussy Sigil uses PCRE, which is pretty much the best RE engine there is. I'm not sure that the anonymous answer above would work. If you were referrring to my suggestion, it does work and unlike your suggestion will only merge broken paragraphs if the next paragraph starts with lower case character. – Nemo XXX Oct 2 '15 at 5:45
0

This worked and you can play with it if you want. Please copy it before changing it. https://regex101.com/r/gO0zG0/1.

A regex replace is like this in Perl: $s=~s/OLDPATTERN/NEWPATTERN/g;

The regex was: /<\/p>\n\n<p>//g;

Replace the first part between the first two // with nothing. The \n SHOULD be properly initialized by the regex engine for your operating system (you shouldn't have to do a thing), because it has different values for different OSes. But if that \n doesn't work, please let me know. You might have to try \l\r or \r\l.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.