def exampleCodeReplace(sectionText, in_directory, keyString):
    """
    Searches throught the given text and replaces the files of code with
    the actual code in the file. 
    
    All examples in the Latex file follows the following pattern:
        \keyString{<pre-text>}{<directory to code>}{<post-text>}
    -- The <pre-text> and <post-text> should have already been processed 
    prior to this function call and will be concatenated to the return
    string.
    -- The pattern ".nf\\n ... .fi\\n" will have the text in between ".nf"
    and "fi" be presented without formatting. 
    """

    while(sectionText.find(keyString) != -1):
        startOfText = sectionText.find(keyString)
        firstStartBrace = sectionText.find("{", startOfText)
        firstEndBrace = sectionText.find("}", firstStartBrace)
        secStartBrace = sectionText.find("{", firstEndBrace)
        secEndBrace = sectionText.find("}", secStartBrace)
        thirdStartBrace = sectionText.find("{", secEndBrace)
        thirdEndBrace = sectionText.find("}", thirdStartBrace)
        path = sectionText[secStartBrace+1:secEndBrace].strip()
        code = open(in_directory + "/../" + path, "r").read()
        sectionText = sectionText[:startOfText] + "\n" + \
                    sectionText[firstStartBrace+1:firstEndBrace] + "\n\n" + \
                    ".nf\n" + \
                    code + \
                    ".fi\n" + \
                    sectionText[thirdStartBrace+1:thirdEndBrace] + \
                    sectionText[thirdEndBrace + 1:]
    return sectionText