GeSHi Syntax Highlighter installation

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
Raheem
Registered User
Posts: 82
Joined: Thu Feb 09, 2017 7:02 pm
Location: Egypt
Contact:

GeSHi Syntax Highlighter installation

Post by Raheem » Wed Jul 11, 2018 5:13 pm

Hello,

I was trying to install GeSHi Syntax Highlighter in my phpBB 3.2.2 forum, i need to highligh the code to C#. When user use [code][/code] tag it automatically use C# as default language.

I follow installation from here: http://qbnz.com/highlighter/geshi-doc.html

I first upload geshi.php and geshi folder to includes folder. Then opened: bbcode.php and edited:

Code: Select all

	/**
	* Second parse code tag
	*/
	function bbcode_second_pass_code($type, $code)
	{
		// when using the /e modifier, preg_replace slashes double-quotes but does not
		// seem to slash anything else
		$code = str_replace('\"', '"', $code);

		switch ($type)
		{
			case 'php':
				// Not the english way, but valid because of hardcoded syntax highlighting
				if (strpos($code, '<span class="syntaxdefault"><br /></span>') === 0)
				{
					$code = substr($code, 41);
				}

			// no break;

			default:
				$code = str_replace("\t", '&nbsp; &nbsp;', $code);
				$code = str_replace('  ', '&nbsp; ', $code);
				$code = str_replace('  ', ' &nbsp;', $code);
				$code = str_replace("\n ", "\n&nbsp;", $code);

				// keep space at the beginning
				if (!empty($code) && $code[0] == ' ')
				{
					$code = '&nbsp;' . substr($code, 1);
				}

				// remove newline at the beginning
				if (!empty($code) && $code[0] == "\n")
				{
					$code = substr($code, 1);
				}
			break;
		}

		$code = $this->bbcode_tpl('code_open') . $code . $this->bbcode_tpl('code_close');

		return $code;
	}
To:

Code: Select all

	/**
	* Second parse code tag
	*/
	function bbcode_second_pass_code($type, $code)
	{
		include_once('geshi.php');
		
		$geshi = new GeSHi($code, 'csharp');
		
		$code = $geshi->parse_code();

		$code = $this->bbcode_tpl('code_open') . $code . $this->bbcode_tpl('code_close');

		return $code;
	}
This according to http://qbnz.com/highlighter/geshi-doc.html but it did not work, nothing highlighted why? is there is something i miss? i don't know in php but it seems like other languages i know like java.

User avatar
AmigoJack
Registered User
Posts: 5350
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: GeSHi Syntax Highlighter installation

Post by AmigoJack » Thu Jul 12, 2018 7:55 am

Raheem wrote:
Wed Jul 11, 2018 5:13 pm
is there is something i miss?
Yes:
  • The manual's most recent date is "© 2007 - 2012", which means it can only be interpreted for phpBB versions in that date, not today.
  • The manual clearly says "mod for phpBB", but MOD support died along with the 3.0.x branch - today's 3.2.x does not support them anymore.
The worst thing about censorship is ███████████

Raheem
Registered User
Posts: 82
Joined: Thu Feb 09, 2017 7:02 pm
Location: Egypt
Contact:

Re: GeSHi Syntax Highlighter installation

Post by Raheem » Thu Jul 12, 2018 11:29 am

That's OK Amigo, thanks.

Post Reply

Return to “phpBB Custom Coding”

Who is online

Users browsing this forum: No registered users and 5 guests