Skip to content

Adding slightly nicer auto-indentation in xml/html mode#1694

Closed
mtaran-google wants to merge 4 commits intocodemirror:masterfrom
mtaran-google:master
Closed

Adding slightly nicer auto-indentation in xml/html mode#1694
mtaran-google wants to merge 4 commits intocodemirror:masterfrom
mtaran-google:master

Conversation

@mtaran-google
Copy link
Copy Markdown
Contributor

These are two changes to how html and xml get indented. The first is that attribute names on a new line will get indented to be in a line with the first attribute. For example, if you start out with this

<div class="..."

then press enter at the end and type 'style="...">' to get

<div class="..."
     style="...">

The option added controls whether to use the new attr name indentation algorithm or the old one, defaulting to the new.

The second change indents multi-line string attr values. For example, if you start with

<div style="height: 10px;

then press enter at the end and type 'width: 10px">' you'll get

<div style="height: 10px;
            width: 10px">

This seems like a generally nicer way of doing things, so I didn't put in an option for disabling it.

Two tests fail with these changes, but I checked and they seem to also be failing at your head. I'm pretty new to working with github, so maybe I didn't check it properly and my change did cause the failures. Hope you can let me know if there are problems! Thanks :)

@marijnh
Copy link
Copy Markdown
Member

marijnh commented Jul 25, 2013

Nice. But why did you split inAttribute? Add a property to the closure if you need to identify it. This seems like too much code duplication. Also, you have a console.log still in there.

@mtaran-google
Copy link
Copy Markdown
Contributor Author

Thanks for the suggestions! I don't program in JS much, so it hadn't occurred to me to use a property like that :)

@marijnh
Copy link
Copy Markdown
Member

marijnh commented Jul 26, 2013

Looks good. Merged.

@marijnh marijnh closed this Jul 26, 2013
anaran pushed a commit to anaran/CodeMirror that referenced this pull request Feb 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants