3 Replies Latest reply: Jan 28, 2010 9:12 AM by giezi
plg Level 1 (0 points)
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)?
  • Pope7 Level 1 (10 points)
    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/directoryof_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)
  • jwdavidson Level 1 (0 points)
    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
  • giezi Level 1 (0 points)
    We have the excatly same problem like jwdavidson, if we edit a page with code highlighting.
    does anyone have a solution / workaround? Our implementation is based on http://alexgorbatchev.com/wiki/SyntaxHighlighter

    Thanks and regards

    Message was edited by: giezi