Author Topic: Auto close html tags  (Read 4301 times)

Kluyg

  • Guest
Auto close html tags
« on: October 15, 2009, 02:14:46 pm »
Is there ability to automatically (by hotkey) add close tags when editing html files?

Offline alex

  • Developer
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2181
  • Karma: +37/-3
    • View Profile
    • HippoEDIT
Re: Auto close html tags
« Reply #1 on: October 15, 2009, 02:45:10 pm »
Hi Kluyg,

welcome on forum, and thanks for a feedback!

Auto close of the tags is rather specific function for XML based languages only, but I am trying to keep HippoEDIT language/syntax independent and have all functionality described by syntax schemes. As introduction :)

So there is no specific command for this and I do not plan to add it to core. And it is also difficult to some how model it. Because maybe adding close tag defined in syntax schema would be possible, but what you want is also </ tag > for it. And signs </ > are not described in schema as part of scope tag.

BUT: you have code templates, which can help in adding of pairs of open/close tags by one key stroke. You can also use there selected text and surround selection by <strong>smth</strong> on Ctrl+B.
In addition I am currently working on scripting (would be available in 1.50) which would be used then for extension of HE with all syntax related functionality as closing of tag. Script would be callable by short cut also. In addition it would be possible to subscribe script to some event, like onChar, and then do something if </ is typed.
Maybe I would provide some set of such scripts as examples then.

Best regards,
Alex.

Kluyg

  • Guest
Re: Auto close html tags
« Reply #2 on: October 15, 2009, 07:44:51 pm »
Hi Alex,

Thanks for the answer!

Keeping HippoEDIT syntax independent is good idea. I can live without automatic tag closing :) There are a lot of features in HE, I just don't want to miss any. Looking forward to version 1.50, good luck!

Thanks,
Mikhail

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 775
  • Karma: +6/-0
    • View Profile
Re: Auto close html tags
« Reply #3 on: October 15, 2009, 09:49:53 pm »
Hi Mikhail and welcome ;)

Just to make this more clear: as Alex already mentioned ... "you have code templates"

So if one edit an HTML file and write f.ex. <table  you see an pop-up/tool-tip,
just press the TAB-key and see what happens ;D
Or try writing <a and then the TAB-key. It's magic...

Kluyg

  • Guest
Re: Auto close html tags
« Reply #4 on: October 16, 2009, 06:49:02 pm »
It's great! But unfortunately it adds tags in uppercase which is not what I want. Can I change this behavior somehow?

Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 775
  • Karma: +6/-0
    • View Profile
Re: Auto close html tags
« Reply #5 on: October 16, 2009, 07:33:57 pm »
It's great! But unfortunately it adds tags in uppercase which is not what I want. Can I change this behavior somehow?

- open an HTML file
- Go to "Tools > Syntax settings (HTML)... > Code Templates"
or
- Go to "Tools > Syntax settings (HTML)... > Miscellaneous > Edit User File"
there you can modify all templates.


But this would be some work to do.
Maybe this would be an features suggestion: implement an option to choose the case of CodeTemplations.

I mean something like as with:
"Tools > Options... > [+ ] Formating > Smart Helpers > Case correction"
for keywords.

Offline alex

  • Developer
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2181
  • Karma: +37/-3
    • View Profile
    • HippoEDIT
Re: Auto close html tags
« Reply #6 on: October 17, 2009, 02:27:51 am »
As far as I remember my code ;) if you would check Format after every paste and select for Case correction lowercase for example, then pasted template would be also formatted and all tag names would be automatically converted to lowercase. Or you can use Format Selection keeping Case correction set to desired value.

But probably better is to once convert template source to format you like and forget about it.

Kluyg

  • Guest
