English 中文(简体)
Eclipse - 如何扩大超文本编辑以添加习俗标签?
原标题:Eclipse - how to extend HTML editor to add custom tags?

我撰写了一份申请,并在“超文本”版中,我有“定制标签”(当然,这些标签在服务器上被捆绑,终端用户将其当作有效的超文本处理)。 习俗标签使用实例:

<html>
<body>
...
    <Gallery type="grid" title="My Gallery" />
...
</body>
</html>

1.) How can I have eclipse recognize my custom tags inside of HTML code and add syntax highlighting to them?
2.) How can I add auto-suggestions to my custom tags? For example if I type "<Gallery " press "Ctrl+Space" - in the list of available attributes it shows me "type" and "title" and if I type "<Gallery type=" press "Ctrl+Space" I would see list of available values only for tag "Gallery" and its attribute "type".

提前感谢!

最佳回答

可悲的是,没有什么容易的:你必须为此向你们自己的传教,然后增加你的外在内容和基文法(超文本)。

如果您有主人的话,你可以利用这个词来强调(严格地说,这种简单的灵活做法就足够了);一个好的主人可以支持内容(你术语中的选择)。

洞穴:

  • Creating a parser for HTML is not an easy task. Maybe by aiming at a more often used subset is feasible.
  • If a parser exists, the editor parts are still hard to get well.

一方面,一些帮助:你可以使用一些文字编辑发电机来缓解你的工作:

  • Eclipse IMP http://www.eclipse.org/imp/ can in theory handle any type of parser, but currently it is most optimized for LPG. The documentation is scarce, but the developers are helpful in the forums.
  • Xtext http://www.eclipse.org/Xtext/ got quite a hype for creating text editors for DSLs. The generated editors are quite nice out of the box, but is not the best solution for large files. Has a really helpful developer community.
  • EMFText http://www.emftext.org/index.php/EMFText is a lesser known entity - I don t know it in details, but I guess, it is similar to Xtext.
问题回答

不是你想要的,而是可以帮助你:

  1. You can try the Aptana Plug-in for Eclipse. It allows to write your own regular expression for HTML validation, so a custom tag would be ignored by the validator. E.g.:

    gallery.

  2. Eclipse allows you to add simple auto-suggestions via Templates. On Eclipse 3.7.1 (Indigo) + PHP Dev Tools (PDT) 3.0.0: Window > Preferences > Web > HTML Files > Editor > Templates

I know its been a long time since this Q was asked, but I hope this might help others like myself that reach this in search of a solution.

So, When using Eclipse (Mars.1 Release (4.5.1) - and possibly earlier - I did not check).

Go to Window - Prefrences
Then in the dialog that opens go to Web - HTML Files - Editor - Validation.
On the right side:

  1. under Ignore specified element names in validation and enter the list of custom elements you use. (e.g. Gallery,tab,tabset,my-element-directives-*)
  2. you might also like to go under Ignore specified attribute names in validation do the same for your custom attributes.(e.g. ng-*,my-attr-directives-*)

值得注意的两点:

  1. After letting eclipse do a full validation you must also close the file and reopen it to have the warnings removed from the source code.
  2. Using this method would ignore those attributes under any element. I don t think there is a simple way to tell it to ignore some-attribute only if its a child of some-element.

我发现模板是一种ok择,但请看我们是否能够鼓励更强有力的解决办法;请就此一刻和表决:





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签