klembot / chapbook

A simple, readable story format for Twine 2.
https://klembot.github.io/chapbook
MIT License
80 stars 25 forks source link

Bug when formatting inserts with italics #89

Closed Gibbo27 closed 7 months ago

Gibbo27 commented 4 years ago

Hi,

I'm having an issue where the italics are randomly not affecting inserted text. I have copied and pasted the successful code into the problem passages, but it seems the program is randomly adding a space in most cases.

e.g.

*{firstname} {secondname} {profession}* displays correctly italicised in some cases, but in most cases it displays as:

John Smith Baker - with no italics and an added space at the end (John Smith Baker_)

{firstname} {secondname} {profession} may display partly formatted like: John Smith Baker_*

Is the space breaking the instruction? It should not be there and isn't in the code. The state tracking would state "Baker" with no added space, and this matches the passages where the formatting has worked. I can't see any clues why it works in some cases but not in others.

I am using Twine in Windows and testing in Chrome.

Many thanks

Gibbo27 commented 4 years ago

Sorry, where I've clarified the space with Baker-underscore, that shouldn't have italicized, but I think you'll get what I mean. The second example had asterisks beside each word, but I forgot to \ them out. You can email me directly if anything needs better explaining: gibbo@gibbocreations.com

klembot commented 3 years ago

Is it possible that the leading asterisk is getting interpreted as the start of a bullet point? This seems to work consistently correctly for me:

first: 'Chris'
last: 'Klimas'
profession: 'dev'
--
Test: *{first} {last} {profession}*
Gibbo27 commented 3 years ago

Hi Chris,

Thanks for your response. I altered your example until it was in line with the one in my game, and I think I’ve found the issue.

It does seem to be the space at the end which is breaking the formatting, but Twine is not adding the space as I first suspected. The last insert I am using is not always required. Therefore, in some instances, it is an empty string. But the space between the last two inserts is still (understandably) being displayed - and it's this space that breaks the formatting. I believe I have solved this by closing the space between the last two inserts and adding a space at the start of the string in the final insert's field e.g. profession: ' dev'

I guess you might want to look at why a space between inserts would break the formatting if left dangling, but after a bit of work, I think all is good on this end.

Thanks again,

Gibbo

mielikki commented 3 years ago

Looking at this again, it seems like that is just basic markdown syntax. Bold and italic cannot have a space before the closing * or **.

This

this is *italic* text

this is *italic with trailing space * text

Renders as:

this is italic text

this is italic with trailing space text

klembot commented 7 months ago

I'm going to close this for the reason @mielikki cited. The spacing around delimiters issue(?) is present in Marked, the library we use for Markdown rendering.