-
Notifications
You must be signed in to change notification settings - Fork 267
Open
Description
When using the json{} displayer, if an attribute name is tag, text, you get misleading results:
# echo '<div tag="hello">world</div>' |./pup 'div json{}'
[
{
"tag": "div",
"text": "world"
}
]tag=hello attribute has disappeared
# echo '<div text="hello">world</div>' |./pup 'div json{}'
[
{
"tag": "div",
"text": "hello world"
}
]text=hello attribute has been appended to text
Both these issues can be solved by giving attributes their own object underneath the node object
# echo '<div tag="hello">world</div>' |./pup 'div json{}'
[
{
"attrs": {
"tag": "hello"
},
"tag": "div",
"text": "world"
}
]
# echo '<div text="hello">world</div>' |./pup 'div json{}'
[
{
"attrs": {
"text": "hello"
},
"tag": "div",
"text": "world"
}
]Metadata
Metadata
Assignees
Labels
No labels