Newsroom Update

Beginning in May, a special Today at Apple series titled “Made for Business” will offer small business owners and entrepreneurs free opportunities to learn how Apple products and services can support their growth and success. Learn more >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

displaying code in a wiki

Does anyone know if there is a convenient way of displaying source code on a wiki page? Sure, I can select the text and make it monospace, then manually fix the spacing, etc... but is there a magic button to press or magic html tags to put in so that a block of source code shows nicely on my wiki page? (e.g. a series of unix commands, or a block of C code)?
Thanks,

Posted on Oct 5, 2009 1:14 PM

Reply
3 replies

Oct 29, 2009 10:01 AM in response to plg

You can create a whitelist.plist file and place it in /etc/wikid/ which will allow you to specifically define html tags allowed on wiki pages. Then you can just add your custom CSS to the blocks of code you want to style. The first link below is a decent example. Also, if you go to /library/application support/apple/wikiserver/themes/directory of_them_youuse/ you can edit the css for each theme - you could just edit the css for one of the existing styles defined in those stylesheets.

(See http://discussions.apple.com/thread.jspa?threadID=1667663&tstart=72 and http://lists.apple.com/archives/wiki-server/2008/Aug/msg00030.html)

Nov 1, 2009 1:00 PM in response to plg

I have been working on a solution to displaying properly formatted and colorized code in the wiki. I am using a javascript and css from http://notebar.com/CodeColor.html

So far it I have modified the tags in whitelist.plist so that it accepts the 'lang' attribute on the <pre> tag. I have edited the css so that the codecolor.css is included in the theme I am using. I have modified the javascript so that there is an event that fires when the page loads in the wiki to add the formatting and color codes to the dom of the wiki text, and the code is displayed exactly as I want it.....

That is, until I try to edit the page containing the code. What happens then is that the editor opens with the contents of the DOM, after formatting, rather than the raw wiki text that was stored and saved. Then the code becomes an absolute mess because the event that formats the code is fired a second time and makes an absolute mess of the html and the original wiki text with the embedded code.

Is there anyway to have the editor load the saved wiki content rather than the unsaved DOM representation?

John Davidson

displaying code in a wiki

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.