Skip to Content
Author's profile photo Craig Cmehil

Bringing your code snippets to the next level!

A very long time ago we implemented a “snippet gallery” within the wiki. The idea was to create one of the most comprehensive collections of code snippets, code samples and tutorials that ever existed for the SAP ecosystem.

Today I want to ask each of you to do your part to achieve that goal. From now on when you are writing a forum message or a weblog that will have “code” PLEASE jump over here and add the snippet here first and then link to it. Or even drag this bookmarklet up to your browser toolbar (or create a new bookmark in your tool bar with the following: 

javascript:location.href=’https://wiki.sdn.sap.com/wiki/pages/createpage.action?spaceKey=Snippets&fromPageId=9055′;

There’s a very simple reason for this, actually a couple of them.

  1. Easier readability
  2. Easier searching (remember to use the labels on your page)
  3. Syntax Highlighting
  4. Syntax Highlighting – wait did I mention that already?

We have implemented a brand new feature into the wiki for code, for those who have been in the community for the past several years you’ll recognize this I think 😉 it took us awhile but it’s finally here!

Here’s the “before”

and now the “after”

 

Usage:

{highlighter: language}

..code…

{highlighter}

Bash/shell:      bash
C#:      c-sharp
C++:      cpp
CSS:      css      
Delphi:      delphi
Groovy:      groovy
JavaScript:      jscript
Java:      java      
PHP:      php
Plain Text:       ( nothing)
Python:      python
Ruby:      ruby
Scala:      scala
SQL:      sql
Visual Basic:      vb
XML:      xml 

Anyone up for creating some SAP specific ones? We based this macro off of this.

Assigned Tags

      6 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member
      That's really great -- who is up for building the ABAP one at Sapphire?
      Author's profile photo Richard Hirsch
      Richard Hirsch
      I remember you guys working on ABAP syntax formatting for another system (GoogleCode?) at a past TechEd. Maybe you can re-use the code.

      D.

      Author's profile photo Former Member
      Former Member
      Yea we were messing with it but the whole setup is totally different.  The only thing we can reuse is the reserved word list.
      Author's profile photo Ankan Banerjee
      Ankan Banerjee
      This is really great! 🙂
      Craig, anyway you can make the code snippets inserted in new posts automatically add to the snippet gallery instead of having the user to do this? I guess we'll end up filling the gallery much faster that way - may have something like a checkbox for auto-posting to the snippet gallery when a user is making a forum post...
      Author's profile photo Former Member
      Former Member
      Great!

      Now I have a nice job to spend my weekend -:) With the Scripting languages I have wrote in my blogs, I'm going to spend a lot of my weekend time adding the to the new Code Gallery -;)

      Greetings,
      Blag.

      Author's profile photo Matthias Steiner
      Matthias Steiner
      Just saw it... (lived under a rock the last six months ;))

      Really cool... I'm up to it!