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

Is there support for Visual Studio like formatting each attribute in new line with indentation? #14

Open
pmahend1 opened this issue Mar 27, 2020 · 6 comments

Comments

@pmahend1
Copy link

Expected:

<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
             xmlns:d="http://xamarin.com/schemas/2014/forms/design" 
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             mc:Ignorable="d" 
             x:Class="App9.MainPage">
    <StackLayout>
        <Label Text="Welcome to Xamarin.Forms!" 
            HorizontalOptions="Center" 
            VerticalOptions="CenterAndExpand" />
    </StackLayout>
</ContentPage>

Default

<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:d="http://xamarin.com/schemas/2014/forms/design" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="App9.MainPage">
	<StackLayout>
		<Label Text="Welcome to Xamarin.Forms!" HorizontalOptions="Center" VerticalOptions="CenterAndExpand" />
	</StackLayout>
</ContentPage>
@chrisbottin
Copy link
Owner

Thanks for your message.

According to you, what should be the rule to wrap the attributes into the next line ?

@pmahend1
Copy link
Author

I am just wondering if we can format XML as above, see the first attribute is on same line as of start tag and remaining attributes aligned with first attribute?

@chrisbottin
Copy link
Owner

I will look into it if that can be done easily but I can't give you a time estimate.

@dgergely
Copy link

@chrisbottin I think it can be done by having a parameter on line length. E.g. above 120 character length if there are at least 2 attributes, the 2nd, 3rd, etc gets the padding of (tag's padding + tags length + 1 (opening '<') + 1 (space)) or simply just an extra padding as it would be a child element.
These are just ideas, I am not sure what other issues might be here.

@chrisbottin
Copy link
Owner

Thanks for your comment @dgergely, I agree it's a good approach. I might take a look this week.

@pmahend1
Copy link
Author

pmahend1 commented Oct 19, 2020

I couldnt find this feature in any npm packages or even standard C# XMLWriter unfortunately. I ended up writing it down through C# and using electron-edge-js to call dll for my extension PrettyXML
Yes the approach is to track element space length and attribute space length separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants