1

I am editing a long HTML document in Kate, and I'd love to be able to "close" the parts I'm not currently working on. But this is a new document, and the highest level of modularization uses section, not div. This is a HTML tag, and my Kate (version 3.8.4) doesn't recognize it. It works fine with div and other older elements.

I started looking around if there is a way to get this support in Kate. I can imagine that my version is old (it is what came with Debian stable), but I don't want to upgrade it unless the newer one really has the support for HTML5. Strangely, I can't find much documentation on what I need: neither a list of "newest features" of Kate, nor even information which number is the most current version.

Does the newest version of Kate have HTML5 support? If yes, is it advisable to install it from source? After all, many of my programs which came from the repositories rely on Kate, for example Kile? And if it doesn't have HTML5 support, is there another way to get it, maybe with some kind of plugin?

2

I have Kate 3.13.2 installed and it exhibits the same behavior you describe. However, you can alter Kate to have your desired behavior by editing the html syntax schema Kate uses.

First, find the html syntax file for Kate. For my installation this is at

/usr/share/apps/katepart/syntax/html.xml

Near the top of this file is a list of tags that define regions and it is the these regions that are foldable. To add to this list, just copy and paste a line for the opening and closing tag and edit appropriately. Below is a diff showing my addition and a few lines on either side of it.

*** html.xml.orig   2014-06-25 19:40:40.000000000 +0000
--- html.xml    2014-06-25 19:41:08.000000000 +0000
***************
*** 23,28 ****
--- 23,29 ----
      <RegExpr attribute="Element" context="JS" String="&lt;script\b" insensitive="TRUE" beginRegion="script" />
      <RegExpr attribute="Element" context="El Open" String="&lt;pre\b" insensitive="TRUE" beginRegion="pre" />
      <RegExpr attribute="Element" context="El Open" String="&lt;div\b" insensitive="TRUE" beginRegion="div" />
+     <RegExpr attribute="Element" context="El Open" String="&lt;section\b" insensitive="TRUE" beginRegion="section" />
      <RegExpr attribute="Element" context="El Open" String="&lt;table\b" insensitive="TRUE" beginRegion="table" />
      <RegExpr attribute="Element" context="El Open" String="&lt;ul\b" insensitive="TRUE" beginRegion="ul" />
      <RegExpr attribute="Element" context="El Open" String="&lt;ol\b" insensitive="TRUE" beginRegion="ol" />
***************
*** 30,35 ****
--- 31,37 ----
      <RegExpr attribute="Element" context="El Open" String="&lt;&name;" />
      <RegExpr attribute="Element" context="El Close" String="&lt;/pre\b" insensitive="TRUE" endRegion="pre" />
      <RegExpr attribute="Element" context="El Close" String="&lt;/div\b" insensitive="TRUE" endRegion="div" />
+     <RegExpr attribute="Element" context="El Close" String="&lt;/section\b" insensitive="TRUE" endRegion="section" />
      <RegExpr attribute="Element" context="El Close" String="&lt;/table\b" insensitive="TRUE" endRegion="table" />
      <RegExpr attribute="Element" context="El Close" String="&lt;/ul\b" insensitive="TRUE" endRegion="ul" />
      <RegExpr attribute="Element" context="El Close" String="&lt;/ol\b" insensitive="TRUE" endRegion="ol" />

Re-load Kate and open an html file and you will now be able to fold at the section tag. This doesn't add full HTML5 support, but does satisfy your need to fold on this tag. Also note that you'll want to keep a backup of this edited file as it will likely be clobbered next time Kate is updated.

Results:
kate

  • This looks very promising, but how do I find this file? I have /usr/share/apps, and it has folders for Konqueror and Konsole. Does this mean that I should create a Kate directory there, or that I should look for the syntax file somewhere else? – rumtscho Jun 25 '14 at 19:54
  • @rumtscho I found my syntax file with the command locate kate | grep html – casey Jun 25 '14 at 19:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.