-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: add namespace support to Writer #41
Conversation
Closes #40 In addition to the new namespace-aware functions, this commit brings several other enhancements: - The element name has been removed as an argument of `elementEnd`. The writer now keeps track of the current open element automatically. - Doctests have been added for all public writer functions. - Doc comments have been added for all public writer functions.
Thanks! I'm trying it out. I saw some odd behaviour in my app with <?xml version="1.0" encoding="UTF-8"?>
<D:multistatus xmlns:D="DAV:" xmlns:c="urn:ietf:params:xml:ns:carddav">
<D:response>
<D:href>/</:href>
<D:propstat>
<D:prop xmlns:z="DAV:">
<z:current-user-principal><href>/principal/0192c59f-4894-7ecf-bb00-c2348efa927d/</href></:current-user-principal>
... I wrote a quick test to try to narrow it down: test "namespaceBug" {
var raw = std.ArrayList(u8).init(std.testing.allocator);
defer raw.deinit();
const out = streamingOutput(raw.writer());
var writer = out.writer(std.testing.allocator, .{ .indent = " " });
defer writer.deinit();
try writer.bindNs("d", "foospace");
try writer.elementStartNs("foospace", "root");
try writer.elementStartNs("foospace", "child");
try writer.text("Hello, Bug");
try writer.elementEnd();
try writer.elementEnd();
try expectEqualStrings(
\\<d:root xmlns:d="foospace">
\\ <d:child>
\\ Hello, Bug
\\ </d:child>
\\</d:root>
, raw.items);
} unfortunately the test crashes with a segfault
|
Thanks! That bug is an unfortunate consequence of my trying to be a bit too clever with memory management 😄 I pushed up a fix in e00a4a8, and added your example as a test case. |
TODO: I need to take another look over this before merging it to make sure I didn't miss anything (and possibly add more tests aside from just the doctests added here).
Closes #40
In addition to the new namespace-aware functions, this commit brings several other enhancements:
elementEnd
. The writer now keeps track of the current open element automatically.