Syntax highlighting like on Github
On Github I can choose a language formatter by typing the language identifier after the first
``` 3 backticks, like this:
The extra space should be disregarded, only there to bypass the formatting end tag.
Would that be possible to implement in talkyard?
- 4 replies
- KajMagnus @KajMagnus2018-06-25 04:29:11.575Z
Hello Christian! Yes and i'd like to do that. Now the nearest time, I'm first going to add a rich text editor, and then I'll need to refactor code related to editing & Markdown (well, Commonmark), so I think it's better to wait with integrating with a highlighting lib, until after that.
Hi @KajMagnus. Thanks for getting back to me on this. As you know I didn't receive a notification for this until now.
I understand it makes sense to make rich text editing work first.
Fwiw we integrated Facebook's draftjs which is a React based rich text editor that is very well designed and engineered, and it just took a day or two. It is a great modern, React based way of creating possibly very complex mechanisms for code editing.
- KajMagnus @KajMagnus2018-08-20 11:56:22.391Z
Hmm likely it'll take long, before syntax highlighting gets built in. Maybe better to add Prism.js yourself, for syntax highlighting, for now (see https://www.talkyard.io/-84/strange-problem-with-prismjs-syntax-highlighting ) — then you'll get something that works now directly.
(The other problem Mateusz refers to, in that topic, was that a too old Prism.js version was in use, + a max JS size limit which has since been increased so should be fine.)
Thanks for the tips about Draft. I read a while ago about Draft, ProseMirror, and "all other rich text editors out there", and ProseMirror got my attention because it also supports Markdown (converting between rich text and Markdown), and also has collaborative editing (many people editing the same text in parallel).
Now I see that Draftjs also kind of has Markdown support: https://github.com/withspectrum/draft-js-markdown-plugin. — I suppose I'd better take a look at Draftjs, ProseMirror and others, later when it's time to start with adding a rich text editor. The things I'm thinking can be take time, is to "port" [the plugins in use now and written for markdown-it] to the new editor. (There're plugins for
@mentionsand youtube links —> videos, for example.)