Syntax highlighting

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Syntax highlighting

Craig Dabelstein
Hi all,

I'd like to add LilyPond syntax highlighting to highlight.js ( https://highlightjs.readthedocs.io/en/latest/ ) so that I can experiment with documentation tools such as mkDocs/readthedocs. Does anyone have any experience with this? Would it just be a matter of getting one of the current syntax packages (such as https://github.com/yrammos/SubLilyPond or https://github.com/yrammos/AtLilyPond , and trying to modify them?

All the best,

Craig


--
Craig Dabelstein
Owner
Maxime's Music
M: 0404884173
A: 19 Twelfth Ave,  Kedron QLD 4031, Australia
W: concertbandmusicstore.com[hidden email]

 
Reply | Threaded
Open this post in threaded view
|

Re: Syntax highlighting

Federico Bruni-2


Il giorno mar 14 gen 2020 alle 09:13, Craig Dabelstein
<[hidden email]> ha scritto:

> Hi all,
>
> I'd like to add LilyPond syntax highlighting to highlight.js (
> https://highlightjs.readthedocs.io/en/latest/ ) so that I can
> experiment with documentation tools such as mkDocs/readthedocs. Does
> anyone have any experience with this? Would it just be a matter of
> getting one of the current syntax packages (such as
> https://github.com/yrammos/SubLilyPond or
> https://github.com/yrammos/AtLilyPond , and trying to modify them?
>
>

I don't have any experience with highlight.js.
Some years ago I started writing a Pygments definition for LilyPond but
then I gave up or simply forgot about it.

The Sublimetext and Atom packages might be useful as a reference, but I
guess that highlight.js will need its own syntax so you'd better start
from scratch.

The problem with syntax highlighting is maintainance. LilyPond syntax
changes and a manually compiled list must be updated manually for every
new stable release.

See also python-ly:
https://github.com/frescobaldi/python-ly/blob/master/ly/words.py


Personally I'd be more interested in adding lilypond to Pygments.
Pygments can be easily exported to chroma¹ (for Hugo² static site
generator).
And it seems Pygments may be used also in Mkdocs, see this discussion:
https://github.com/mkdocs/mkdocs/issues/1588

¹ https://github.com/alecthomas/chroma
² https://gohugo.io/content-management/syntax-highlighting/




Reply | Threaded
Open this post in threaded view
|

Re: Syntax highlighting

Urs Liska-3
Am Dienstag, den 14.01.2020, 12:27 +0100 schrieb Federico Bruni:

>
> Il giorno mar 14 gen 2020 alle 09:13, Craig Dabelstein
> <[hidden email]> ha scritto:
> > Hi all,
> >
> > I'd like to add LilyPond syntax highlighting to highlight.js (
> > https://highlightjs.readthedocs.io/en/latest/ ) so that I can
> > experiment with documentation tools such as mkDocs/readthedocs.
> > Does
> > anyone have any experience with this? Would it just be a matter of
> > getting one of the current syntax packages (such as
> > https://github.com/yrammos/SubLilyPond or
> > https://github.com/yrammos/AtLilyPond , and trying to modify them?
> >
> >
>
> I don't have any experience with highlight.js.
> Some years ago I started writing a Pygments definition for LilyPond
> but
> then I gave up or simply forgot about it.
>
> The Sublimetext and Atom packages might be useful as a reference, but
> I
> guess that highlight.js will need its own syntax so you'd better
> start
> from scratch.
>
> The problem with syntax highlighting is maintainance. LilyPond
> syntax
> changes and a manually compiled list must be updated manually for
> every
> new stable release.
>
> See also python-ly:
> https://github.com/frescobaldi/python-ly/blob/master/ly/words.py
>

I'm not sure where and how, but there is also a substantial part of
python-ly's knowledge that is retrieved directly from LilyPond (either
from the sources or by running some LilyPond code). As far as I know
python-ly is the most comprehensive syntax highlighting solution on the
market (although still 2.18.2), and I think it would be good to find a
way use that “knowlegde” to generate syntax highlighting for arbitrary
other highlighters from that set of data.

>
> Personally I'd be more interested in adding lilypond to Pygments.
> Pygments can be easily exported to chroma¹ (for Hugo² static site
> generator).
> And it seems Pygments may be used also in Mkdocs, see this
> discussion:
> https://github.com/mkdocs/mkdocs/issues/1588

Pygments is also what Pandoc uses for its syntax highlighting, so that
would also make sense for that (e.g. generating PDF documentation from
Markdown).

Urs

>
> ¹ https://github.com/alecthomas/chroma
> ² https://gohugo.io/content-management/syntax-highlighting/
>
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Syntax highlighting

Federico Bruni-2
Il giorno mar 14 gen 2020 alle 12:34, Urs Liska <[hidden email]>
ha scritto:
> Pygments is also what Pandoc uses for its syntax highlighting, so that
> would also make sense for that (e.g. generating PDF documentation from
> Markdown).

Are you sure?
I think that pygments is the name of the default style in Pandoc, but
the highlight library is a Haskell library called skylighting:
https://pandoc.org/MANUAL.html#syntax-highlighting
https://github.com/jgm/skylighting

It seems Wilbert contributed the definitions for lilypond syntax:
https://github.com/KDE/syntax-highlighting/blob/master/data/syntax/lilypond.xml

About 10 days ago I wanted to share this in the open issue in
Frescobaldi tracker but I forgot to do it.
I remember I found the lilypond file definition somewhere else...




Reply | Threaded
Open this post in threaded view
|

Re: Syntax highlighting

Craig Dabelstein
Thank you gentlemen,

I'll have a go at taking the python-ly work and seeing if I can use it work to make syntax highlighting with pygments. It's highly possible that I will totally fail, but I'll give it a try.

Craig


On Tue, 14 Jan 2020 at 23:38, Federico Bruni <[hidden email]> wrote:
Il giorno mar 14 gen 2020 alle 12:34, Urs Liska <[hidden email]>
ha scritto:
> Pygments is also what Pandoc uses for its syntax highlighting, so that
> would also make sense for that (e.g. generating PDF documentation from
> Markdown).

Are you sure?
I think that pygments is the name of the default style in Pandoc, but
the highlight library is a Haskell library called skylighting:
https://pandoc.org/MANUAL.html#syntax-highlighting
https://github.com/jgm/skylighting

It seems Wilbert contributed the definitions for lilypond syntax:
https://github.com/KDE/syntax-highlighting/blob/master/data/syntax/lilypond.xml

About 10 days ago I wanted to share this in the open issue in
Frescobaldi tracker but I forgot to do it.
I remember I found the lilypond file definition somewhere else...





--
Craig Dabelstein
Owner
Maxime's Music
M: 0404884173
A: 19 Twelfth Ave,  Kedron QLD 4031, Australia
W: concertbandmusicstore.com[hidden email]

 
Reply | Threaded
Open this post in threaded view
|

Re: Syntax highlighting

Craig Dabelstein
Federico,

Is it just me or is the documentation for Pygments really hard to understand? I can't even find anywhere they discuss the setup.py file.

I've opened a repo (https://github.com/craigdab/pygments-lilypond-test) and cut and paste from other peoples repositories as a start, but I really have no idea what I'm doing.

Craig


On Wed, 15 Jan 2020 at 10:38, Craig Dabelstein <[hidden email]> wrote:
Thank you gentlemen,

I'll have a go at taking the python-ly work and seeing if I can use it work to make syntax highlighting with pygments. It's highly possible that I will totally fail, but I'll give it a try.

Craig


On Tue, 14 Jan 2020 at 23:38, Federico Bruni <[hidden email]> wrote:
Il giorno mar 14 gen 2020 alle 12:34, Urs Liska <[hidden email]>
ha scritto:
> Pygments is also what Pandoc uses for its syntax highlighting, so that
> would also make sense for that (e.g. generating PDF documentation from
> Markdown).

Are you sure?
I think that pygments is the name of the default style in Pandoc, but
the highlight library is a Haskell library called skylighting:
https://pandoc.org/MANUAL.html#syntax-highlighting
https://github.com/jgm/skylighting

It seems Wilbert contributed the definitions for lilypond syntax:
https://github.com/KDE/syntax-highlighting/blob/master/data/syntax/lilypond.xml

About 10 days ago I wanted to share this in the open issue in
Frescobaldi tracker but I forgot to do it.
I remember I found the lilypond file definition somewhere else...





--
Craig Dabelstein
Owner
Maxime's Music
M: 0404884173
A: 19 Twelfth Ave,  Kedron QLD 4031, Australia
W: concertbandmusicstore.com[hidden email]

 


--
Craig Dabelstein
Owner
Maxime's Music
M: 0404884173
A: 19 Twelfth Ave,  Kedron QLD 4031, Australia
W: concertbandmusicstore.com[hidden email]

 
Reply | Threaded
Open this post in threaded view
|

Re: Syntax highlighting

Craig Dabelstein
The pygments LilyPond lexer is actually going ok. I'm still copying over the info from python-ly, but I've worked it out and so far it's working without errors. I will have to learn some regex tricks in the next few days. Perhaps another week and it will be ready for some testing.

Craig

On Wed., 15 Jan. 2020, 12:16 pm Craig Dabelstein, <[hidden email]> wrote:
Federico,

Is it just me or is the documentation for Pygments really hard to understand? I can't even find anywhere they discuss the setup.py file.

I've opened a repo (https://github.com/craigdab/pygments-lilypond-test) and cut and paste from other peoples repositories as a start, but I really have no idea what I'm doing.

Craig


On Wed, 15 Jan 2020 at 10:38, Craig Dabelstein <[hidden email]> wrote:
Thank you gentlemen,

I'll have a go at taking the python-ly work and seeing if I can use it work to make syntax highlighting with pygments. It's highly possible that I will totally fail, but I'll give it a try.

Craig


On Tue, 14 Jan 2020 at 23:38, Federico Bruni <[hidden email]> wrote:
Il giorno mar 14 gen 2020 alle 12:34, Urs Liska <[hidden email]>
ha scritto:
> Pygments is also what Pandoc uses for its syntax highlighting, so that
> would also make sense for that (e.g. generating PDF documentation from
> Markdown).

Are you sure?
I think that pygments is the name of the default style in Pandoc, but
the highlight library is a Haskell library called skylighting:
https://pandoc.org/MANUAL.html#syntax-highlighting
https://github.com/jgm/skylighting

It seems Wilbert contributed the definitions for lilypond syntax:
https://github.com/KDE/syntax-highlighting/blob/master/data/syntax/lilypond.xml

About 10 days ago I wanted to share this in the open issue in
Frescobaldi tracker but I forgot to do it.
I remember I found the lilypond file definition somewhere else...





--
Craig Dabelstein
Owner
Maxime's Music
M: 0404884173
A: 19 Twelfth Ave,  Kedron QLD 4031, Australia
W: concertbandmusicstore.com[hidden email]

 


--
Craig Dabelstein
Owner
Maxime's Music
M: 0404884173
A: 19 Twelfth Ave,  Kedron QLD 4031, Australia
W: concertbandmusicstore.com[hidden email]