You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
4.4 KiB

  1. <?php
  2. // Project: Web Reference Database (refbase) <http://www.refbase.net>
  3. // Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's
  4. // original author(s).
  5. //
  6. // This code is distributed in the hope that it will be useful,
  7. // but WITHOUT ANY WARRANTY. Please see the GNU General Public
  8. // License for more details.
  9. //
  10. // File: ./includes/transtab_refbase_markdown.inc.php
  11. // Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/includes/transtab_refbase_markdown.inc.php $
  12. // Author(s): Matthias Steffens <mailto:refbase@extracts.de>
  13. //
  14. // Created: 28-May-06, 18:24
  15. // Modified: $Date: 2008-10-30 17:19:48 +0000 (Thu, 30 Oct 2008) $
  16. // $Author: msteffens $
  17. // $Revision: 1288 $
  18. // Search & replace patterns for conversion from refbase markup to "Markdown" markup & entities. Markdown is a plain text formatting syntax
  19. // as well as a software tool that converts the plain text formatting back to HTML; see <http://daringfireball.net/projects/markdown/> for more info.
  20. // refbase fontshape markup (italic, bold) does not need any conversion since it's identical to (and was in fact modeled after) the Markdown syntax.
  21. // Super- and subscript gets converted into HTML commands while greek letters get converted into the respective HTML entity codes.
  22. // Search & replace patterns must be specified as perl-style regular expression and search patterns must include the leading & trailing slashes.
  23. global $patternModifiers; // defined in 'transtab_unicode_charset.inc.php' and 'transtab_latin1_charset.inc.php'
  24. $transtab_refbase_markdown = array(
  25. "/__(?!_)(.+?)__/" => "<u>\\1</u>", // the pattern for underline (__...__) must come before the one for italic (_..._)
  26. // "/_(.+?)_/" => "_\\1_",
  27. // "/\\*\\*(.+?)\\*\\*/" => "**\\1**",
  28. "/\\[super:(.+?)\\]/i" => "<sup>\\1</sup>",
  29. "/\\[sub:(.+?)\\]/i" => "<sub>\\1</sub>",
  30. "/\\[permil\\]/" => "&permil;",
  31. "/\\[infinity\\]/" => "&infin;",
  32. "/\\[alpha\\]/" => "&alpha;",
  33. "/\\[beta\\]/" => "&beta;",
  34. "/\\[gamma\\]/" => "&gamma;",
  35. "/\\[delta\\]/" => "&delta;",
  36. "/\\[epsilon\\]/" => "&epsilon;",
  37. "/\\[zeta\\]/" => "&zeta;",
  38. "/\\[eta\\]/" => "&eta;",
  39. "/\\[theta\\]/" => "&theta;",
  40. "/\\[iota\\]/" => "&iota;",
  41. "/\\[kappa\\]/" => "&kappa;",
  42. "/\\[lambda\\]/" => "&lambda;",
  43. "/\\[mu\\]/" => "&mu;",
  44. "/\\[nu\\]/" => "&nu;",
  45. "/\\[xi\\]/" => "&xi;",
  46. "/\\[omicron\\]/" => "&omicron;",
  47. "/\\[pi\\]/" => "&pi;",
  48. "/\\[rho\\]/" => "&rho;",
  49. "/\\[sigmaf\\]/" => "&sigmaf;",
  50. "/\\[sigma\\]/" => "&sigma;",
  51. "/\\[tau\\]/" => "&tau;",
  52. "/\\[upsilon\\]/" => "&upsilon;",
  53. "/\\[phi\\]/" => "&phi;",
  54. "/\\[chi\\]/" => "&chi;",
  55. "/\\[psi\\]/" => "&psi;",
  56. "/\\[omega\\]/" => "&omega;",
  57. "/\\[Alpha\\]/" => "&Alpha;",
  58. "/\\[Beta\\]/" => "&Beta;",
  59. "/\\[Gamma\\]/" => "&Gamma;",
  60. "/\\[Delta\\]/" => "&Delta;",
  61. "/\\[Epsilon\\]/" => "&Epsilon;",
  62. "/\\[Zeta\\]/" => "&Zeta;",
  63. "/\\[Eta\\]/" => "&Eta;",
  64. "/\\[Theta\\]/" => "&Theta;",
  65. "/\\[Iota\\]/" => "&Iota;",
  66. "/\\[Kappa\\]/" => "&Kappa;",
  67. "/\\[Lambda\\]/" => "&Lambda;",
  68. "/\\[Mu\\]/" => "&Mu;",
  69. "/\\[Nu\\]/" => "&Nu;",
  70. "/\\[Xi\\]/" => "&Xi;",
  71. "/\\[Omicron\\]/" => "&Omicron;",
  72. "/\\[Pi\\]/" => "&Pi;",
  73. "/\\[Rho\\]/" => "&Rho;",
  74. "/\\[Sigma\\]/" => "&Sigma;",
  75. "/\\[Tau\\]/" => "&Tau;",
  76. "/\\[Upsilon\\]/" => "&Upsilon;",
  77. "/\\[Phi\\]/" => "&Phi;",
  78. "/\\[Chi\\]/" => "&Chi;",
  79. "/\\[Psi\\]/" => "&Psi;",
  80. "/\\[Omega\\]/" => "&Omega;",
  81. "/ +- +/" => " &ndash; ",
  82. // "/�/$patternModifiers" => "&ndash;"
  83. // Note that for UTF-8 based systems, '$patternModifiers' contains the "u" (PCRE_UTF8) pattern modifier which should cause PHP/PCRE
  84. // to treat pattern strings as UTF-8 (otherwise this conversion pattern would garble UTF-8 characters such as "�"). However, the
  85. // "�" character still seems to cause PREG compilation errors on some UTF8-based systems, which is why the line has been commented
  86. // out (it should work fine for a latin1-based system, though).
  87. );
  88. ?>