YWriter 5 eating emdashes

186 views
Skip to first unread message

sharni ward

unread,
Apr 17, 2018, 5:46:09 PM4/17/18
to yWriter
Hi again,

So I've just noticed something that may or may not be a sticking point for me when it comes to using yWriter. I use emdashes frequently in dialogue in a variety of situations that require it to be somewhat choppy. But yWriter is turning them into single hyphens and I can't just do a blanket replace of hyphens to turn them all into emdashes because there are words linked with hyphens (particularly descriptive phrases and written numbers) that would not look or sound right with emdashes in them (I've set my screen-reader to pause in a specific way for emdashes, which is how I noticed this to begin with).

Is there a way to fix this? I really don't want to drop a program that might just help me get this story out of my brain and ready for publishing after twelve years of gestation and procrastination, but I need the emdashes to remain emdashes...

Dain Unicorn

unread,
Apr 17, 2018, 6:01:05 PM4/17/18
to ywr...@googlegroups.com
Silly question....

Are you sure the em dash (a double hyphen) isn’t being converted to a Unicode Emdash (single character version)

Have you looked for ‘text transformations’ or ‘auto-replace’ settings for that?   It’s a common thing, along with transforming three periods into the single character ellipsis…

Sent from my iPhone
--
You received this message because you are subscribed to the Google Groups "yWriter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ywriter+u...@googlegroups.com.
To post to this group, send email to ywr...@googlegroups.com.
Visit this group at https://groups.google.com/group/ywriter.
For more options, visit https://groups.google.com/d/optout.

sharni ward

unread,
Apr 17, 2018, 6:12:18 PM4/17/18
to yWriter
I know how to make the single-character emdash (hold down alt and then press numpad 0, 1, 5, 1 and release the alt key), so I don't type it by pressing hyphen twice. When I noticed the lack of a pause when reading back the scene, I checked by moving character by character with my arrow keys. NVDA announces when an emdash is present, and calls a hyphen just "dash" when the cursor moves over the character. I know exactly what I'm talking about here. Also, I tested this by opening the editor for the scene in which I noticed this and re-inserting an emdash where one was supposed to be. When I saved and exited and read over the scene again, however, it had turned back into a single dash.

Henry Boleszny

unread,
Apr 17, 2018, 7:02:26 PM4/17/18
to ywr...@googlegroups.com

Hi Sharni,

 

I’ve noticed that yWriter tends to remove characters it doesn’t understand.  Emdash is a normal punctuation mark, but it’s outside the normal definitions for this program.  It’s possible to add them to the Editor settings, however. 

 

Have you tried this?

  1. Open a scene
  2. Settings -> Autobackups and Punctuation
  3. This opens up a new window with three tabs.  Select “Other”
  4. The top row is for punctuation marks, where you can add those things like a German umlaut and French surd (or however it’s spelled) if you need them.  Emdash isn’t in there, but you could add it. 

 

If you use two hyphens together in yWriter, it will become the correct punctuation mark when you do a final edit in Word or some other editing program.  This happens to the quotation marks, if you’ve set autocorrect to fix them. 

 

yWriter is intended only for authoring a work.  Customisation is possible, in a limited way.  Customisation is possible, in a limited way.  Simon has always said that the editing happens outside of it.  That’s why there are few formatting tools and options in the program. 

 

Hope this helps,

 

Henry

 

Sent from Mail for Windows 10

 


From: ywr...@googlegroups.com <ywr...@googlegroups.com> on behalf of sharni ward <theimagi...@gmail.com>
Sent: Wednesday, April 18, 2018 8:12:17 AM
To: yWriter
Subject: Re: [yWriter] YWriter 5 eating emdashes
 

Simon Haynes

unread,
Apr 17, 2018, 11:03:12 PM4/17/18
to ywr...@googlegroups.com


em-dashes are lost due to a bug in Microsoft's rich text control. I can see it happening in the code - put an m-dash into the rtf text box, and when you read it back it's a regular dash again.

The only way around it (as suggested) is to use 2 regular dashes. On export, they will be written out as an mdash.

Cheers
Simon
--
Spacejock Software: http://www.spacejock.com
Hal Spacejock Series: http://www.spacejock.com.au
Patreon: https://www.patreon.com/spacejock

Peter Barns

unread,
Apr 18, 2018, 3:59:49 AM4/18/18
to ywr...@googlegroups.com
Yep that's how I do it.

Message has been deleted

Simon Haynes

unread,
Apr 22, 2018, 12:28:39 AM4/22/18
to ywr...@googlegroups.com


Thanks for the suggestions.

I'm already loading the rtf into a string.

It's much more complicated than you expect, though, because internally ywriter6 then converts the RTF to my own markup code. However, whenever I need to perform operations on the Rtf, I post it to a hidden rich text control, perform the ops, then convert it back to markup again.

If it were just the box in the editor it would be fine, but there are many other places I need to tackle this.

Personally I've been hoping that microsoft would update the rich text control to base it on a later one which is already included with Windows, but they haven't yet.

Cheers
Simon
--
Spacejock Software: http://www.spacejock.com
Hal Spacejock Series: http://www.spacejock.com.au
Patreon: https://www.patreon.com/spacejock


ScytheRider wrote:

> It is possible to preserve endash and emdash in rich text boxes.
>
> If you can get an endash into the text box, the SaveFile method saves it
> correctly. The problem is getting it in there.
>
> Instead of using the LoadFile method, load the file from a stream into a
> string.
>
> Then (for emdash) perform a replace on the raw RTF code, and replace all
> instances of "\emdash" with the string literal "???"
> Then replace all instances of "\emdash " (with a space at the end) with the
> same string literal. Then set the textbox's rtf property to the string, and
> voil??.
>
> This should perfectly preserve emdashes through saving and loading. Then
> you can do the same with "???" and \endash, or any other special character
> that gets screwed up. This is because the richtextbox converts the string
> literal into the RTF code, then the next time converts the RTF code into
> the hyphen. So if you can convert it back into a string literal before it
> gets turned into a hyphen, it's like taking a step back and then a step
> forward.
>
> For typing the characters into the editor, autocorrect does the trick just
> fine, and the textbox will not replace them.
>
> The only remaining problem is copy and paste, as the characters can get
> replaced when copying from somewhere else. If you want to go the extra
> mile, you can subclass your textbox and intercept the WM_PASTE message,
> then fetch the rtf code off the clipboard and paste it yourself after
> performing the replacements on it. This should even work with copying from
> MSWord.
>
> Or if you want an easier method, instead intercept the keypresses for
> Ctrl+V and Shift+Insert, and the right-click menu option for paste.
>
> Then you'll have a rich text box that appears to handle dashes just as well
> as any other text editor.
>
> Hope you find this helpful!

Simon Haynes

unread,
Apr 22, 2018, 1:56:04 AM4/22/18
to ywr...@googlegroups.com


By the way, I think the original problem was that all m-dashes are converted to n-dashes in the rtf when you read the rtf out of the richtextbox.

At that point I can't simply convert all n-dashes to m-dashes in the rtf code, because there wouldn't be any way of knowing which are supposed to be n-dashes in the first place.

ScytheRider

unread,
Apr 22, 2018, 3:49:38 PM4/22/18
to yWriter
Assuming we are both using the same version of the rich text box (4.6.1.0), the character "—" gets converted into "\emdash" which later gets converted into "-".
Likewise, the character "–" gets converted into "\endash" which later gets converted into "-"

Since only one conversion happens at a time, it should be possible to ensure the rtf data contains the desired characters, rather than the character codes, before loading it into the rich text box, and it will appear correctly. 

This should also be possible if you convert text into your own format by sanitizing the rtf data before putting it into the invisible rich text box. 

I don't know how your codebase works since I can't see it, but it seems that the task is possible. But yes, it does indeed suck that Microsoft has left this bug in and not updated the control. I wonder if it's possible to invoke the updated windows control somehow, rather than the default one, I'll have to look into that. It would be useful to know, since I do some text processing myself.
dashes.png
Reply all
Reply to author
Forward
0 new messages