Bug 171846 - Commented xml elements break xml intendation
Summary: Commented xml elements break xml intendation
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Unclassified
Component: indentation (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-29 10:16 UTC by Jiri Klement
Modified: 2013-04-23 21:00 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.11


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jiri Klement 2008-09-29 10:16:29 UTC
Version:            (using Devel)
Compiler:          gcc 4.2.3 
OS:                Linux
Installed from:    Compiled sources

XML file is sometimes not correctly intended (using Tools - Align command). For example look at following file:

<xml>
  <!--
    <in-comment>
    </in-comment>
    -->
    <element>
    </element>
</xml>

<element> is not intended correctly. Try to remove <in-comment>, </in-comment> or both and do Tools - Align. Every time intendation will change.

Tested with katepart in kde 3.5.9 and 4.1.67.
Comment 1 Fabian 2011-03-03 11:02:05 UTC
Bug still exists.

KDE 4.6.00, Kate 3.6.0
Comment 2 Dominik Haumann 2011-08-08 13:12:58 UTC
Milian, do you plan to do something about it?

Fabian and Jiri: The xml indenter can be found in e.g. /usr/share/kde4/apps/katepart/script/xml.js, or in a similar location on your system.

It's plain javascript, if you want, you can try to improve it and contribute a better version!
See: 
http://docs.kde.org/stable/en/kdebase-runtime/kate/advanced-editing-tools-scripting.html
Comment 3 Milian Wolff 2011-08-08 13:22:05 UTC
I'd like to fix it eventually but I simply don't have enough time right now for it - sorry. If someone else could work on it I'd appreciate it and would gladly give a hand.
Comment 4 Christoph Cullmann 2012-10-27 18:13:45 UTC
We have the indenters as javascript for the reason that users can help to maintain them.
If you want to provide a patch, please reopen, else this stays closed.
Comment 5 Gerald Senarclens de Grancy 2013-04-15 23:54:06 UTC
Git commit b79d22f6a32cb9db8bab78447f3b984a97729e0b by Gerald Senarclens de Grancy.
Committed on 16/04/2013 at 01:41.
Pushed by geralds into branch 'master'.

Rewrote xml indenter and added a small test-suite

removed many of the really complicated regular expressions
and replaced them using the nice .isComment, .isCode, ... functions
also works properly on aligning etc.
REVIEW: 110018

M  +129  -122  part/script/data/indentation/xml.js
M  +17   -1    part/script/data/libraries/string.js
A  +1    -0    tests/data/indent/xml/.kateconfig
A  +2    -0    tests/data/indent/xml/arguments1/expected
A  +3    -0    tests/data/indent/xml/arguments1/input.js
A  +1    -0    tests/data/indent/xml/arguments1/origin
A  +3    -0    tests/data/indent/xml/arguments2/expected
A  +3    -0    tests/data/indent/xml/arguments2/input.js
A  +2    -0    tests/data/indent/xml/arguments2/origin
A  +3    -0    tests/data/indent/xml/arguments3/expected
A  +3    -0    tests/data/indent/xml/arguments3/input.js
A  +2    -0    tests/data/indent/xml/arguments3/origin
A  +3    -0    tests/data/indent/xml/arguments4/expected
A  +3    -0    tests/data/indent/xml/arguments4/input.js
A  +2    -0    tests/data/indent/xml/arguments4/origin
A  +3    -0    tests/data/indent/xml/closing1/expected
A  +3    -0    tests/data/indent/xml/closing1/input.js
A  +2    -0    tests/data/indent/xml/closing1/origin
A  +3    -0    tests/data/indent/xml/closing2/expected
A  +3    -0    tests/data/indent/xml/closing2/input.js
A  +2    -0    tests/data/indent/xml/closing2/origin
A  +3    -0    tests/data/indent/xml/closing3/expected
A  +4    -0    tests/data/indent/xml/closing3/input.js
A  +2    -0    tests/data/indent/xml/closing3/origin
A  +1    -0    tests/data/indent/xml/comment1/README
A  +3    -0    tests/data/indent/xml/comment1/expected
A  +3    -0    tests/data/indent/xml/comment1/input.js
A  +2    -0    tests/data/indent/xml/comment1/origin
A  +4    -0    tests/data/indent/xml/comment2/expected
A  +11   -0    tests/data/indent/xml/comment2/input.js
A  +4    -0    tests/data/indent/xml/comment2/origin
A  +3    -0    tests/data/indent/xml/opening1/expected
A  +4    -0    tests/data/indent/xml/opening1/input.js
A  +1    -0    tests/data/indent/xml/opening1/origin
A  +2    -0    tests/data/indent/xml/self_closing1/expected
A  +3    -0    tests/data/indent/xml/self_closing1/input.js
A  +1    -0    tests/data/indent/xml/self_closing1/origin
A  +2    -0    tests/data/indent/xml/text1/expected
A  +3    -0    tests/data/indent/xml/text1/input.js
A  +1    -0    tests/data/indent/xml/text1/origin
A  +2    -0    tests/data/indent/xml/text2/expected
A  +3    -0    tests/data/indent/xml/text2/input.js
A  +1    -0    tests/data/indent/xml/text2/origin
A  +35   -0    tests/data/indent/xml/xhtml1/expected
A  +66   -0    tests/data/indent/xml/xhtml1/input.js
A  +1    -0    tests/data/indent/xml/xhtml1/origin
M  +12   -0    tests/indenttest.cpp
M  +3    -0    tests/indenttest.h

http://commits.kde.org/kate/b79d22f6a32cb9db8bab78447f3b984a97729e0b