[scribus] Converting hyphens to en and em dashes

Gregory Pittman gpittman at iglou.com
Sun Apr 27 16:02:21 UTC 2014


On 04/26/2014 10:45 PM, Gregory Pittman wrote:
> On 04/26/2014 10:32 PM, Gregory Pittman wrote:
>> Here is a script that accomplishes something simpler than Autoquote.py:
>>
>> http://wiki.scribus.net/canvas/En%2Bemdash.py
>>

I've fixed the script so that it doesn't alter styles and formatting.

I actually changed the logic quite a bit.
Now when it encounters a hyphen, it looks to see if the previous
character was a hyphen. If not, it leaves it alone.

If there was a hyphen in the prior character, it then looks to see what
follows. If previous, current, and following character are all hyphens,
then it deletes them and places an em dash.

If only previous and current character are hyphens, these two are
deleted and an en dash is inserted.

It's a bit hellish to keep track of where you are in the text,
especially when you're deleting and inserting, but in the end it works.

If you have a long series of hyphens all together, you end up with em
and maybe en dashes separated by hyphens.

Greg




More information about the scribus mailing list