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

using AtomicString will mess up "<" and ">" characters #443

Closed
sander76 opened this issue Nov 17, 2015 · 4 comments
Closed

using AtomicString will mess up "<" and ">" characters #443

sander76 opened this issue Nov 17, 2015 · 4 comments
Milestone

Comments

@sander76
Copy link

for example:
div.text = AtomicString("< test >")

will come out as:
&lt; test &gt;

using python 3.5

@waylan
Copy link
Member

waylan commented Nov 17, 2015

I expect this is probably related to mkdocs/mkdocs#751.

Thanks for the report.

@waylan
Copy link
Member

waylan commented Nov 17, 2015

I've taken a closer look and this is not related to the MkDocs issue. That is specifically a bug in MkDocs.

Actually, now that I think about it, this behavior is expected. I supose you were thinking that because it was an AtomicString, that no additional processing should be done on it. That is actually what happens. The "parser" does no additional processing. However, the serializer does sanitation/escaping on any input it receives, including AtomicStrings. In fact, the serializer has no knowledge of AtomicString. It simply sees a normal string and treats it the same.

If you want to bypass the serializer, then you need to not have your output (presumably from and extension) go through the serializer. Note that some extensions (codehilite and fenced_code_blocks) do this by storing their output in the HtmlStash for later retrieval after the serializer has run. Others may operate as a postprocessor completely for the same reason.

In any event, there is no bug here, unless you can show different behavior in different versions of Python (which is what I thought you were reporting at first--turns out the behavior is the same across versions in my testing).

@sander76
Copy link
Author

Ok thanks for diving into this.
However,
div.text = "< test >"
comes out as:
< test >

This is what I use now as it gives me the result I want, but I feel I should have been using AtomicString as I want my string not to be processed anymore..

@waylan waylan added this to the Version 3.0 milestone Nov 18, 2015
@waylan
Copy link
Member

waylan commented Nov 18, 2015

It sounds like what you want is something that will be coming in version 3.0. We will be introducing a new type: RawText which will get ignored by both the parser and the seriallizer. You will have to wait for 3.0 to get that feature though. See the Roadmap for more info.

In the meantime, I'll label this as 3.0 and leave it open.

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