Register Guidelines E-Books Search Today's Posts Mark Forums Read

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

Notices

Reply
 
Thread Tools Search this Thread
Old 10-27-2023, 02: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: 76,446
Karma: 136564696
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, 07: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,304
Karma: 12587727
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 04:39 AM.
Tex2002ans is offline   Reply With Quote
Advert
Old 11-09-2023, 02: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

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

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


All times are GMT -4. The time now is 02:38 AM.


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