We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The serialization of the mdast fails to deserialize because of a duplicate field type
#[test] fn test_serde() { let markdown = "This is a **test**"; let tree = markdown::to_mdast(&markdown, &markdown::ParseOptions::default()).unwrap(); let json = serde_json::to_string(&tree).unwrap(); let tree2: Node = serde_json::from_str(&json).unwrap(); assert!(tree == tree2); }
I get the following error from serde
Error("duplicate field `type`", line: 1, column: 21)
This is the generated json. It has duplicate type fields everywhere.
{ "type":"Root", "type":"root", "children":[ { "type":"Code", "type":"code", "value":"This is a **test**", "position":{ "start":{ "line":2, "column":1, "offset":1 }, "end":{ "line":3, "column":5, "offset":28 } }, "lang":null, "meta":null } ], "position":{ "start":{ "line":1, "column":1, "offset":0 }, "end":{ "line":3, "column":5, "offset":28 } } }
Looking at the AST enum and related structs they all have serde(tag, rename) macro configs, which seem to be conflicting.
enum
struct
serde(tag, rename)
#[derive(Clone, Eq, PartialEq)] #[cfg_attr( feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", rename = "type") )] pub enum Node { // Document: /// Root. Root(Root), //.. } #[derive(Clone, Debug, Eq, PartialEq)] #[cfg_attr( feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(tag = "type", rename = "root") )] pub struct Root { // Parent. /// Content model. pub children: Vec<Node>, /// Positional info. pub position: Option<Position>, }
The text was updated successfully, but these errors were encountered:
Definitely possible! PR welcome! :)
Sorry, something went wrong.
I have the same problem, I hope the fixing PR can join in as soon as possible!
Successfully merging a pull request may close this issue.
The serialization of the mdast fails to deserialize because of a duplicate field type
I get the following error from serde
This is the generated json. It has duplicate type fields everywhere.
Looking at the AST
enum
and relatedstruct
s they all haveserde(tag, rename)
macro configs, which seem to be conflicting.The text was updated successfully, but these errors were encountered: