ajaxorg / ace

Ace (Ajax.org Cloud9 Editor)
https://ace.c9.io
Other
26.73k stars 5.28k forks source link

Extending markdown mode codeblocks #5190

Open cdbdev opened 1 year ago

cdbdev commented 1 year ago

Extending markdown mode

Hi,

Is it possible to extend the markdown mode to support more languages for codeblocks than the ones listed below:

this.createModeDelegates({
        javascript: require("./javascript").Mode,
        html: require("./html").Mode,
        bash: require("./sh").Mode,
        sh: require("./sh").Mode,
        xml: require("./xml").Mode,
        css: require("./css").Mode
    });

Or is there already a way to do this?

Thank you

Use Case

I'm using markdown for technical documentation on other languages than currently supported

Proposed Solution

No response

Other Information

No response

Acknowledgements

ACE version used

Latest

whazor commented 1 year ago

Hi, you could create your own custom mode and extend MarkdownMode, afterwards which you can call this.createModeDelegates again, and it should work. Or if you think the community would benefit from it, you could extend this method in ace/src/mode/markdown.js.

cdbdev commented 1 year ago

Thanks for your answer. So if I understand correctly, I would have to extend the sourcecode and rebuild with nodejs to be able to achieve this?

whazor commented 8 months ago

Contributing to Ace is actually relatively simple. There is no need to rebuild Ace.

Developing

  1. Run node static.js and open the link that is in the logs
  2. Click on kitchen-sink.html and see the kitchen sink
  3. Edit any of the files, in your case likely src/mode/markdown.js or src/snippets/markdown.snippets.js
  4. Refresh to see your changes

Testing

  1. npm install
  2. npm run test to run the tests

Then you contribute by creating a PR.