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.

128 lines
7.3 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_bibtex_refbase.inc.php
  11. // Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/includes/transtab_bibtex_refbase.inc.php $
  12. // Author(s): Matthias Steffens <mailto:refbase@extracts.de>
  13. //
  14. // Created: 10-Aug-06, 21:00
  15. // Modified: $Date: 2008-07-30 14:16:35 +0000 (Wed, 30 Jul 2008) $
  16. // $Author: msteffens $
  17. // $Revision: 1182 $
  18. // Search & replace patterns for conversion from LaTeX/BibTeX markup & entities to refbase markup. Converts LaTeX fontshape markup (italic, bold, underline)
  19. // into appropriate refbase commands, super- and subscript as well as greek letters in math mode get converted into the respective refbase commands.
  20. // You may need to adopt the LaTeX markup to suit your individual needs.
  21. // Notes: - search & replace patterns must be specified as perl-style regular expression and search patterns must include the leading & trailing slashes
  22. $transtab_bibtex_refbase = array(
  23. '/\\\\(?:ul|hl|uuline|uwave)\\{(.+?)\\}/i' => "__\\1__",
  24. '/\\\\(?:text)?it\\{(.+?)\\}/i' => "_\\1_",
  25. '/\\\\(?:text)?bf\\{(.+?)\\}/i' => "**\\1**",
  26. '/((\\$\\^\\{.+?\\}\\$|\\\\textsuperscript\\{.+?\\}|\\{\\\\text(one|two|three)superior\\})+)/ie' => "bibtexSuperScriptToRefbase('\\1')", // function 'bibtexSuperScriptToRefbase()' will convert LaTeX/BibTeX superscript markup to appropriate refbase markup
  27. '/((\\$\\_\\{.+?\\}\\$|\\\\textsubscript\\{.+?\\})+)/ie' => "bibtexSubScriptToRefbase('\\1')", // function 'bibtexSubScriptToRefbase()' will convert LaTeX/BibTeX subscript markup to appropriate refbase markup
  28. '/\\{\\\\textperthousand\\}/' => "[permil]",
  29. '/\\$\\\\infty\\$/' => "[infinity]",
  30. '/\\$\\\\alpha\\$/' => "[alpha]",
  31. '/\\$\\\\beta\\$/' => "[beta]",
  32. '/\\$\\\\gamma\\$/' => "[gamma]",
  33. '/\\$\\\\delta\\$/' => "[delta]",
  34. '/\\$\\\\epsilon\\$/' => "[epsilon]",
  35. '/\\$\\\\zeta\\$/' => "[zeta]",
  36. '/\\$\\\\eta\\$/' => "[eta]",
  37. '/\\$\\\\theta\\$/' => "[theta]",
  38. '/\\$\\\\iota\\$/' => "[iota]",
  39. '/\\$\\\\kappa\\$/' => "[kappa]",
  40. '/\\$\\\\lambda\\$/' => "[lambda]",
  41. '/\\$\\\\mu\\$/' => "[mu]",
  42. '/\\$\\\\nu\\$/' => "[nu]",
  43. '/\\$\\\\xi\\$/' => "[xi]",
  44. '/\\$o\\$/' => "[omicron]",
  45. '/\\$\\\\pi\\$/' => "[pi]",
  46. '/\\$\\\\rho\\$/' => "[rho]",
  47. '/\\$\\\\varsigma\\$/' => "[sigmaf]",
  48. '/\\$\\\\sigma\\$/' => "[sigma]",
  49. '/\\$\\\\tau\\$/' => "[tau]",
  50. '/\\$\\\\upsilon\\$/' => "[upsilon]",
  51. '/\\$\\\\phi\\$/' => "[phi]",
  52. '/\\$\\\\chi\\$/' => "[chi]",
  53. '/\\$\\\\psi\\$/' => "[psi]",
  54. '/\\$\\\\omega\\$/' => "[omega]",
  55. '/\\$A\\$/' => "[Alpha]",
  56. '/\\$B\\$/' => "[Beta]",
  57. '/\\$\\\\Gamma\\$/' => "[Gamma]",
  58. '/\\$\\\\Delta\\$/' => "[Delta]",
  59. '/\\$E\\$/' => "[Epsilon]",
  60. '/\\$Z\\$/' => "[Zeta]",
  61. '/\\$H\\$/' => "[Eta]",
  62. '/\\$\\\\Theta\\$/' => "[Theta]",
  63. '/\\$I\\$/' => "[Iota]",
  64. '/\\$K\\$/' => "[Kappa]",
  65. '/\\$\\\\Lambda\\$/' => "[Lambda]",
  66. '/\\$M\\$/' => "[Mu]",
  67. '/\\$N\\$/' => "[Nu]",
  68. '/\\$\\\\Xi\\$/' => "[Xi]",
  69. '/\\$O\\$/' => "[Omicron]",
  70. '/\\$\\\\Pi\\$/' => "[Pi]",
  71. '/\\$R\\$/' => "[Rho]",
  72. '/\\$\\\\Sigma\\$/' => "[Sigma]",
  73. '/\\$T\\$/' => "[Tau]",
  74. '/\\$\\\\Upsilon\\$/' => "[Upsilon]",
  75. '/\\$\\\\Phi\\$/' => "[Phi]",
  76. '/\\$X\\$/' => "[Chi]",
  77. '/\\$\\\\Psi\\$/' => "[Psi]",
  78. '/\\$\\\\Omega\\$/' => "[Omega]",
  79. '/^opt(?=(URL|LOCATION|NOTE|KEYWORDS)=)/mi' => ""
  80. );
  81. $bibtexSuperScriptSearchReplaceActionsArray = array(
  82. "/\\$\\^\\{(.+?)\\}\\$/" => '\\1',
  83. "/\\\\textsuperscript\\{(.+?)\\}/i" => '\\1',
  84. "/\\{\\\\textonesuperior\\}/i" => '1', // (superscript one)
  85. "/\\{\\\\texttwosuperior\\}/i" => '2', // (superscript two)
  86. "/\\{\\\\textthreesuperior\\}/i" => '3' // (superscript three)
  87. );
  88. $bibtexSubScriptSearchReplaceActionsArray = array(
  89. "/\\$\\_\\{(.+?)\\}\\$/" => '\\1',
  90. "/\\\\textsubscript\\{(.+?)\\}/i" => '\\1'
  91. );
  92. // --------------------------------------------------------------------
  93. // Converts LaTeX/BibTeX superscript markup to appropriate refbase markup:
  94. function bibtexSuperScriptToRefbase($sourceString)
  95. {
  96. global $bibtexSuperScriptSearchReplaceActionsArray;
  97. $sourceString = searchReplaceText($bibtexSuperScriptSearchReplaceActionsArray, $sourceString, true); // function 'searchReplaceText()' is defined in 'include.inc.php'
  98. return "[super:" . $sourceString . "]";
  99. }
  100. // --------------------------------------------------------------------
  101. // Converts LaTeX/BibTeX subscript markup to appropriate refbase markup:
  102. function bibtexSubScriptToRefbase($sourceString)
  103. {
  104. global $bibtexSubScriptSearchReplaceActionsArray;
  105. $sourceString = searchReplaceText($bibtexSubScriptSearchReplaceActionsArray, $sourceString, true); // function 'searchReplaceText()' is defined in 'include.inc.php'
  106. return "[sub:" . $sourceString . "]";
  107. }
  108. ?>