MarkEdit-app / MarkEdit

Just like TextEdit on Mac but dedicated to Markdown.
https://markedit.app
MIT License
1.08k stars 45 forks source link

Support more languages for syntax highlighting in code blocks #14

Closed somelinguist closed 1 year ago

somelinguist commented 1 year ago

Hi. What are your thoughts on supporting more languages for syntax highlighting in code blocks?

I have a fork (https://github.com/somelinguist/MarkEdit) that enables highlighting for fsharp and ocaml using @codemirror/legacy-modes/mode/mllike, which is already included in the app but not enabled.

Would you be open to me submitting a pull request?

Thanks for this great app!

cyanzhong commented 1 year ago

Hi @somelinguist, thanks for raising this. I initially tailored the language data to keep the bundler smaller. I will be careful about adding new ones but won't be strongly discouraged. Regarding your changes, would you mind opening a pull request?

This also reminds me one plan that I originally had, even I wanted to keep the app really simple, I think if there's a way to load transpiled CodeMirror extensions, it would be great to fit some needs. I don't have a clear path for now, let me think about it a little bit more.

Thank you!

somelinguist commented 1 year ago

Hi @cyanzhong. Thanks for sharing your thoughts about it. It makes sense to want to keep the app small and agile.

I've opened the pull request here https://github.com/MarkEdit-app/MarkEdit/pull/15

Is there anything I missed? It built everything on my machine and ran the tests with everything passing, and it works in the all. But I don't know if anything else is needed to make it complete.

F# is one of the languages I use frequently these days, so it was one of the first things I checked out in MarkEdit. :) I was glad to see that CodeMirror already had support for it.

Thanks again for the app.

cyanzhong commented 1 year ago

Thanks @somelinguist! I will check in as soon as the workflow passes, closing this.

stuffmc commented 4 days ago

Hey @cyanzhong do I see correctly that swift isn't supported/highlighted?

cyanzhong commented 3 days ago

@stuffmc It highlights swift: https://github.com/MarkEdit-app/MarkEdit/blob/main/CoreEditor/src/%40vendor/language-data/index.ts#L395

cyanzhong commented 2 days ago

With MarkEdit-api, we can add new language support like this:

import { LanguageDescription } from '@codemirror/language';
import { vue } from '@codemirror/lang-vue';
import { MarkEdit } from 'markedit-api';

const language = LanguageDescription.of({
  name: 'Vue',
  extensions: ['vue'],
  load: async() => vue(),
});

MarkEdit.addCodeLanguage(language);

Example project: https://github.com/MarkEdit-app/MarkEdit-lang-vue.

cyanzhong commented 2 days ago

Cc @somelinguist.

somelinguist commented 2 days ago

This looks good!