How to highlight Caché ObjectScript, work with htm, add image in the post and other questions
Hi, Community!
We've updated Developer Community (DC) portal and here are some good news.
Now you can insert in your post highlighted parts of code. It works with help of highlight.js library.
To illustrate it I took some code snippets from Fabian's article.
Method OnPreServer() As %Status
{
set ..SharedConnection=1
set room=$GET(%request.Data("room",1),"default")
set:room="" room="default"
if (..WebSocketID'="")
{
set ^CacheTemp.Chat.WebSockets(..WebSocketID)=""
set ^CacheTemp.Chat.Room(..WebSocketID)=room }
else
{
set ^CacheTemp.Chat.Error($INCREMENT(^CacheTemp.Chat.Error),"no websocketid defined")=$HOROLOG
}
Quit $$$OK
}
To paste formatted text do following:
- Insert the code into the post and select it.
- Click on Format(2) button in Editor (left corner or 2 in the shot) and mark code as Formatted.
- Click on Styles (3) and choose Computer Code.
Your code should be automatically highlighted in a preview. It works not only for COS but for all the languages which are supported by higlight.js.
If you have code snippet which is not automatically highlighted like this one do the following:
- Turn html mode (Source(1) button).
- Put class="COS" parameter into code tag and get the highlighted COS.
Method Server() As %Status
{
job ..StatusUpdate(..WebSocketID) for
{
set data=..Read(.size,.sc,1)
if ($$$ISERR(sc)) {
if ($$$GETERRORCODE(sc)=$$$CSPWebSocketTimeout) {
//$$$DEBUG("no data") }
If ($$$GETERRORCODE(sc)=$$$CSPWebSocketClosed){
kill ^CacheTemp.ChatWebSockets(..WebSocketID)
do ..EndServer()
Quit // Client closed WebSocket
}
}
else {
set mid=$I(^CacheTemp.Chat.Message)
set sc= ##class(%ZEN.Auxiliary.jsonProvider).%ConvertJSONToObject(data,"%Object",.msg)
set msg.Room=$G(^CacheTemp.Chat.Room(..WebSocketID))
set msg.WSID=..WebSocketID //meta data for the message
set ^CacheTemp.Chat.Message(mid)=msg.$toJSON()
job ..ProcessMessage(mid)
}
}
Quit $$$OK
}
Or, you can simply disable rich-text and embrace your code part into two tags: pre and than code, like it is shown in the shot:
How to add annotation for the post?
Again we need <!--break--> tag. Click on Source button and place the tag into html code of the post in your desired place.
Here are the Editor's buttons on the shot:
- Source,
- Format,
- Styles.
How to add an image to the post?
Press upload image button in the editor (see the screenshot) and the image will be uploaded to your post.
You can adjust the Width of the image. To do this click on the image and then click on the image settings button (see the shot):
Width 600 is preferrable.