Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Editor

Notices

Reply
 
Thread Tools Search this Thread
Old 10-27-2023, 01:57 PM   #16
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 74,015
Karma: 129333114
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by Tex2002ans View Post
DiapDealers's fantastic plugins can already do this:
How do you use Diap's Editing Toolbag for calibre to deal with dashes?

I want to replace all en-dashes with and without spaces to en-dashes without spaces. Also, I want all em-dashes with spaces to be em-dashes without spaces.
JSWolf is offline   Reply With Quote
Old 10-27-2023, 06:02 PM   #17
Tex2002ans
Wizard
Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.
 
Posts: 2,297
Karma: 12126329
Join Date: Jul 2012
Device: Kobo Forma, Nook
Quote:
Originally Posted by JSWolf View Post
How do you use Diap's Editing Toolbag for calibre to deal with dashes?
I personally don't. I always have it on the setting:
  • Do not educate dashes

I only use Diap's Editing Toolbag for smartening quotation marks.

Quote:
Originally Posted by JSWolf View Post
I want to replace all en-dashes with and without spaces to en-dashes without spaces. Also, I want all em-dashes with spaces to be em-dashes without spaces.
Then use a Regular Expressions + Saved Searches:

Regex #3: SPACE + EN DASH + SPACE -> No-space EM DASH
  • Find: ( )–( )
  • Replace: \1—\2

or various mixes of \s or whatever types of spaces you're trying to find/fix.

- - -

Personally, if I was adjusting those dashes, I'd:
  • Use Diap's Editing Toolbag once...
  • Then take a very close look at all the diffs, making sure it got all correct.

I don't believe it's a very smart idea to mass change "spaced dashes" like this without verification (or deciding on a case-by-case basis), because you don't know what sort of madness might be inside the book.

I've seen too many cases of:
  • THIN SPACES
    • This is a small – very small – example of text.
    • This is a small — very small — example of text.
  • HAIR SPACES
    • This is a small – very small – example of text.
    • This is a small — very small — example of text.

or all sorts of weird spacing mixed around the dashes too.

Again, see the 2022 topic: "False paragraph breaks & RegEx" where I went into all the edge-case details. (Like em dashes signifying "cut off" dialogue.)

- - -

Side Note: I've even seen the (definitely wrong):
  • single HYPHENs
    • This is a small - very small - example of text.
    • This is a small-very small-example of text.

This is why it all has to be on a book-by-book, case-by-case basis. Trying to mass change this type of stuff isn't smart without looking through the text first.

Luckily, every book I work with uses and enforces the proper EM DASH with no spaces around it. And I don't have to worry about the quotation dashes or anything like that. Makes it much easier on my end.

- - -

Side Note #2: Personally, this is what I use. 3 sets of Regex:

Regex #1: Remove spaces from EM DASH
  • Search: [ ]*—[ ]*
  • Replace:

Regex #2: Inserting EN DASH
  • Search: ([0-9])-([0-9])
  • Replace: \1–\2

Regex #3: Converting to EN DASH (Accidental EM DASH)
  • Search: ([0-9])—([0-9])
  • Replace: \1–\2

I run:
  • Regex #1 once.
  • Regex #2 and #3 one-at-a-time, and go through the book on a case-by-case basis.
    • You have to be really careful, because URLs especially have lots of numbers+hyphens inside.

Before:

Code:
<p>This is a small— very small — example of text.</p>
<p>The 2000-2010 period was the root cause.</p>
<p>See pp. 5—9.</p>
After:

Code:
<p>This is a small—very small—example of text.</p>
<p>The 2000–2010 period was the root cause.</p>
<p>See pp. 5–9.</p>
That takes care of the bulk of dash mistakes/inconsistencies/"OCR errors" I see.

Last edited by Tex2002ans; 10-28-2023 at 03:39 AM.
Tex2002ans is offline   Reply With Quote
Advert
Old 11-09-2023, 01:09 PM   #18
Noirtier
Member
Noirtier began at the beginning.
 
Posts: 17
Karma: 10
Join Date: Jan 2021
Device: Kobo Forma
Quote:
Originally Posted by Tex2002ans View Post
Then you will want to create 2 Regular Expressions...
That's a useful approach thanks. I was previously thinking I would have to do it in two separate steps, first to deal with the ones with spaces, and then any remaining without.

It also occurred to me that where I most need this feature is for fixing up book descriptions ("Comments" metadata) in Calibre. It would be great if a smarten punctuation button could be added to the formatting toolbar for that. But in the meantime I typically copy and paste the text into Notepad++ for editing where I can make use of regex replacements if desired.

Quote:
Originally Posted by Tex2002ans View Post
..the "Saved Searches" feature...
I hadn't come across that editing option in Sigil nor Calibre before so great to learn about too thank you
Noirtier is offline   Reply With Quote
Reply

Tags
dashes, edit, polish, polishing, smarten punctuation


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Smarten Punctuation hiteshp Calibre 4 06-13-2021 02:15 AM
Smarten punctuation crutledge Editor 7 04-26-2014 02:02 AM
Smarten punctuation only? Psymon Conversion 3 10-20-2013 09:28 AM
Simpler Way to Smarten Punctuation Rand Brittain Calibre 3 10-10-2010 08:16 PM
Thanks for new 'Smarten Punctuation' feature jackie_w Calibre 1 09-21-2010 02:53 PM


All times are GMT -4. The time now is 11:23 AM.


MobileRead.com is a privately owned, operated and funded community.