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

Support indentation of generated xml / html #446

Open
kevinushey opened this issue Sep 6, 2024 · 1 comment
Open

Support indentation of generated xml / html #446

kevinushey opened this issue Sep 6, 2024 · 1 comment
Labels
feature a feature request or enhancement

Comments

@kevinushey
Copy link
Contributor

libxml2 supports indentation of generated XML / HTML documents, via https://github.com/GNOME/libxml2/blob/master/xmlwriter.c#L4570-L4589. It would be handy if this could be made available in write_xml() and write_html().

@jennybc
Copy link
Member

jennybc commented Sep 6, 2024

By analogy with JSON, I'm interested in taking something like this:

{"user":{"id":1,"name":"John Doe","contact":{"email":"[email protected]","phone":{"home":"555-555-5555","work":"555-555-5556"}},"address":{"street":"123 Main St","city":"Anytown","state":"CA","postalCode":"12345","coordinates":{"latitude":37.7749,"longitude":-122.4194}},"preferences":{"notifications":{"email":true,"sms":false},"theme":"dark"}}}

and prettifying it like this:

json |> jsonlite::prettify()
#> {
#>     "user": {
#>         "id": 1,
#>         "name": "John Doe",
#>         "contact": {
#>             "email": "[email protected]",
#>             "phone": {
#>                 "home": "555-555-5555",
#>                 "work": "555-555-5556"
#>             }
#>         },
#>         "address": {
#>             "street": "123 Main St",
#>             "city": "Anytown",
#>             "state": "CA",
#>             "postalCode": "12345",
#>             "coordinates": {
#>                 "latitude": 37.7749,
#>                 "longitude": -122.4194
#>             }
#>         },
#>         "preferences": {
#>             "notifications": {
#>                 "email": true,
#>                 "sms": false
#>             },
#>             "theme": "dark"
#>         }
#>     }
#> }
#> 

But with HTML.

@hadley hadley added the feature a feature request or enhancement label Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants