New Clarion Syntax Highlighting on ClarionHub!

:tada: New Clarion Syntax Highlighting on ClarionHub!

Hi ClarionHub Members,

I’m excited to announce that Clarion code syntax highlighting is now available on the forum! We’ve integrated a custom Clarion language support feature into Discourse, and it’s live for all your code posts. You can now write Clarion code with syntax highlighting in both light and dark themes.

How to Use It:

To post code with highlighting, simply use the following markdown syntax in your post:

```clarion
  YOUR_CLARION_CODE_HERE
```

For example:

```clarion
    MEMBER
FileIDType EQUATE(LONG)
    INCLUDE('ABFILE.INC'), ONCE
```

And voilà! Your Clarion code block will be automatically highlighted as shown below:

    MEMBER 
FileIDType EQUATE(LONG)
    INCLUDE('ABFILE.INC'), ONCE

Contribute and Improve

I’ve also set up a GitHub repository where you can find the source code for this feature: GitHub - discourse-highlightjs-clarion.

While we know that color choices may not be everyone’s favorite, we’re aiming for a balance that works well for most users in both light and dark modes. Aesthetic changes to the color schemes will be considered carefully to ensure a good user experience for all.

Feel free to:

  • Open issues if you find any bugs or need enhancements.
  • Submit pull requests if you’d like to contribute directly to the project.

Your Feedback

Please let me know your thoughts and feedback on this new feature. We’re looking forward to improving it based on the community’s needs!

Thanks for being part of the ClarionHub community, and happy coding! :art:

16 Likes

A bigger code example that mark posted elsewhere that shows off a lot of the syntax coloring:

  MEMBER
  PRAGMA ('define(init_priority=>19)')
TraceFiles        EQUATE(0)
GLO:Yada          LONG(0FFh)
FileIDType        EQUATE(LONG)                  !Data type for unique reference to file

    INCLUDE('ABFILE.INC'),ONCE
    INCLUDE('ABUTIL.INC'),ONCE
    INCLUDE('ERRORS.CLW'),ONCE
    INCLUDE('CWSYNCHC.INC'),ONCE

FileOpenServer                CLASS,TYPE
Disposed                        BYTE
MyFile                          &FILE,PROTECTED
Usage                           UNSIGNED,PROTECTED

Construct                       PROCEDURE
Destruct                        PROCEDURE,VIRTUAL
Init                            PROCEDURE(FIlE aFile),VIRTUAL
Link                            PROCEDURE
Release                         PROCEDURE
                              END

ThreadedFileOpenServer        CLASS(FileOpenServer),IMPLEMENTS(IFileOpenServer),TYPE
                              END

UnthreadedFileOpenServer      CLASS(FileOpenServer),IMPLEMENTS(IFileOpenServer),TYPE
CSect                           &CriticalSection,PRIVATE
FileUsageCount                  UNSIGNED,PRIVATE

Construct                       PROCEDURE
Destruct                        PROCEDURE,VIRTUAL
Init                            PROCEDURE(File afile),DERIVED
                              END

UnthreadedFileOpenerMap       QUEUE
FileID                          UNSIGNED
Opener                          &UnthreadedFileOpenServer
                              END

CreateOpenerCrit              CriticalSection

    MAP
ConcatGetComponents             PROCEDURE(KeyFieldQueue,*CSTRING,BYTE HowMany),PRIVATE
DupString                       PROCEDURE(STRING),*STRING,PRIVATE
CasedValue                      PROCEDURE(STRING FieldName,*? Field,? FieldValue),STRING,PRIVATE
LocalAction                     PROCEDURE(BYTE Mode),BYTE,PRIVATE
CleanUp                         PROCEDURE(FileManager),PRIVATE
OpCodeCanBeDone                 PROCEDURE(SIGNED opCode),BYTE,PRIVATE
CreateThreadedFileOpenServer    PROCEDURE(FILE aFile), *IFileOpenServer,PRIVATE
CreateUnthreadedFileOpenServer  PROCEDURE(FILE aFile), *IFileOpenServer,PRIVATE
CreateFileOpenServer            PROCEDURE(FILE aFile, BOOL threaded),*IFileOpenServer,PRIVATE
CreateFileOpenServer            PROCEDURE(FILE aFile),*IFileOpenServer,PRIVATE
    END

RelationQueue                 QUEUE,TYPE,PRIVATE      ! List of all related files
File                            &RelationManager      ! Related file
Fields                          &BufferedPairsClass   ! List of linking fields
HisKey                          &KEY                  ! Only filled in for 1:MANY relationships
UpdateMode                      BYTE                  ! Action on Update RI flag
DeleteMode                      BYTE                  ! Action on Delete RI flag
Opened                          BYTE
                              END

KeyFieldQueue                 QUEUE,TYPE,PRIVATE ! QUEUE of all key components
Field                           ANY              ! Key component
FieldName                       &STRING          ! This should contain the UPPER for a case insensitive field
Ascend                          BYTE             ! Ascending/descending flag
                              END

FileKeyQueue                  QUEUE,TYPE,PRIVATE ! QUEUE of all keys in a file
Key                             &KEY             ! Reference to a KEY
Description                     STRING(80)       ! Key description text (from Data dictionary)
Fields                          &KeyFieldQueue   ! Reference to key components queue
AutoInc                         BYTE             ! Auto-increment flag (from Data dictionary)
Dups                            BYTE             ! Duplicates allowed flag (from Data dictionary)
NoCase                          BYTE             ! Case sensitive flag (from Data dictionary)
                              END

FieldsList                    QUEUE,TYPE,PRIVATE
Tag                             ASTRING
Fld                             ANY
fType                           ASTRING
fPicture                        ASTRING
                              END