Re: Auto close html tags
« Reply #7 on: October 17, 2009, 07:37:13 am »
Quote
As far as I remember my code ;) if you would check Format after every paste and select for Case correction lowercase for example, then pasted template would be also formatted
Just FYI - pasted templates are not formatted and tag names remains uppercase even if Format after every paste and Case correction lowercase are set.
I have fixed "html_user.xml" file as Stefan suggested. Also FYI: I was having problems modifying this file, because it is itself case-sensitive (Firstly I have selected all it's text by ctlr+A and converted it to lowercase by ctrl+L and... all templates disappeared. Fixed it by reinstalling HippoEDIT).
I've attached the resulting fixed "html_user.xml" file. It is located at "C:\Program Files\HippoEdit\data\syntax\html_user.xml"

Offline alex

  • Developer
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2181
  • Karma: +37/-3
    • View Profile
    • HippoEDIT
Re: Auto close html tags
« Reply #8 on: October 17, 2009, 01:58:58 pm »
Hi Mikhail,

yes you are right. Just double checked - the formatting of inserted template is only done, when multi-line template is inserted :/
By initial logic, formatting was used more for correcting of the indent, but not a case. Because of this if you do formatting automatically when editing one line it would "jump", that is why it was disabled for this case.
Maybe this is a bug, when thinking about case correction, I would check and maybe extend the logic to apply only case correction in case of one line templates.

I have checked, explicit Format Selection it works with correction of case, but I think this is not what not want.

Yes, schema file is case sensitive. And thanks for converting it to lower case. From one side I can replace default code templates by lower case version from you, or from another side I can place it in the library in HTML section as additional file, that people can access it. Also can be moved to Syntax Files board to HTML post.

Best regards,
Alex.


Offline Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 775
  • Karma: +6/-0
    • View Profile
Re: Auto close html tags
« Reply #9 on: October 17, 2009, 02:15:31 pm »

- Oh, i am too late. Alex was first. My post was delayed by family-things  ;D

-----------------------------------------------------------------------------



Hi Mikhail, thanks for sharing!

----------
Test:

"Tools > Options... > [+ ] Formating > Smart Helpers > Case correction" = lowercase
"Tools > Options... > [+ ] Formating > Smart Helpers > Smart Helpers" = [X]Format after every paste

Result:

<table>
<tr>
<td>

<TR></TR>
<FONT SIZE=""></FONT>
<A HREF="huhu">jojo[/url]
<table>
<tr>
<td>

<td>
</table>
<td>
</table>


-------------------

Test 2:
> Or you can use Format Selection keeping Case correction set to desired value.


"Tools > Options... > [+ ] Formating > Smart Helpers > Case correction" = lowercase
"Format > Format Selection" or "Format > Format All"

All (selected) keywords are case changed following the "Smart Helpers > Case correction" setting.
All non-keyworks (all other words) are not case changed. Fine!
I have also noticed that the indenting was optimized.

Is it that what "Format > Format Selection" should work?
Then i would suggest to change the name of this item.
Perhaps to something like:
"Format > Format Keywords in Selection" and "Format > Format All Keywords"

So i can better guess what this option does.

Offline alex

  • Developer
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2181
  • Karma: +37/-3
    • View Profile
    • HippoEDIT
Re: Auto close html tags
« Reply #10 on: October 17, 2009, 02:25:36 pm »
Hi Stefan,

no main purpose of the Format Selection is to adopt indentation levels and only then case correction.
So changing to Format Keywords in Selection would be not really correct.

Best regards,
Alex.

 

Related Topics

  Subject / Started by Replies Last post
1 Replies
1962 Views
Last post February 15, 2009, 03:53:40 pm
by alex
1 Replies
1570 Views
Last post April 28, 2009, 11:01:52 pm
by alex
1 Replies
2193 Views
Last post February 09, 2011, 12:12:16 am
by alex
3 Replies
3614 Views
Last post September 06, 2012, 11:52:32 pm
by alex
8 Replies
2520 Views
Last post November 19, 2012, 12:26:59 am
by alex