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.

107 lines
4.8 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_pdf.inc.php
  11. // Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/includes/transtab_refbase_pdf.inc.php $
  12. // Author(s): Matthias Steffens <mailto:refbase@extracts.de>
  13. //
  14. // Created: 11-Jun-06, 01:13
  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 PDF markup & entities. Note that there's currently no conversion of emdashes
  19. // or markup for greek letters and super-/subscript (since I don't know how to print chars by code number or how to print Unicode chars directly).
  20. // Search & replace patterns must be specified as perl-style regular expression and search patterns must include the leading & trailing slashes.
  21. $transtab_refbase_pdf = array(
  22. "/__(?!_)(.+?)__/" => "<u>\\1</u>", // the pattern for underline (__...__) must come before the one for italic (_..._)
  23. "/_(.+?)_/" => "<i>\\1</i>", // html-style fontshape markup is recognized and converted by the pdf-php package
  24. "/\\*\\*(.+?)\\*\\*/" => "<b>\\1</b>",
  25. "/\\[super:(.+?)\\]/ie" => "superScriptToLatin1('\\1')", // function 'superScriptToLatin1()' will convert superscript letters '1', '2' and '3' to appropriate latin1 entities
  26. "/\\[sub:(.+?)\\]/i" => "\\1", // we remove markup which we cannot successfully convert to latin1 entities and replace it with an ASCII representation
  27. "/\\[permil\\]/" => "per mille",
  28. "/\\[infinity\\]/" => "infinity",
  29. "/\\[alpha\\]/" => "alpha",
  30. "/\\[beta\\]/" => "beta",
  31. "/\\[gamma\\]/" => "gamma",
  32. "/\\[delta\\]/" => "delta",
  33. "/\\[epsilon\\]/" => "epsilon",
  34. "/\\[zeta\\]/" => "zeta",
  35. "/\\[eta\\]/" => "eta",
  36. "/\\[theta\\]/" => "theta",
  37. "/\\[iota\\]/" => "iota",
  38. "/\\[kappa\\]/" => "kappa",
  39. "/\\[lambda\\]/" => "lambda",
  40. "/\\[mu\\]/" => "mu",
  41. "/\\[nu\\]/" => "nu",
  42. "/\\[xi\\]/" => "xi",
  43. "/\\[omicron\\]/" => "omicron",
  44. "/\\[pi\\]/" => "pi",
  45. "/\\[rho\\]/" => "rho",
  46. "/\\[sigmaf\\]/" => "sigmaf",
  47. "/\\[sigma\\]/" => "sigma",
  48. "/\\[tau\\]/" => "tau",
  49. "/\\[upsilon\\]/" => "upsilon",
  50. "/\\[phi\\]/" => "phi",
  51. "/\\[chi\\]/" => "chi",
  52. "/\\[psi\\]/" => "psi",
  53. "/\\[omega\\]/" => "omega",
  54. "/\\[Alpha\\]/" => "Alpha",
  55. "/\\[Beta\\]/" => "Beta",
  56. "/\\[Gamma\\]/" => "Gamma",
  57. "/\\[Delta\\]/" => "Delta",
  58. "/\\[Epsilon\\]/" => "Epsilon",
  59. "/\\[Zeta\\]/" => "Zeta",
  60. "/\\[Eta\\]/" => "Eta",
  61. "/\\[Theta\\]/" => "Theta",
  62. "/\\[Iota\\]/" => "Iota",
  63. "/\\[Kappa\\]/" => "Kappa",
  64. "/\\[Lambda\\]/" => "Lambda",
  65. "/\\[Mu\\]/" => "Mu",
  66. "/\\[Nu\\]/" => "Nu",
  67. "/\\[Xi\\]/" => "Xi",
  68. "/\\[Omicron\\]/" => "Omicron",
  69. "/\\[Pi\\]/" => "Pi",
  70. "/\\[Rho\\]/" => "Rho",
  71. "/\\[Sigma\\]/" => "Sigma",
  72. "/\\[Tau\\]/" => "Tau",
  73. "/\\[Upsilon\\]/" => "Upsilon",
  74. "/\\[Phi\\]/" => "Phi",
  75. "/\\[Chi\\]/" => "Chi",
  76. "/\\[Psi\\]/" => "Psi",
  77. "/\\[Omega\\]/" => "Omega",
  78. // "/\"(.+?)\"/" => "/quotedblleft\\1/quotedblright",
  79. // "/ +- +/" => " � " // endash (w.r.t. the "�" character, see e.g. note in file 'transtab_refbase_rtf.inc.php')
  80. );
  81. $latin1SuperScriptSearchReplaceActionsArray = array(
  82. "/1/" => '�', // <U00B9> (superscript one)
  83. "/2/" => '�', // <U00B2> (superscript two)
  84. "/3/" => '�' // <U00B3> (superscript three)
  85. // "/([^���]+)/" => '[super:\\1]' // keep superscript markup in place for any text that has no matching superscript entity in Unicode
  86. );
  87. // --------------------------------------------------------------------
  88. // Converts superscript text to appropriate Unicode entities:
  89. function superScriptToLatin1($sourceString)
  90. {
  91. global $latin1SuperScriptSearchReplaceActionsArray;
  92. $sourceString = searchReplaceText($latin1SuperScriptSearchReplaceActionsArray, $sourceString, true); // function 'searchReplaceText()' is defined in 'include.inc.php'
  93. return $sourceString;
  94. }
  95. ?>