Changing default syntax highlighting colors in codeSnippets

This forum is for all Flare issues related to styles, stylesheets and XML.
Post Reply
AndreP
Jr. Propeller Head
Posts: 1
Joined: Tue Jul 14, 2020 4:44 am

Changing default syntax highlighting colors in codeSnippets

Post by AndreP »

Love the new Code Snippets, but I'd like to change the default colors for the syntax highlighting.
We have been using specific colors for syntax highlighting for JSON, JavaScrip and C# code samples in out docs for years and would like to style the code similarly when using the new Flare code snippets.
For mc-code-lang: CSharp for example, comments are highlighted with the color #969896, but I want them in green. I know the code snippet is rendered in the output as a <pre> block and the C# elements (keywords, comments etc.) are styled with a <span style="color: #..."> tag. So I did some digging and I believe the syntax highlighting for each of the supported code snippet languages is defined in a DLL. When Flare compiles the project output, it styles each element of the code snippet according to it's definition in the DLL ... at least I think this is how it works. So my question is, is there any way of overwriting those code element syntax highlighting definitions?

Thanks.
ChoccieMuffin
Senior Propellus Maximus
Posts: 2632
Joined: Wed Apr 14, 2010 8:01 am
Location: Surrey, UK

Re: Changing default syntax highlighting colors in codeSnipp

Post by ChoccieMuffin »

Ooo, what an interesting question! I don't know the answer but still wanted to welcome you to the forums. I'm sure you'll get some useful answers from the clever people.
Started as a newbie with Flare 6.1, now using Flare 2023.
Report bugs at http://www.madcapsoftware.com/bugs/submit.aspx.
Request features at https://www.madcapsoftware.com/feedback ... quest.aspx
Nita Beck
Senior Propellus Maximus
Posts: 3669
Joined: Thu Feb 02, 2006 9:57 am
Location: Pittsford, NY

Re: Changing default syntax highlighting colors in codeSnipp

Post by Nita Beck »

I don't think there is a way. The code snippet itself is plain text that is then "interpreted" in order to supply the syntax highlighting, based on the language. The syntax highlighting is added programmatically, not via CSS. MadCap has built the language rules into Flare, without offering us users any way either to edit those rules or to supply additional rules, which is on my wish list so I've submitted a feature request. (For example, I've been documenting code written in a custom programming language, and there is no language I can select for my code snippets, so they appear without syntax highlighting.)

I also wonder that if you were to somehow add your own formatting to your code samples via inline formatting or span classes, you'd be defeating the idea of allowing your end-users to copy the code samples. I'd expect the formatting to come along for the ride, which is not what the end-user would want.
Nita
Image
RETIRED, but still fond of all the Flare friends I've made. See you around now and then!
jcollins
Propeller Head
Posts: 22
Joined: Tue Feb 01, 2011 1:00 pm

Re: Changing default syntax highlighting colors in codeSnipp

Post by jcollins »

I'd love to be able to do this, too. Do you know if there is a way to +1 on your feature request, @Nita?
Nita Beck
Senior Propellus Maximus
Posts: 3669
Joined: Thu Feb 02, 2006 9:57 am
Location: Pittsford, NY

Re: Changing default syntax highlighting colors in codeSnipp

Post by Nita Beck »

MadCap accepts feature requests here: https://www.madcapsoftware.com/feedback ... quest.aspx
Nita
Image
RETIRED, but still fond of all the Flare friends I've made. See you around now and then!
Post Reply