Disable BBcode encoding within a latex tag

Disable BBcode encoding within a latex tag

Hello, I have the following bb function

function bb($string) {
  $string = trim($string);
  $search = array(
    '@\<(?i)latex\>(.*?)\</(?i)latex\>@si',
    '@\<(?i)b\>(.*?)\</(?i)b\>@si',
    '@\<(?i)i\>(.*?)\</(?i)i\>@si',
    '@\<(?i)u\>(.*?)\</(?i)u\>@si',
    '@\<(?i)blockquote\>(.*?)\</(?i)blockquote\>@si',
    '@\<(?i)pre\>(.*?)\</(?i)pre\>@si'
  );
  $replace = array(
    '<img src="cgi/mathtex.cgi?\\1">',
    '<b>\\1</b>',
    '<i>\\1</i>',
    '<u>\\1</u>',
    '<blockquote>\\1</blockquote>',
    '<pre>\\1</pre>'
  );
  $string = strtr($string, array("\n" => '<br>'));
  $string = preg_replace($search ,$replace, $string);
  return $string;
}

The problem is that if one enters newlines within latex tags (to make latex more clearly arranged), the function replaces the \n by <br>, which then becomes of course invalid latex code. How to disable the encoding of code which is within latex tags?

View Answers

October 6, 2012 at 12:01 AM

fixed!

Ads









Related Tutorials/Questions & Answers:
Disable BBcode encoding within a latex tag
Disable BBcode encoding within a latex tag  Hello, I have... invalid latex code. How to disable the encoding of code which is within latex tags... is that if one enters newlines within latex tags (to make latex more clearly
Set encoding from within SQL*Plus
Set encoding from within SQL*Plus  Hi, In Oracle server I am running sql query from sqlplus which is adding Spanish data. But data is converted wrongly due to UTF conversion. How to resolve this. Thanks   Hi, Run
Advertisements
ModuleNotFoundError: No module named 'bbcode'
ModuleNotFoundError: No module named 'bbcode'  Hi, My Python... 'bbcode' How to remove the ModuleNotFoundError: No module named 'bbcode'... to install padas library. You can install bbcode python with following command
ModuleNotFoundError: No module named 'django-bbcode'
ModuleNotFoundError: No module named 'django-bbcode'  Hi, My... 'django-bbcode' How to remove the ModuleNotFoundError: No module named 'django-bbcode' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'django-bbcode'
ModuleNotFoundError: No module named 'django-bbcode'  Hi, My... 'django-bbcode' How to remove the ModuleNotFoundError: No module named 'django-bbcode' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'mde_bbcode'
ModuleNotFoundError: No module named 'mde_bbcode'  Hi, My Python... 'mde_bbcode' How to remove the ModuleNotFoundError: No module named 'mde_bbcode' error? Thanks   Hi, In your python environment you
disable function
disable function  Sir, I have called a java script function when one radio button is checked i want to disable this function when another radio button is checked ,both radio buttons are of same group Please help Thanks in advance
ModuleNotFoundError: No module named 'django-content-bbcode'
ModuleNotFoundError: No module named 'django-content-bbcode'  Hi...: No module named 'django-content-bbcode' How to remove the ModuleNotFoundError: No module named 'django-content-bbcode' error? Thanks   Hi
ModuleNotFoundError: No module named 'django-precise-bbcode'
ModuleNotFoundError: No module named 'django-precise-bbcode'  Hi...: No module named 'django-precise-bbcode' How to remove the ModuleNotFoundError: No module named 'django-precise-bbcode' error? Thanks   Hi
ModuleNotFoundError: No module named 'django-precise-bbcode'
ModuleNotFoundError: No module named 'django-precise-bbcode'  Hi...: No module named 'django-precise-bbcode' How to remove the ModuleNotFoundError: No module named 'django-precise-bbcode' error? Thanks   Hi
ModuleNotFoundError: No module named 'lektor-mathshistory-bbcode'
ModuleNotFoundError: No module named 'lektor-mathshistory-bbcode'  Hi...: No module named 'lektor-mathshistory-bbcode' How to remove the ModuleNotFoundError: No module named 'lektor-mathshistory-bbcode' error? Thanks
ModuleNotFoundError: No module named 'latex'
ModuleNotFoundError: No module named 'latex'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'latex' How to remove the ModuleNotFoundError: No module named 'latex'
ModuleNotFoundError: No module named 'latex'
ModuleNotFoundError: No module named 'latex'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'latex' How to remove the ModuleNotFoundError: No module named 'latex'
ModuleNotFoundError: No module named 'latex'
ModuleNotFoundError: No module named 'latex'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'latex' How to remove the ModuleNotFoundError: No module named 'latex'
enable disable checkbox in javascript
enable disable checkbox in javascript  How to enable disable checkbox in javascript
uikeyboard disable return key
uikeyboard disable return key  uikeyboard - hot to disable return key
Struts2.2.1 treenode Tag Example
Struts2.2.1 treenode Tag Example The tree & treenode tag  render a tree node within a tree widget with AJAX support.The tree & treenode... to implement the tree & treenode tag in the Struts2.2.1 -- Directory
Disable UITableView Scrolling
Disable UITableView Scrolling   How to disable the UITableView Scrolling either programmatically or in XIB
Version of com.nfbsoftware>latex-converter dependency
List of Version of com.nfbsoftware>latex-converter dependency
nsstring encoding types
nsstring encoding types   What is NSString Encoding Type in XCode
disable keyboard in java applet
disable keyboard in java applet  How to disable key board of my client in an java applet embedded in a website while the applet is running.? Plz help
ModuleNotFoundError: No module named 'apyref-latex'
ModuleNotFoundError: No module named 'apyref-latex'  Hi, My Python... 'apyref-latex' How to remove the ModuleNotFoundError: No module named 'apyref-latex' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'array-to-latex'
ModuleNotFoundError: No module named 'array-to-latex'  Hi, My... named 'array-to-latex' How to remove the ModuleNotFoundError: No module named 'array-to-latex' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'based-latex'
ModuleNotFoundError: No module named 'based-latex'  Hi, My Python... 'based-latex' How to remove the ModuleNotFoundError: No module named 'based-latex' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'delphin-latex'
ModuleNotFoundError: No module named 'delphin-latex'  Hi, My... 'delphin-latex' How to remove the ModuleNotFoundError: No module named 'delphin-latex' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'django-latex'
ModuleNotFoundError: No module named 'django-latex'  Hi, My Python... 'django-latex' How to remove the ModuleNotFoundError: No module named 'django-latex' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'jirafs-latex'
ModuleNotFoundError: No module named 'jirafs-latex'  Hi, My Python... 'jirafs-latex' How to remove the ModuleNotFoundError: No module named 'jirafs-latex' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'jupyterlab-latex'
ModuleNotFoundError: No module named 'jupyterlab-latex'  Hi, My... named 'jupyterlab-latex' How to remove the ModuleNotFoundError: No module named 'jupyterlab-latex' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'latex_snippet'
ModuleNotFoundError: No module named 'latex_snippet'  Hi, My... 'latex_snippet' How to remove the ModuleNotFoundError: No module named 'latex_snippet' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'ooxml_to_latex'
ModuleNotFoundError: No module named 'ooxml_to_latex'  Hi, My... named 'ooxml_to_latex' How to remove the ModuleNotFoundError: No module named 'ooxml_to_latex' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'simple-latex'
ModuleNotFoundError: No module named 'simple-latex'  Hi, My Python... 'simple-latex' How to remove the ModuleNotFoundError: No module named 'simple-latex' error? Thanks   Hi, In your python

Ads