All Projects → brijeshb42 → monaco-ace-tokenizer

brijeshb42 / monaco-ace-tokenizer

Licence: MIT License
Syntax highlighting support for additional languages in monaco-editor

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to monaco-ace-tokenizer

ZSpider
基于Electron爬虫程序
Stars: ✭ 37 (-37.29%)
Mutual labels:  monaco-editor
wiql-editor
Search work items with wiql queries.
Stars: ✭ 30 (-49.15%)
Mutual labels:  monaco-editor
rust-monaco
Rust WASM bindings for the Monaco Editor
Stars: ✭ 23 (-61.02%)
Mutual labels:  monaco-editor
Operational-Transformation
A collection of Algorithms to Synchronise changes across multiple clients using Operational Transformation
Stars: ✭ 25 (-57.63%)
Mutual labels:  monaco-editor
monaco-editor-esm-webpack-plugin
No description or website provided.
Stars: ✭ 25 (-57.63%)
Mutual labels:  monaco-editor
Blazaco
A Blazor Component utilizing the Monaco editor by Microsoft
Stars: ✭ 23 (-61.02%)
Mutual labels:  monaco-editor
monaco-editor-custom-intellisense
Code from the "Custom IntelliSense with Monaco Editor" post
Stars: ✭ 23 (-61.02%)
Mutual labels:  monaco-editor
vue-eslint-editor
A code editor component to play ESLint.
Stars: ✭ 35 (-40.68%)
Mutual labels:  monaco-editor
react-monacoeditor
Monaco Editor component for React.
Stars: ✭ 191 (+223.73%)
Mutual labels:  monaco-editor
editor.sh
Yet another live programming environment for collaborative code editing and running.
Stars: ✭ 29 (-50.85%)
Mutual labels:  monaco-editor
sprite
🖌 Draw charts in code. Render in real-time. Embed anywhere as .png.
Stars: ✭ 202 (+242.37%)
Mutual labels:  monaco-editor
emmet-monaco
Emmet support for monaco-editor
Stars: ✭ 19 (-67.8%)
Mutual labels:  monaco-editor
monaco-loader
The utility to easy setup monaco-editor into your browser
Stars: ✭ 85 (+44.07%)
Mutual labels:  monaco-editor
V2releases
A friendly ARM assembler and simulator for educational use
Stars: ✭ 46 (-22.03%)
Mutual labels:  monaco-editor
use-monaco
Use 🗒️ monaco-editor in any ⚛️ React app with simple hooks 🎣
Stars: ✭ 85 (+44.07%)
Mutual labels:  monaco-editor
mongood
A MongoDB GUI with Fluent Design
Stars: ✭ 674 (+1042.37%)
Mutual labels:  monaco-editor
ovid-editor
Adobe panel providing the most advanced scripting environment possible -- Typescript, app DOM autocomplete, full I/O features and more
Stars: ✭ 43 (-27.12%)
Mutual labels:  monaco-editor
vite-vue3-lowcode
vue3.x + vite2.x + vant + element-plus H5移动端低代码平台 lowcode 可视化拖拽 可视化编辑器 visual editor 类似易企秀的H5制作、建站工具、可视化搭建工具
Stars: ✭ 1,309 (+2118.64%)
Mutual labels:  monaco-editor
ng-monaco-editor
Angular wrapper for monaco-editor.
Stars: ✭ 22 (-62.71%)
Mutual labels:  monaco-editor
mmpm
MagicMirror Package Manager
Stars: ✭ 104 (+76.27%)
Mutual labels:  monaco-editor

monaco-ace-tokenizer

npm version

An alternative tokenizer for monaco-editor using ace's tokenization. See demo. Try to select kotlin or elixir in the demo.

This library is relevant only till monarch definitions of all the remaining languages are added directly in monaco-editor itself. Untill then, it can be used if you do not want to use web assembly.

I have observed that syntax highlighting for a particular language is better with ace's tokenizer when compared to it's monarch counterpart. This may not be true for all the languages (I observed for clojure) though.

Install

Webpack/browserify

npm install monaco-ace-tokenizer
import * as monaco from 'monaco-editor';
import { registerRulesForLanguage } from 'monaco-ace-tokenizer';
import KotlinHighlightRules from 'monaco-ace-tokenizer/lib/ace/definitions/kotlin';

monaco.languages.register({
  id: 'kotlin',
});
registerRulesForLanguage('kotlin', new KotlinHighlightRules());

This repo already contains definitions for 18 languages not yet available directly in monaco. If you need highlighting for a language which is not available here, you can copy over files from original ace project to your own project and modify it such that it's default export is the rule class. Check out any of the definition files already available in src/ace/defintions. Most of the highlight rules require TextHighlightRules, DocCommentHighlightRules and oop. They are directly exported in this project so that you don't have to modify the copied file too much. Example -

  • somelang.js
import { TextHighlightRules, DocCommentHighlightRules, oop } from 'monaco-ace-tokenizer';

// Copied syntax file
var SomeLangHighlightRules = function() {
  // internal defintions you probably don't need to change
  // unless there is some extra dependency other that the 3 already imported.
}
oop.inherits(SomeLangHighlightRules, TextHighlightRules);

export default SomeLangHighlightRules;
// some lang files may also depend on DocCommentHighlightRules

This file can then be used as -

import * as monaco from 'monaco-editor';
import { registerRulesForLanguage } from 'monaco-ace-tokenizer';
import SomeLangHighlightRules from './somelang'; // in your project directory

const langId = 'somelang';
monaco.languages.register({
  id: langId,
});
registerRulesForLanguage(langId, new SomeLangHighlightRules());

If some language definition file requires any other dependency, you can copy over that file too to your project and modify accordingly.

An array of all available languages in monaco-ace-tokenizer is also exported in case you need it.

import { AVAILABLE_LANGUAGES } from 'monaco-ace-tokenizer';

See src/lazy.js if you want to register languages but only load their definitions dynamically when they are used for the first time in your editor.

AMD

If you are using the official guide to integrate AMD version of monaco, this is how you can use monaco-ace-tokenizer -

<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
</head>
<body>
  <div id="container" style="width:800px;height:600px;border:1px solid grey"></div>

  <script src="https://unpkg.com/monaco-editor/min/vs/loader.js"></script>
  <script>
    require.config({
      paths: {
        'vs': 'https://unpkg.com/monaco-editor/min/vs',
        'tokenizer': 'https://unpkg.com/monaco-ace-tokenizer/dist',
      }
    });
    require(['vs/editor/editor.main', 'tokenizer/monaco-tokenizer', 'tokenizer/definitions/kotlin'], function(a, MonacoAceTokenizer, KotlinDefinition) {
      monaco.languages.register({
        id: 'kotlin'
      });
      MonacoAceTokenizer.registerRulesForLanguage('kotlin', new KotlinDefinition.default);
      var editor = monaco.editor.create(document.getElementById('container'), {
        value: '',
        language: 'kotlin'
      });
    });
    /* To load All languages */
    require(['vs/editor/editor.main', 'tokenizer/monaco-tokenizer'], function(_, MonacoAceTokenizer) {
      MonacoAceTokenizer.AVAILABLE_LANGUAGES.forEach(lang => {
        require(['tokenizer/definitions/' + lang], function(LangDefinition) {
          monaco.languages.register({
            id: lang,
          });
          MonacoAceTokenizer.registerRulesForLanguage(lang, new LangDefinition.default);
        });
      });
    });
  </script>
</body>
</html>
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].