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

Fields beginning with numbers get deleted #304

Open
dfjerstad opened this issue Apr 28, 2023 · 11 comments
Open

Fields beginning with numbers get deleted #304

dfjerstad opened this issue Apr 28, 2023 · 11 comments

Comments

@dfjerstad
Copy link

I'm having an issue where any fields starting with numbers are deleted upon saving or uploading to Tiddlyhost, using an uploaded Tiddlywiki version 5.1.17.

Expected behavior: Fields starting with numbers work like any other.

Observed behavior: Any field starting with a number will be deleted or not saved upon saving. Everything else is present upon reloading except any fields beginning with a number. A freshly uploaded Tiddlywiki file (v5.1.17) that contains fields starting with a number will not have those fields present upon viewing the uploaded wiki, with everything else intact.

@simonbaird
Copy link
Collaborator

I missed this somehow - apologies for the late response. I'll take a look at this and see if I can reproduce it.

@simonbaird
Copy link
Collaborator

I can't reproduce this in the latest TiddlyWiki, so perhaps it's a TiddlyWiki bug rather than a Tiddlyhost bug.

I'm trying it out at https://simon.tiddlyhost.com/#Fields%20with%20numbers%20test with TiddlyWiki 5.2.5.

@simonbaird
Copy link
Collaborator

I was able to reproduce this problem in an older TiddlyWiki version, (a 5.1.24-prerelease).

Actually I suspect it is related to how Tiddlyhost parses the div based storage used in pre-5.2.0 TiddlyWikis. If that's true it may be possible to provide a fix on Tiddlyhost. I'll take a look at this later.

My guess is that switch to json based storage in TiddlyWiki 5.2.0, caused this problem to go away. Are you able to upgrade your TiddlyWiki file as a workaround?

@dfjerstad
Copy link
Author

Hey, thanks for responding, I kind of forgot about this as well.

I can look into updating my wiki. If it's not an issue with newer wikis then it's not a totally pressing issue for me. I'll close this as completed and let you decide whether it's an issue you'd like to address further.

@dfjerstad
Copy link
Author

Hi, I have done some work trying to upgrade my wiki without success. I am wondering if you would please attempt to fix this bug?

@dfjerstad dfjerstad reopened this Apr 20, 2024
@simonbaird
Copy link
Collaborator

Do you want some help to upgrade your TiddlyWiki?

@simonbaird
Copy link
Collaborator

@dfjerstad
Copy link
Author

Thank you. The wiki is fairly customized with most of the work on it being done some time ago, so I have not been able to upgrade it cleanly. Are you willing to try to fix the bug? I don't want to take too much of your time, but I figure there might be a chance it's just a simple fix.

@simonbaird
Copy link
Collaborator

Understood. Okay, let me see if I can find a solution.

@simonbaird
Copy link
Collaborator

Experiments with the parser used by Tiddlyhost:

irb(main):038> puts Nokogiri::HTML('<div aa="value1" bb="value2" title="Asdf">').elements
<html><body><div aa="value1" bb="value2" title="Asdf"></div></body></html>

irb(main):039> puts Nokogiri::HTML('<div 1a="value1" bb="value2" title="Asdf">').elements
<html><body><div bb="value2" title="Asdf"></div></body></html>

Notice the attribute "1a" is skipped in the second example.

Experimenting with a real TiddyWiki saved in Tiddlyhost:

irb(main):044> Site.find_by_name('aaa').file_download.lines.grep /1aaa/
<div 1aaa="123" aaa="123" created="20240503172140910" modified="20240503174518514" title="Asdfasdf">

From that I can tell that the save does preserve the attribute, but when Tiddlyhost reads/parses the site (using Nokogiri) it disappears.

@simonbaird
Copy link
Collaborator

simonbaird commented May 3, 2024

Switching from Nokogiri to Oga might be an option since it seems to be more lenient about attribute names.

>> puts Oga.parse_html('<div 1a="value1" bb="value2">').to_s
<div 1a="value1" bb="value2"></div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants