{"_id":"54d5635732d98b0d00384b16","parentDoc":null,"category":{"_id":"551f39be6886f8230055f02a","__v":5,"pages":["551f39d0610f400d00837ec2","551f39ef610f400d00837ec4","551f3a0b50a0fc210057968c","551f3a164986f62b00a720e0","55206797623ff50d009b2bdf"],"project":"54d53c7b23010a0d001aca0c","version":"54d5635532d98b0d00384afb","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-04-04T01:09:18.662Z","from_sync":false,"order":10,"slug":"language-modes","title":"Language Modes"},"project":"54d53c7b23010a0d001aca0c","user":"54cfa8e1a8a4fd0d00b7fd1d","version":{"_id":"54d5635532d98b0d00384afb","project":"54d53c7b23010a0d001aca0c","__v":10,"forked_from":"54d53c7c23010a0d001aca0f","createdAt":"2015-02-07T00:59:01.934Z","releaseDate":"2015-02-07T00:59:01.934Z","categories":["54d5635632d98b0d00384afc","54d5635632d98b0d00384afd","54d5635632d98b0d00384afe","54d5635632d98b0d00384aff","54d5635632d98b0d00384b00","54d5635632d98b0d00384b01","54d5635632d98b0d00384b02","54d652097e05890d006f153e","54dd1315ca1e5219007e9daa","54e21e2b22de1c230094b147","54e68e62a43fe13500db3879","54fa1d3fe7a0ba2f00306309","551c453a23a1ee190034d19a","551df586e52a0b23000c62b6","551f39be6886f8230055f02a","55a6720751457325000e4d97"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"","version_clean":"0.1.0","version":"0.1"},"__v":8,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-02-07T00:08:52.762Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":7,"body":"There is a tool that will take an existing tmlanguage file and do its best to convert it into Javascript for Ace to consume. Here's what you need to get started:\n\n1. In the Ace repository, navigate to the [tools](https://github.com/ajaxorg/ace/tree/master/tool) folder.\n1. Run `npm install` to install required dependencies.\n1. Run `node tmlanguage.js <path_to_tmlanguage_file>;` for example, `node <path_to_tmlanguage_file> /Users/Elrond/elven.tmLanguage`\n\nTwo files are created and placed in 'lib/ace/mode': one for the language mode, and one for the set of highlight rules.\n\n# A Note on Accuracy\n\nYour '.tmlanguage' file will then be converted to the best of the converter’s ability. It is an understatement to say that the tool is imperfect. Probably, language mode creation will never be able to be fully autogenerated. There's a list of non-determinable items; for example:\n\n**The use of regular expression lookbehinds**\n\nThis is a concept that JavaScript simply does not have and needs to be faked\n\n**Deciding which state to transition to**\n\nWhile the tool does create new states correctly, it labels them with generic terms like `state_2`, `state_10`, etc.\n\n**Extending modes**\n\nMany modes say something like `include source.c`, to mean, “add all the rules in C highlighting.” That syntax does not make sense to Ace or this tool (though of course you can extending existing highlighters).\n\n**Rule preference order**\n\n**Gathering keywords**\n\nMost likely, you’ll need to take keywords from your language file and run them through `createKeywordMapper()`\n\nHowever, the tool is an excellent way to get a quick start, if you already possess a tmlanguage file for you language.","excerpt":"","slug":"import-a-textmate-bundle","type":"basic","title":"Import a TextMate Bundle"}

Import a TextMate Bundle


There is a tool that will take an existing tmlanguage file and do its best to convert it into Javascript for Ace to consume. Here's what you need to get started: 1. In the Ace repository, navigate to the [tools](https://github.com/ajaxorg/ace/tree/master/tool) folder. 1. Run `npm install` to install required dependencies. 1. Run `node tmlanguage.js <path_to_tmlanguage_file>;` for example, `node <path_to_tmlanguage_file> /Users/Elrond/elven.tmLanguage` Two files are created and placed in 'lib/ace/mode': one for the language mode, and one for the set of highlight rules. # A Note on Accuracy Your '.tmlanguage' file will then be converted to the best of the converter’s ability. It is an understatement to say that the tool is imperfect. Probably, language mode creation will never be able to be fully autogenerated. There's a list of non-determinable items; for example: **The use of regular expression lookbehinds** This is a concept that JavaScript simply does not have and needs to be faked **Deciding which state to transition to** While the tool does create new states correctly, it labels them with generic terms like `state_2`, `state_10`, etc. **Extending modes** Many modes say something like `include source.c`, to mean, “add all the rules in C highlighting.” That syntax does not make sense to Ace or this tool (though of course you can extending existing highlighters). **Rule preference order** **Gathering keywords** Most likely, you’ll need to take keywords from your language file and run them through `createKeywordMapper()` However, the tool is an excellent way to get a quick start, if you already possess a tmlanguage file for you language.