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

XML CDATA Sections not preserved on round-trip save #348

Closed
dreftymac opened this issue Dec 12, 2016 · 2 comments
Closed

XML CDATA Sections not preserved on round-trip save #348

dreftymac opened this issue Dec 12, 2016 · 2 comments
Assignees
Labels
Milestone

Comments

@dreftymac
Copy link

Context

context000

Scenario

  • User creates a leo file in the leo GUI.
  • User then opens the leo file in a plain old text editor like Vim.
  • User then adds a CDATA section to an t element in a tnodes section.
  • User then re-opens the file in leo GUI and saves the file

Problem

  • Upon save, Leo editor strips out the XML CDATA
  • This is a problem because some users may not want to have their data XML-Escaped, and instead preserved as raw text with absolutely no leo-based modifications.

Question

Is there a setting or option that preserves the CDATA applied to tnodes/t element in leo?

@edreamleo
Copy link
Member

Thanks for this report. Leo uses the xml.sax parser, so presumably this is a bug in the cdata handler. I'll look into this asap.

@edreamleo edreamleo added this to the 5.5 milestone Dec 15, 2016
@edreamleo edreamleo self-assigned this Dec 15, 2016
@edreamleo edreamleo added the Bug label Dec 15, 2016
@edreamleo
Copy link
Member

edreamleo commented Dec 17, 2016

This page shows there is no separate cdata handler. Googling "python xml.sax cdata" yields this page, which indicates that cdata comes in as part of the characters content handler.

Alas, Leo's content handler strips '\r' characters, and converts to unicode if necessary, though that usually is not necessary. So it appears that preserving cdata unchanged will not be easy.

Happily, neither you nor your scripts should ever need to munge any .leo file by inserting cdata elements. Instead, you should use uA's to add content to nodes. You can add uA's to any node, regardless of whether the node is in an @<file> tree or not. The str_ convention should allow any cdata to come in unchanged.

I am going to close this issues for now. Please reopen if there are problems using uA's to do what you want.

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

No branches or pull requests

2 participants