daverosoff / PreTeXtual

A Sublime Text 2/3 package for PreTeXt files.
Other
1 stars 3 forks source link

Weird behavior with <idx> and <h> tags #35

Closed j-oldroyd closed 3 years ago

j-oldroyd commented 6 years ago

Firstly, thanks again for creating such a great package for Sublime Text. It's been a massive help!

I'm writing to ask about some strange behavior I'm getting with <idx> and <h> tags. I get the same issue on both my Windows laptop and MacBook. For example, consider the following code block:

<definition>
  <idx><h>Wronskian</h></idx>
</definition>

My problem specifically deals with closing tags automatically. If I set my syntax to XML, then typing </ after "Wronskian" closes the first <h> tag just fine, and typing <\ after that closes the index tag as well. However, if I switch the syntax to PreTeXt, and then enter, say, </ after "Wronskian", Sublime Text can't seem to recognize that there's a tag that needs to be closed. The same is true for <idx>. Even stranger, typing </ after </definition> results in the following:

<definition>
  <idx><h>Wronskian</h></idx>
</definition>
</h>Wronskian<></h>Wronskian<>
</h>Wronskian<>

As far as I can tell, entering </ anywhere outside of <p>...</p>, <m>...</m>, etc., result in this behavior.

If you can shed any light on this, or tell me if I'm in error, I'd appreciate it. Thank you for your time!

daverosoff commented 6 years ago

Hi, thanks for opening the issue and for your kind words about the package. I'm looking into it and hopefully I'll have some solution in the next few days. Can you please clarify what you meant by "outside of <p>...</p>, <m>...</m>, etc."? I'm not sure what the "etc." might include. Thanks.

j-oldroyd commented 6 years ago

Thanks for your response! Sorry I was unclear earlier. I've added another example below to (hopefully) help illustrate when I'm seeing this behavior:

<idx> <!-- Tag doesn't close properly when entering "</"-->
<h> <!-- Tag doesn't close properly when entering "</" -->
<Tag1>
  <Tag2>
  </Tag2> <!-- This tag closes properly -->
  <theorem>
    <idx><h>some index</h></idx> <!-- tags here must be closed manually -->
     <p>text</p> <!-- This tag closes properly  -->
     <m>math</m> <!-- This tag closes properly -->
  </h>some></h>some></h>some>   <!-- Theorem tag doesn't close properly when entering "</" -->
  </theorem>

  </h>some> <!-- Outside tags fail to close properly after <idx><h> tags -->
  <p>more text</p> <!-- This tag closes properly -->
  <Tag3></Tag3> <!-- This tag closes properly -->
  </h>some> <!-- Outside tags still fail to close properly after entering "</" -->

I think it might be an issue with the matching used for indices. If I change line 304 in PreTeXt.sublime-syntax from

- match: '(</?)({{index}})'

to

- match: '(</?)(index)'

both <h> and <idx> seem to work properly (though I have no idea what this change might break!).

daverosoff commented 3 years ago

Closed at #46.