~sircmpwn/sr.ht-discuss

2 2

Question about syntax highlighting libraries

Details
Message ID
<20211212132739.1153f8dccfac0575c8d39c74@disroot.org>
DKIM signature
pass
Download raw message
I have created my own programming language. Its syntax is similar to
Crystal, so I am using the Crystal .cr file extension. In Ace,
Pygments, and Visual Studio Code, my code is given nice highlighting
colours. On sr.ht, everything appears green.

https://git.sr.ht/~cadence/collapse-lang/tree/main/item/advent/day11/part1.cr

In Ace, Pygments, highlight.js, and Visual Studio Code, my code
appears a lot better. In particular, words ending in `:` appear in a
different colour to other words and symbols.

  Demos:
  https://ace.c9.io/build/kitchen-sink.html
  https://pygments.org/demo/#try
  https://react-syntax-highlighter.github.io/react-syntax-highlighter/demo/

On paste.sr.ht, the highlighting is different and still incorrect.
Comment lines (leading #) are not distinguished from other text.

I've looked into the sr.ht code, but not gotten very far. I think it
uses the Ace and Pygments libraries, but I don't know why my code
doesn't appear properly.

--

I would like to write a patch to address whatever is causing this
unexpected behaviour.

Could you tell me which libraries sr.ht uses for syntax highlighting,
and do you know which files I should try to examine first?

Thanks so much.

- Cadence
Details
Message ID
<d8d70975-f0f3-4fc0-f7b0-f1aed7ec71af@ignaskiela.eu>
In-Reply-To
<20211212132739.1153f8dccfac0575c8d39c74@disroot.org> (view parent)
DKIM signature
pass
Download raw message
On 2021-12-12 02:27, Cadence Ember wrote:
> I would like to write a patch to address whatever is causing this
> unexpected behaviour.
> 
> Could you tell me which libraries sr.ht uses for syntax highlighting,
> and do you know which files I should try to examine first?
> 

sourcehut uses pygmets for rendering pages. This is probably a problem 
with language detection, but as far as I can see, it uses the 
pygments.guess_lexer_for_filename() for determining what the language 
is, and if that fails, it uses the shebang if it exists. I would look 
into whether that function works correctly by itself first.
Usage of pygments is in these files:

https://git.sr.ht/~sircmpwn/scm.sr.ht/tree/master/item/scmsrht/formatting.py
https://git.sr.ht/~sircmpwn/core.sr.ht/tree/master/item/srht/markdown.py
https://git.sr.ht/~sircmpwn/paste.sr.ht/tree/master/item/pastesrht/blueprints/public.py

ace editor is also used for interactive editors in paste.sr.ht and 
builds.sr.ht, but AFAIK builds is set to always use YAML and paste 
doesn't have highlighting.
Details
Message ID
<20211214235129.9e7a1d09c7dcb92abaef4a0a@disroot.org>
In-Reply-To
<d8d70975-f0f3-4fc0-f7b0-f1aed7ec71af@ignaskiela.eu> (view parent)
DKIM signature
pass
Download raw message
Thanks for your reply!

I have no idea what's happened but the first link from my first email,
where I said it all looks green, no longer looks green. It looks
great. So someone must have changed something on sr.ht. To whoever
that was, thank you as well!

Cadence

On Sun, 12 Dec 2021 02:54:06 +0200
Ignas Kiela <me@ignaskiela.eu> wrote:

> On 2021-12-12 02:27, Cadence Ember wrote:
> > I would like to write a patch to address whatever is causing this
> > unexpected behaviour.
> > 
> > Could you tell me which libraries sr.ht uses for syntax
> > highlighting, and do you know which files I should try to examine
> > first?
> > 
> 
> sourcehut uses pygmets for rendering pages. This is probably a
> problem with language detection, but as far as I can see, it uses the 
> pygments.guess_lexer_for_filename() for determining what the language 
> is, and if that fails, it uses the shebang if it exists. I would look 
> into whether that function works correctly by itself first.
> Usage of pygments is in these files:
> 
> https://git.sr.ht/~sircmpwn/scm.sr.ht/tree/master/item/scmsrht/formatting.py
> https://git.sr.ht/~sircmpwn/core.sr.ht/tree/master/item/srht/markdown.py
> https://git.sr.ht/~sircmpwn/paste.sr.ht/tree/master/item/pastesrht/blueprints/public.py
> 
> ace editor is also used for interactive editors in paste.sr.ht and 
> builds.sr.ht, but AFAIK builds is set to always use YAML and paste 
> doesn't have highlighting.
Reply to thread Export thread (mbox)