gama-platform / gama-platform.github.io

Repository for the website of GAMA
https://gama-platform.github.io/
GNU General Public License v3.0
4 stars 2 forks source link

custom syntax highlighting of gaml code in github markdown #49

Open sriramab opened 6 years ago

sriramab commented 6 years ago

Hi,

I have been wondering if it is possible to have some custom gaml highlighting for code blocks in github markdown. For example, if you use a code block code block with a language preference for r , it highlights r keywords as below

library(gaml)
k=mean(rnorm(100,1,0.1)

or for python as below:

import numpy as n
float f = n.sin(90)

or java as below:

import numpy
float f = n.sin(90);

Is it possible to create a custom syntax highlight for gaml language on github markdown? I do not know how easy or difficult it is, but could be nice in sharing or exhibiting code on github tutorials.

RoiArthurB commented 5 years ago

For the Github Wiki I'm afraid that it's impossible (mainly because we can't do any design more than the MarkDown Structure of the file). But I'm working on it for the gama-platform website :)

RoiArthurB commented 2 years ago

Since we moved to Docusaurus V2, CodeBlocks are rendered using the Prism engine (source).

It's not easier to implement, but it's a famous tool in JS world and used by Ghost, MDN, etc; so it may be easy to extend it to other usages (like, maybe, a plugin for GitHub Highlight library :smile: ).

I won't work on it any time soon, but if anyone wants to do it, feel free to help :wink: It can either be a PR on the main project, or just a language extension added only on the website

benoitgaudou commented 1 year ago

Hi @RoiArthurB ,

Please find below a very small js tentative for GAML (rename it as .js). prism-gaml.txt

If GAMA produces such a file you can use it on the website?

RoiArthurB commented 1 year ago

Hi @benoitgaudou ,

You're quick implementation does work good, see below :

Before After
image image
image image

So if you can generate this file from GAMA, I'll be easily able to integrate it during the website compilation 👌

I also made the branch syntax-gaml to work on it :)

benoitgaudou commented 1 year ago

Thanks! I am not so impressed by the after version : it was supposed to highlight the statement names also ... but get italic instead, I guess it is mainly due to the css ... Thanks for the integration and for the branch.... but how to use this new branch ? I can produce the website by myself locally ?

RoiArthurB commented 1 year ago

@benoitgaudou

I am not so impressed by the after version : it was supposed to highlight the statement names also ... but get italic instead, I guess it is mainly due to the css ...

Yes, we probably can also tweak the color theme or badly used the syntax to just have appropriate colors on the wiki 🤷 But it's minor tweaking in my point of view :)

Thanks for the integration and for the branch.... but how to use this new branch ? I can produce the website by myself locally ?

Yes you can, it's a little tricky so either we can do it together, otherwise it's mostly following step-by-step the github action here : https://github.com/gama-platform/gama-platform.github.io/blob/sources/.github/workflows/github-travis.yml

You'll need to have Python3, pip (package manager for Python), NodeJS, yarn (or npm; both package managers for NodeJS) and bash - I know it's a bit heavy and complex 😅😅

RoiArthurB commented 1 year ago

Re-opening to work on full Github's syntax support color (forgot that initial issue request 🙈)