chrisbra / vim-xml-runtime

Vim filetype plugin for XML files
11 stars 6 forks source link

Style a problem with autoindent and autoclosing tags #26

Closed maieul closed 4 years ago

maieul commented 4 years ago

Hi, there is still a problem with autoindent ans autoclosing tag. That happens when autoclosing tag is inside a word, which may happen for example in XML-TEI.

So the output I get


    Something some other thing.<lb /> Some longwords
        Something some other thing.<lb /> Some longwords
            Some<lb />thing some other thing. Some longwords
                Something some other thing.<lb /> Some longwords
                    Something some other thing. Some longwords
                    Something some other thing. Some longwords

while a would expect

    Something some other thing.<lb /> Some longwords
    Something some other thing.<lb /> Some longwords
    Some<lb />thing some other thing. Some longwords
    Something some other thing.<lb /> Some longwords
    Something some other thing. Some longwords
    Something some other thing. Some longwords
maieul commented 4 years ago

Sorry, I tried it but I still have this problem.

chrisbra commented 4 years ago

how to reproduce please?

maieul commented 4 years ago

well, in ~/.vim/pack/vim-xml-runtime it is a clone of the repository, last commit f1ce700

So I guess my installation is correct. But with the example I provided in the ticket, I have still bad indent. So I reproduce my problem just by pastebin the example, and try auto indentation, using =.

chrisbra commented 4 years ago

Are you entering the content, or using an existing xml file and run gg=G over it? FWIW: commit f1ce700 contains a test, that uses gg=G to correctly format such an example and I cannot see how to reproduce your issue besides what I have just committed.

So if you can reproduce using vim --clean that would help pin down the problem.

Thanks, Christian

maieul commented 4 years ago

I tried both.

  1. Entering the content line by line
  2. Open an existing file the first example, select the line in visual mode, and type =

But I have look on your test file, and it does not match the problem I mentionned in the issue, which concern tags inside a word.

chrisbra commented 4 years ago

But I have look on your test file, and it does not match the problem I mentioned in the issue, which concern tags inside a word.

Well, for one, that file is not a valid xml file and then I don't understand what you mean with tags inside a word. There are no tags inside words, only within the text, but I doubt this makes a difference. There is a space before the closing /. Is that what you mean? I also tried with the example above, but for me it works, except that the first line will be de-indented. Which is expected I guess. But it certainly does not create those stair-stepping issue.

maieul commented 4 years ago

Well, of course, it is not a full valid XML document, but just an extract to show an example.

But if you want a full valid (according to the w3c validator) XML document, here it is

<?xml version="1.0"?>
<!DOCTYPE TEI PUBLIC "TEI" "https://www.tei-c.org/release/xml/tei/custom/schema/dtd/tei_all.dtd">
<TEI>
<text>
<body>
    Something some other thing.<lb /> Some longwords
        Something some other thing.<lb /> Some longwords
            Some<lb />thing some other thing. Some longwords
                Something some other thing.<lb /> Some longwords
                    Something some other thing. Some longwords
                    Something some other thing. Some longwords
</body>
</text>
</TEI>

Concerning the tags inside the word, that is precisely the point. If you have some<lb /> word, the tag is outside the word. But if you have some<lb />thing, the tag is inside the word (<lb /> is between some and thing, and, consequently, inside the something word).

Furthermore, I tried to run https://github.com/chrisbra/vim-xml-runtime/blob/f1ce70014ff5fb7d0b4a908ad24b5a3473aa4abc/test/INDENT/18/cmd, and the output.xml get this


<div>
  <p>
    Some text
      Some text <lb/>
        Some more text <lb/> even more text
          Some text <lb/>
            Some text
            Some text
            Some more text <lb/> even more text
              Some more text <lb/> even more text
            </p>
          </div>
chrisbra commented 4 years ago

I still cannot reproduce this, but I see some other funny behaviours, that is certainly not right. Also the tests suddenly start failing for me :/

Concerning the tags inside the word, that is precisely the point. If you have some word, the tag is outside the word. But if > you have something, the tag is inside the word ( is between some and thing, and, consequently, inside the something word).

That does not make a difference for the indent script. It does not check, whether a tag is within a word or not, so I do not see how this should make a difference.

Furthermore, I tried to run https://github.com/chrisbra/vim-xml-runtime/blob/f1ce70014ff5fb7d0b4a908ad24b5a3473aa4abc/test/INDENT/18/cmd, and the output.xml get this

Did you set $VIM_XML_RT correctly? What Vim version is this?

maieul commented 4 years ago

What is $VIM_XML_RT, where should I set it, and which value ? I did't know about that before. I have vim 8.1.2269

maieul commented 4 years ago

May I asked again for this problem?

i have still it, but I don't know What is $VIM_XML_RT, where should I set it, and which value

chrisbra commented 4 years ago

$VIM_XML_RT

It is a environment varible that is set to the path of the checkout out repository, so the tests can source the correct fiels. See the Makefile.

See if make test works for you, or if it fails currently. If it does fail, than something seriously is wrong, if it doesn't try to add a new test to the indent directory (see the other files for how to do it), put the commands to reproduce the issue into a file cmd and see what the result is.

maieul commented 4 years ago

I tried make test and that is what I get.

make test
cd test && VIM_XML_RT=/home/mrouquet/.vim/plugged/vim-xml-runtime ./test_runtime.sh && cd .. && make clean >/dev/null

AUTOFORMAT tests
============
Test 01:        [OK]
Test 02:        [OK]
Test 03:        [OK]
Test 04:        [OK]
Test 05:        [OK]
Test 06:        [OK]
Test 07:        [OK]
Test 08:        [OK]
Test 09:        [OK]
Test 10:        [OK]
Test 11:        [OK]
Test 12:        [OK]
Test 13:        [OK]

INDENT tests
============
Test 01:        [OK]
Test 02:        [OK]
Test 03:        [OK]
Test 04:        [OK]
Test 05:        [OK]
Test 06:        [OK]
Test 07:        [Failed]
Test 08:        [OK]
Test 09:        [OK]
Test 10:        [OK]
Test 11:        [OK]
Test 12:        [OK]
Test 13:        [OK]
Test 14:        [OK]
Test 15:        [OK]
Test 16:        [OK]
Test 17:        [OK]
Test 18:        [Failed]
maieul commented 4 years ago

some news ?

chrisbra commented 4 years ago

the problem is, I don't know why it fails for you. I'll have to investigate this some more. What platform and Vim version are you using?

maieul commented 4 years ago

I use Ubuntu 20.04 TLS + VIm 8.1

VIM - Vi IMproved 8.1 (2018 May 18, compilé Apr 15 2020 06:40:31)

chrisbra commented 4 years ago

can you please check again?

maieul commented 4 years ago

Well, both test and real use case succcess after upgrading. Thank you.

chrisbra commented 4 years ago

great!