Monday, August 03, 2015

Posting code in WP

Just trying to  post my apex code in WP.

1)Using Gist. Just copy the Gist URL into your WP post.Done.Look nice , but if you delete your file in Gist,the code in post also will be gone which I less prefer.Maybe will use it if I decide not to delete my file in Gist.

 2) Using code based on Posting source code. Because this is from SyntaxHighlighter,it offered quite sophisticated features,but unfortunately I found it not able to remove the scroll bar.It got some solutions but only apply for WordPress.org only.But it nice, maybe for longer and complex code I can use this.

 [code language="java" padlinenumbers="true" highlight="1"] public Map<Id,MyAgenda__c> getAgendaMap(){ agendaMap = new Map<Id,MyAgenda__c>([SELECT Id FROM MyAgenda__c WHERE Id=: this.stdController.getId() ORDER BY Date__c DESC]); return agendaMap; } [/code]

 3)Using hilite.me It look nice for simple and shorter code.
public Map<Id,MyAgenda__c>  getAgendaMap(){
        agendaMap = new Map<Id,MyAgenda__c>([SELECT Id FROM MyAgenda__c WHERE Id=: this.stdController.getId() ORDER BY Date__c DESC]);
        return agendaMap;
    }   
So for free WP user, what tool do you use to post your code?Just note that I am Salesforce developer,so I code with Apex.

In Blogger last time I used Syntaxhighlighter, but now I found out hilite.me also quite convenient.

Note:This is copied from my other blog in wordpress.

No comments:

Post a Comment