ATutor

Learning Management Tools







Pages:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15


Syntax Highlighter module and ATutor preprocessing


  • 2012-11-09 12:33:15

    Syntax Highlighter module and ATutor preprocessing

    ATutor version - 2.1

    I'm trying to use the Syntax Highlighter module for code segments but am having trouble because of ATutor's preprocessing
    of the content. It works fine for the '<' and '>' characters. When the code segment contains [i], ATutor replaces it with
    the <em> tag and in a newline command '\n' the backslash is removed. Below is a sample of the code I'm trying to display.
    Is there anyway I can stop ATutor from preprocessing code segments? In the past, before using the Syntax Highlighter module, I would have to replace <, >, backslashes, and [i] in code with the html special characters. I would like to get away from having to do this. Plus, if I do that it makes the Syntax Highlighter module useless.


    <pre class="c">#include <stdlib.h>
    #include <stdio.h>
    #include "mpi.h"

    main (int argc, char* argv[])
    {
    int procID, nproc, root, source, target, tag;
    int k, ncolors, pcolor;
    int *colorArray;
    char color[10];
    MPI_Status status;

    // Set the rank 0 process as the root process
    root = 0;

    // Generate three colors for color array, where white = 0, red = 1, and green = 2
    ncolors = 3;
    colorArray = (int*) malloc(sizeof(int) * ncolors);

    for (i = 0; i < ncolors; i++)
    {
    colorArray[i] = i;
    }

    ...

    printf("proc %d has color %s\n", root, color);

    ...
    }</pre>

    Thanks, Sandie

  • 2012-11-09 12:51:05

    Re: Syntax Highlighter module and ATutor preprocessing

    I'm not familiar with the workings of particular module. You might contact Peter Strba who created it. His email should be listed in the module.xml file.

  • 2012-11-09 16:04:28

    Re: Syntax Highlighter module and ATutor preprocessing

    The problems are caused by how ATutor is handling the content before the Syntax Highlighter works with it.
    I just went ahead and modified the source code to fix the problem. Hopefully I didn't break anything in the
    process but it seems to work fine now. Here's what I did:

    To stop removal of the backslash when content is saved to the database, I removed $stripslashes from line 180
    of mods/_core/editor_tab_functions.inc.php:

    $_POST['body_text'] = $stripslashes(trim($_POST['body_text']));) ==> $_POST['body_text'] = trim($_POST['body_text']);

    Since I don't use ATutor's codes anyway, to stop replacement of [i] with an <em> tag, I commented out lines 563-564
    in include/lib/output.inc.php:

    // $text = str_replace('[i]','<em>',$text);
    // $text = str_replace('[/i]','</em>',$text);