SaveQueue                     QUEUE,TYPE,PRIVATE
Buffer                          USHORT
Id                              USHORT
AutoIncDone                     BYTE
State                           LONG
Pos                             STRING(1024)
                              END

Epoc                          LONG(1),THREAD
szDbTextLog                   CSTRING(FILE:MaxFilePath + 1),THREAD  ! DbAudit Data

TransactionManagerQueue QUEUE,TYPE
RM                       &RelationManager
RMInstance               LONG
Cascade                  BYTE
                        END

FilesOnTransactionQueue QUEUE,TYPE
RM                        &RelationManager
RMInstance                LONG
PrevLogout                BYTE
                        END

  COMPILE('***',TraceFiles)
Trace FILE,DRIVER('ASCII'),CREATE
R       RECORD
B         STRING(1000)
        END
      END

LinkASCIIDriver  EQUATE(lib_mode)
  ***
  OMIT('***',TraceFiles)
LinkASCIIDriver  EQUATE(0)
  ***

  COMPILE('=== DO LINK', LinkASCIIDriver)
    PRAGMA ('link (C%V%ASC%X%%L%.LIB)')
! === DO LINK

StatusQ_t                     QUEUE,TYPE
Thread                          LONG
Proc                            ASTRING
ID                              FileIDType
UStat                           BYTE
Hold                            USHORT
ScopeLevel                      USHORT
NestedOpen                      USHORT
                              END

FileMapping_t                 QUEUE,TYPE
FileLabel                       FileIDType
FileManager                     &FileManager
                              END
FileMapping_r                 QUEUE,TYPE
FileLabel                       FileIDType
RelationManager                 &RelationManager
                              END

FilesManager                 CLASS,THREAD
Errs                            &ErrorClass
FileMapping                     &FileMapping_t
RelationMapping                 &FileMapping_r
StatusQ                         &StatusQ_t

Construct                       PROCEDURE
Destruct                        PROCEDURE
AddFileMapping                  PROCEDURE(FileManager FM),PRIVATE
AddFileMapping                  PROCEDURE(RelationManager RM),PRIVATE
FindRecord                      PROCEDURE(FileManager FM),BYTE
GetFileID                       PROCEDURE(File ThisFile),FileIDType
GetFileMapping                  PROCEDURE(FileIDType FileLabel),*FileManager
GetRelationFileMapping          PROCEDURE(FileIDType FileLabel),*RelationManager
NoteClose                       PROCEDURE(FileManager FM)
NoteOpen                        PROCEDURE(FileManager FM)
NoteUsage                       PROCEDURE(FileManager FM, BYTE Level)
RemoveFileMapping               PROCEDURE(FileIdType FileLabel)
RemoveFileMapping               PROCEDURE(FileManager FM)
RemoveRelationFileMapping       PROCEDURE(FileIdType FileLabel)
RemoveRelationFileMapping       PROCEDURE(RelationManager RM)
Trace                           PROCEDURE(STRING S)
                              END

FilesManager.Construct PROCEDURE
  CODE
  SomeNumberFormeat = FORMAT(SomeNumber, @N02)
  SELF.FileMapping &= NEW FileMapping_t
  SELF.RelationMapping &= NEW FileMapping_r
  SELF.StatusQ &= NEW StatusQ_t
  COMPILE('***',TraceFiles)
  CREATE(Trace)
? ASSERT(~ERRORCODE(),'Unable to create trace file')
  OPEN(Trace)
? ASSERT(~ERRORCODE(),'Unable to open trace file')
  ***

FilesManager.Destruct PROCEDURE
  CODE
  DISPOSE(SELF.StatusQ)
  DISPOSE(SELF.FileMapping)
  FREE(SELF.RelationMapping)
  DISPOSE(SELF.RelationMapping)
  COMPILE('***',TraceFiles)
  CLOSE(Trace)
  ***

FilesManager.NoteUsage PROCEDURE(FileManager FM,BYTE Level)
  CODE
  IF SELF.FindRecord(FM) <> Level:Benign
    SELF.StatusQ.ScopeLevel = 0
    DO AddQ
  ELSIF SELF.StatusQ.Proc = SELF.Errs.GetProcedureName()
    IF Level > SELF.StatusQ.Ustat
      SELF.StatusQ.Ustat = Level
    COMPILE('***',TraceFiles)
      SELF.Trace('New Level :' & SELF.StatusQ.Proc & '(' & SELF.StatusQ.ScopeLevel & '):' & SELF.StatusQ.Ustat)
    ***
      PUT(SELF.StatusQ)
?     ASSERT(~ERRORCODE())
    END
  ELSE
    DO AddQ
    IF Level < UseType:Returns AND ~SELF.StatusQ.Hold
    COMPILE('***',TraceFiles)
      SELF.Trace('**Record getting clobbered')
    ***
      SELF.StatusQ.Hold = FM.SaveFile()
      PUT(SELF.StatusQ)
?     ASSERT(~ERRORCODE())
    END
  END

AddQ ROUTINE
    SELF.StatusQ.Thread = THREAD()
    SELF.StatusQ.Proc = SELF.Errs.GetProcedureName()
    SELF.StatusQ.Ustat = Level
    SELF.StatusQ.ScopeLevel += 1
    SELF.StatusQ.Hold = 0
    SELF.StatusQ.NestedOpen = 0
    COMPILE('***',TraceFiles)
      SELF.Trace('New Scope :'&CLIP(FM.GetName()) & '(' & SELF.StatusQ.ScopeLevel & '):' & SELF.StatusQ.Ustat)
    ***
    ADD(SELF.StatusQ)
?   ASSERT(~ERRORCODE())
4 Likes