
我正在 Kate 中編輯一個很長的 HTML 文檔,我希望能夠「關閉」我目前未處理的部分。但這是一個新文檔,最高級別的模組化使用的是section
,而不是div
。這是一個 HTML 標籤,我的 Kate(版本 3.8.4)無法辨識它。它div
與其他舊元素配合得很好。
我開始四處尋找是否有辦法獲得凱特的支持。我可以想像我的版本很舊(這是 Debian stable 附帶的版本),但我不想升級它,除非較新的版本確實支援 HTML5。奇怪的是,我找不到太多關於我需要的文檔:既沒有凱特的“最新功能”列表,也沒有找到哪個版本是最新版本的信息。
最新版本的 Kate 有 HTML5 支援嗎?如果是,是否建議從來源安裝它?畢竟,我的許多來自儲存庫的程式都依賴 Kate,例如 Kile?如果它沒有 HTML5 支持,是否有其他方法來獲取它,也許使用某種插件?
答案1
我安裝了 Kate 3.13.2,它表現出與您描述的相同的行為。但是,您可以透過編輯 Kate 使用的 html 語法架構來變更 Kate 以獲得所需的行為。
首先,找到 Kate 的 html 語法檔。對於我的安裝,這是在
/usr/share/apps/katepart/syntax/html.xml
該文件頂部附近是定義區域的標籤列表,這些區域是可折疊的。要添加到此列表,只需複製並貼上一行作為開始和結束標記,然後進行適當的編輯。下面是一個差異,顯示了我添加的內容及其兩側的幾行。
*** 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="<script\b" insensitive="TRUE" beginRegion="script" />
<RegExpr attribute="Element" context="El Open" String="<pre\b" insensitive="TRUE" beginRegion="pre" />
<RegExpr attribute="Element" context="El Open" String="<div\b" insensitive="TRUE" beginRegion="div" />
+ <RegExpr attribute="Element" context="El Open" String="<section\b" insensitive="TRUE" beginRegion="section" />
<RegExpr attribute="Element" context="El Open" String="<table\b" insensitive="TRUE" beginRegion="table" />
<RegExpr attribute="Element" context="El Open" String="<ul\b" insensitive="TRUE" beginRegion="ul" />
<RegExpr attribute="Element" context="El Open" String="<ol\b" insensitive="TRUE" beginRegion="ol" />
***************
*** 30,35 ****
--- 31,37 ----
<RegExpr attribute="Element" context="El Open" String="<&name;" />
<RegExpr attribute="Element" context="El Close" String="</pre\b" insensitive="TRUE" endRegion="pre" />
<RegExpr attribute="Element" context="El Close" String="</div\b" insensitive="TRUE" endRegion="div" />
+ <RegExpr attribute="Element" context="El Close" String="</section\b" insensitive="TRUE" endRegion="section" />
<RegExpr attribute="Element" context="El Close" String="</table\b" insensitive="TRUE" endRegion="table" />
<RegExpr attribute="Element" context="El Close" String="</ul\b" insensitive="TRUE" endRegion="ul" />
<RegExpr attribute="Element" context="El Close" String="</ol\b" insensitive="TRUE" endRegion="ol" />
重新加載 Kate 並打開一個 html 文件,您現在可以在部分標籤處折疊。這不會添加完整的 HTML5 支持,但確實滿足了折疊此標籤的需要。另請注意,您需要保留此編輯檔案的備份,因為下次更新 Kate 時它可能會被破壞。
結果: