0 votes
by (260 points)

I use the below in a header to fancify the dialogue I write in the story, where I want to swap out short - signs to longer ones. 


(replace: "- ")[― ]

 My issue is that replace above doesnt only replace a short sign that is follwed by a space ( "- "). It replaces all short signs, no matter the spacing before of after them. I

Question: How can I achieve such a precise replace:? What am I missing here?

2 Answers

+2 votes
by (156k points)

You don't give an example of the actual text you're trying to replace so I wasn't sure if you were trying to replace the figure dash with an en dash or an em dash, so I tested both.

1. Replace a figure dash delimited by spaces with an en dash with spaces:

Queen Victoria throne-sat for six decades.
Queen Victoria throne - sat for six decades.
Queen Victoria throne- sat for six decades.
Queen Victoria throne -sat for six decades.

(replace: " - ")[ – ]

... produced the following correct output where only the second line was modified.

Queen Victoria throne-sat for six decades.
Queen Victoria throne – sat for six decades.
Queen Victoria throne- sat for six decades.
Queen Victoria throne -sat for six decades.

 

2. Replace a figure dash delimited by spaces with an em dash with spaces:

Queen Victoria throne-sat for six decades.
Queen Victoria throne - sat for six decades.
Queen Victoria throne- sat for six decades.
Queen Victoria throne -sat for six decades.

(replace: " - ")[ — ]

.. produced the following correct output where only the second line was modified.

Queen Victoria throne-sat for six decades.
Queen Victoria throne — sat for six decades.
Queen Victoria throne- sat for six decades.
Queen Victoria throne -sat for six decades.

note: I also ran the above tests using Harlowe v1.2.4 in case you were using it instead. and it also produced the correct output.

+1 vote
by (6.2k points)

As greyelf said, please give an example to what you're doing. Anyway, could you use hooks?

|replace>[-]
(replace: ?replace)[-]

 

Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.
...