Syntax Highlighter for source code in knowledge base

Hi all,

I am looking for a way to highlight js c# code in a rich text field.

Especially we want to use it in the knowledge base in creatio.

 

 

Is there a way to do this?

 

Regards,

Oliver

Like 0

Like

5 comments

Hi Oliver,

You can possibly do it and here is small instruction on how:

1) At first write an example of a code you want to highlight and do it manually using the options above the text. Save the result.

2) Get the value of this field from the database, it should look something like this:

 <div>hello there&nbsp;</div>  <div>&nbsp;</div>  <div>define(&quot;PrcAcceptanceCertificate777ab4cfSection&quot;, [], function() {<br /> &nbsp;&nbsp; &nbsp;return {<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;entitySchemaName: &quot;PrcAcceptanceCertificate&quot;,<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;diff: /**SCHEMA_DIFF*/[]/**SCHEMA_DIFF*/,<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;methods: {}<br /> &nbsp;&nbsp; &nbsp;};<br /> });<br /> &nbsp;</div>  <div>&nbsp;</div> 

3) In this value take a look at how the system applies styles, you need to do it automatically in your method.

4) Write a method that will apply needed highlights to your text.

var text = this.get("Notes");

text.DoSomethingToModifyIt();

this.set("Notes", text);

Probably the hardest point would be finding the js code in the whole text because for the system there are no differences between a normal sentence or parts of the code. But if you manage to do it, then applying highlights is not that difficult to do.

 

Hi,

 

phew, that sounds like a lot of work.



I was thinking more of a js library that you can just use.

There must already be something integrated in creatio, because there is the source code area. Couldn't we just use that somehow?

 

Or a component in the editor like here in the community area

 

Regards,

Oliver

Oliver Herzog,

Slightly misunderstood what are you trying to do.

Can you please specify what source code area you are referring to?

Sorry for the misunderstanding!

 

I just want c#, js or html to be displayed "nicely" in the richtext editor. In the first post you can see how it should not look like.

 

No logical check or something like that.



Something like the code snippet function here in the community.

 

Oliver Herzog,

Unfortunately, right now highlighting the code lines like the "Code snippet" function is impossible on the system itself due to a base logic of RICH_TEXT fields.

I registered your suggestion for our R&D team, thank you for your idea.

Show all comments