Code Snippets

This forum is for all Flare issues not related to any of the other categories.

Code Snippets

Postby Vibeke B on Fri Jan 15, 2021 12:24 am

Hello everyone!

I have just discovered that Flare has a Code Snippet feature. I have used a pre styling with a monospace font and colored background for code until now but I think I want to go ahead and change our code examples to the snippet. But before I do so, I just wanted to hear if anyone is experiencing problems with this feature? Is it mature enough to embark on? Any teething problems? We have a lot of code examples, so I have a bit job ahead of me, but I hope it will be worth it in the end.

Kind regards,
Vibeke
Vibeke B
Propeller Head
 
Posts: 59
Joined: Thu Mar 15, 2018 7:14 am
Location: Denmark

Re: Code Snippets

Postby bunnycat on Fri Jan 15, 2021 8:57 am

It basically works.

Output displays nicely on HTML5 output and has the added benefit of the "copy to clipboard" functionality.
In PDF output, it does the syntax highlighting nicely - which is sorely missing if you are using a different <pre> tag solution (or code syntax highlighting solution such as Prettify or PrismJS)

However, I feel it is still lacking in some language support. Common ones are there, but it feels like it's missing things like JSON and command line.

For some reason, it appears that previous releases (2020 plain, R2) handled code indents better. 2020 R3 seems to not indent code snippets properly when the target is built, even though you see your indents in the dialog box for code snippets.

If your code snippets are lengthy, line numbering on the left side tend to display weirdly, probably because of margins and such in the code snippet divs and classes baked into the functionality.

Hope this helps.

-CAT
bunnycat
Propeller Head
 
Posts: 68
Joined: Tue Nov 03, 2015 6:44 am

Re: Code Snippets

Postby paul_collins on Mon Jan 18, 2021 10:07 am

A minor point is that the generated output converts any leading space characters to a &#160; character, which might not be desirable in some situations. It does this for every language type, including PlainText.
This specific issue caused a problem fur us with the jinja templating language, although using tabs instead worked fine.
paul_collins
Propeller Head
 
Posts: 21
Joined: Thu May 22, 2014 7:25 am

Re: Code Snippets

Postby Vibeke B on Wed Jan 20, 2021 3:16 am

I can see what you mean about the indents. I am playing with an XML code, and the indents (tabs) display nicely in the Code Editor, but are not there when I click OK and close the Editor, nor do they display in the PDF or the online output. Also, the indents are still not there when you use the Copy function in the online output.

Is there a fix, or should this be reported to MadCap?
Vibeke B
Propeller Head
 
Posts: 59
Joined: Thu Mar 15, 2018 7:14 am
Location: Denmark

Re: Code Snippets

Postby bgo on Mon Feb 01, 2021 7:46 am

bunnycat wrote:However, I feel it is still lacking in some language support. Common ones are there, but it feels like it's missing things like JSON and command line.


For JSON, choose Javascript as the language. Then it appears to format correctly.
bgo
Jr. Propeller Head
 
Posts: 3
Joined: Mon Sep 09, 2019 8:39 am

Re: Code Snippets

Postby amarchant on Tue Apr 13, 2021 3:14 pm

Choosing JavaScript as the language to highlight JSON doesn't work for me. In order for this feature to be useful for my company, it would have to support JSON highlighting.
amarchant
Jr. Propeller Head
 
Posts: 6
Joined: Mon Apr 02, 2012 10:44 am

Re: Code Snippets

Postby bunnycat on Tue Apr 27, 2021 11:43 am

Looks like Flare 2021 fixed the code indent issue (hurray!) so that XML and such indents look much better.
bunnycat
Propeller Head
 
Posts: 68
Joined: Tue Nov 03, 2015 6:44 am

Re: Code Snippets

Postby Dafra08 on Fri May 07, 2021 7:53 am

I think it works quite well, but I have fairly simple code examples. I do miss the possibility to highlight parts of the code with, say yellow background, to point out that ”this needs to be changed to your server name” or whatever.
Dafra08
Propeller Head
 
Posts: 17
Joined: Fri Aug 16, 2019 1:02 am


Return to Flare's General Discussion

Who is online

Users browsing this forum: No registered users and 12 guests