Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paragraph tags misplaced for first paragraph in Windows #186

Open
mcdemarco opened this issue Aug 19, 2020 · 5 comments
Open

Paragraph tags misplaced for first paragraph in Windows #186

mcdemarco opened this issue Aug 19, 2020 · 5 comments
Assignees
Labels
2.X Issues for the 2.X branch

Comments

@mcdemarco
Copy link

If you create a new story in Windows using the latest Twine (2.39) and Snowman (2.0.2), the first paragraph in every passage will be missing its paragraph tags, which appear to be shifted onto the next line as an empty paragraph tag. While this has no obvious visual effect out of the box (you have to view the rendered source of the passage to see it), it will mess up any paragraph-based CSS or scripting.

This does not happen on (unix-based) MacOS X. It seems to be a result of some paragraph cleanup code at the end of Passage.js aimed at fixing marked output. The code assumes unix newlines (\n) instead of windows newlines (\r\n). There are other cases as well, like classic mac newlines (\r), but Twine users are unlikely to run into them.

Note that importing a story into a Windows Twine can preserve unix newlines, and then the problem won't occur. (It's not clear exactly what the import and Twine are doing, but for a story I imported the newlines remained unix-style even after some editing in Windows.)

As a temporary workaround I suggested converting the published story to unix newlines, but the original reporter (bphennessy on discord) went with a jQuery fix instead:

var firstpar = $(".passage").contents().filter(function(){ 
  return this.nodeType == 3; 
})[0]

$(firstpar).wrap("<p></p>")

To fix Snowman itself I assume a better regex would be sufficient, depending on what problem the code was fixing:

    if ((!result.endsWith('</p>\n') && newResult.endsWith('</p>\n')) || (!result.endsWith('</p>\r\n') && newResult.endsWith('</p>\r\n')) {
      newResult = newResult.replace(/^<p>|<\/p>$|<\/p>(\r)?\n$/g, '');
    }

Since I can't reproduce the original issue (my stories behave the same with and without the paragraph correction code) I can't be sure that actually works as intended.

@videlais
Copy link
Owner

videlais commented Jun 2, 2022

Thanks for reporting this. It is an issue with Marked I'd been fighting with for a long time. The newest build should fix it by no longer generating paragraph tags (and removing Marked from the project).

@videlais videlais closed this as completed Jun 2, 2022
@sheridanvk
Copy link

Would you mind clarifying which build this is fixed in (and providing the URL for it so I can add it to Twine)? I have this issue with Snowman 2.0.2, and it's not clear to me if you're saying this is fixed in v3 (which I believe is not production-ready yet?) or some other version?

thank you!

@videlais
Copy link
Owner

videlais commented Jan 2, 2024

Hi, @sheridanvk. The issue was fixed in the work toward Snowman 3.X. There have been no updates to Snowman 2.X since Summer 2022.

@sheridanvk
Copy link

Thanks for the fast reply! Is there a format link where I can try out 3.x?

@videlais videlais self-assigned this Jan 3, 2024
@videlais videlais added the 2.X Issues for the 2.X branch label Jan 3, 2024
@videlais
Copy link
Owner

videlais commented Jan 3, 2024

Is there a format link where I can try out 3.x?

You can try this link or otherwise download the last format.js build from the latest experimental build from August 2023. However, this comes with a MAJOR caveat. I make absolutely no guarantee it will work. Snowman 3.X is very different than the Snowman 2.X branch.

I'll re-open this issue for now for the 2.X branch, but I do not know when I can address it.

@videlais videlais reopened this Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.X Issues for the 2.X branch
Projects
Status: No status
Development

No branches or pull requests

3 participants