rubychan / coderay

Fast and easy syntax highlighting for selected languages, written in Ruby.
http://coderay.rubychan.de/
Other
845 stars 115 forks source link

CodeRay hangs on multi-code in content #236

Open EnziinSystem opened 5 years ago

EnziinSystem commented 5 years ago

Hello,

I have content with multi-source code programming:

// This is a C code block
#include <stdio.h>

int main()
{
    int n, i;
    unsigned long long factorial = 1;

    printf(\"Enter an integer: \\n\");
    scanf(\"%d\",&n);

    if (n < 0)
        printf(\"Error! Factorial of a negative number doesn't exist.\");
    else
    {
        for(i=1; i<=n; ++i)
        {
            factorial *= i;              // factorial = factorial*i;
        }
        printf(\"Factorial of %d = %llu\", n, factorial);
    }

    return 0;
}
// This is the Ruby code
class PagesController < ApplicationController
  require 'will_paginate/array'
  require 'net/http'
  require 'open-uri'
  require 'securerandom'

  def editor
    @language_code = params[:language_code]
    @source_code = CodeBlock.where(id: params[:id], language_code: @language_code).first

    @language_code = 7 unless @language_code.present?
    unless @source_code.present?
      @example = "#include <iostream>\n\nusing namespace std;\n\nint main() {\n\n\tcout << \"Hello from C/C++\";\n\n\treturn 0;\n}"
    end
    @authenticity_token = form_authenticity_token
    @code_blocks = current_user.code_blocks if user_signed_in?
  end
end

The description text content with multi-language needs to introduction about the large system.

But, when I render the above code, CodeRay hangs.