1. Home
  2. Ideas

Syntax highlighting like on Github

By Christian Scheuer @chrscheuer2018-06-16 12:44:35.746Z

On Github I can choose a language formatter by typing the language identifier after the first ``` 3 backticks, like this:

my javascript code here
`` `

The extra space should be disregarded, only there to bypass the formatting end tag.

Would that be possible to implement in talkyard?

  • 1 replies
  1. 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.

    I had a look at PrismJS and HighlightJS and some other syntax highlighting libraries. Is there anyone you like better than the others? It'd run server side, so one wouldn't need to load any extra Javascript code in the browsers — except for then opening the editor. Then it'd be needed, in the editor preview. Not sure how to determine which languages to load, then. If loading all languages, to make the preview work for "everything", ... then that might be a bit much Javascript, for mobile phones. On the other hand, trying to load only the languages that are needed, is a bit technically more complicated ... Will need to think a bit about how to do this :- ) maybe it's ok to, for a start, just support say PrismJS' default langauges? Which languages do you have in mind to highlight?

    (Sorry for the a bi late reply, I a bit forgot about this, until recently when someone asked about PrismJS here — and, turns out that with an extra Javascript code snippet, one can make PrismJS work, in the browser (no server side rendering for now), more details in that topic)