Advertisement
bitetti

Using markdown in php

Jun 14th, 2011
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 5.63 KB | None | 0 0
  1. <?php
  2.  
  3. include_once './libs/markdown.php';
  4.  
  5. $plain_text = "";
  6. $html_text = "";
  7.  
  8. if ( isset($_REQUEST['texto']))
  9. {
  10.     $plain_text = $_REQUEST["texto"];
  11.     $html_text = Markdown( $plain_text );
  12. }
  13.  
  14.  
  15. ?>
  16. <!DOCTYPE html>
  17. <html>
  18.     <head>
  19.         <title>Markdow preview</title>
  20.        
  21.         <style type="text/css">
  22.        
  23.         #prev {
  24.             width: 100%;
  25.             height: 500px;
  26.             overflow: scroll;
  27.             overflow-x: auto;
  28.             border: solid 1px #000000;
  29.         }
  30.        
  31.         #formulario {
  32.             width: 100%;
  33.             height: 40%;
  34.         }
  35.        
  36.         #formulario textarea {
  37.             width: 100%;
  38.             height: 200px;
  39.         }
  40.        
  41.         </style>
  42.     </head>
  43.    
  44.     <body>
  45.         <section id="prev" class="wikistyle">
  46.             <?php echo $html_text; ?>
  47.         </section>
  48.         <section id="formulario">
  49.             <form id="markdow" action="md.php" method="post">
  50.                 <textarea name="texto" id="texto"><?php echo $plain_text; ?></textarea><br/>
  51.                 <input type="submit" value="testar" />
  52.             </form>
  53.         </section>
  54.        
  55.     </body>
  56.    
  57.     <!-- kibada da página do GitHub para formatar o texto -->
  58.     <style type="text/css">
  59. .wikistyle h1, .wikistyle h2, .wikistyle h3, .wikistyle h4, .wikistyle h5, .wikistyle h6 {
  60.     border: 0 none !important;
  61. }
  62. .wikistyle h1 {
  63.     border-top: 4px solid #AAAAAA !important;
  64.     font-size: 170% !important;
  65.     margin-top: 1.5em !important;
  66.     padding-top: 0.5em !important;
  67. }
  68. .wikistyle h1:first-child {
  69.     border-top: medium none !important;
  70.     margin-top: 0 !important;
  71.     padding-top: 0.25em !important;
  72. }
  73. .wikistyle h2 {
  74.     border-top: 4px solid #E0E0E0 !important;
  75.     font-size: 150% !important;
  76.     margin-top: 1.5em !important;
  77.     padding-top: 0.5em !important;
  78. }
  79. .wikistyle h3 {
  80.     margin-top: 1em !important;
  81. }
  82. .wikistyle hr {
  83.     border: 1px solid #DDDDDD;
  84. }
  85. .wikistyle p {
  86.     line-height: 1.5em !important;
  87.     margin: 1em 0 !important;
  88. }
  89. .wikistyle a.absent {
  90.     color: #AA0000;
  91. }
  92. .wikistyle ul, #wiki-form .content-body ul {
  93.     margin: 1em 0 1em 2em !important;
  94. }
  95. .wikistyle ol, #wiki-form .content-body ol {
  96.     margin: 1em 0 1em 2em !important;
  97. }
  98. .wikistyle ul li, #wiki-form .content-body ul li, .wikistyle ol li, #wiki-form .content-body ol li {
  99.     margin-bottom: 0.5em;
  100.     margin-top: 0.5em;
  101. }
  102. .wikistyle ul ul, .wikistyle ul ol, .wikistyle ol ol, .wikistyle ol ul, #wiki-form .content-body ul ul, #wiki-form .content-body ul ol, #wiki-form .content-body ol ol, #wiki-form .content-body ol ul {
  103.     margin-bottom: 0 !important;
  104.     margin-top: 0 !important;
  105. }
  106. .wikistyle blockquote {
  107.     border-left: 5px solid #DDDDDD !important;
  108.     color: #555555 !important;
  109.     margin: 1em 0 !important;
  110.     padding-left: 0.6em !important;
  111. }
  112. .wikistyle dt {
  113.     font-weight: bold !important;
  114.     margin-left: 1em !important;
  115. }
  116. .wikistyle dd {
  117.     margin-bottom: 1em !important;
  118.     margin-left: 2em !important;
  119. }
  120. .wikistyle table {
  121.     margin: 1em 0 !important;
  122. }
  123. .wikistyle table th {
  124.     border-bottom: 1px solid #BBBBBB !important;
  125.     padding: 0.2em 1em !important;
  126. }
  127. .wikistyle table td {
  128.     border-bottom: 1px solid #DDDDDD !important;
  129.     padding: 0.2em 1em !important;
  130. }
  131. .wikistyle a code, .wikistyle a:link code, .wikistyle a:visited code {
  132.     color: #4183C4 !important;
  133. }
  134. .wikistyle img {
  135.     max-width: 100%;
  136. }
  137. .wikistyle pre.console {
  138.     background-color: black !important;
  139.     color: white !important;
  140.     font-size: 12px !important;
  141.     line-height: 1.5em !important;
  142.     margin: 1em 0 !important;
  143.     padding: 0.5em !important;
  144. }
  145. .wikistyle pre.console code {
  146.     background-color: black !important;
  147.     border: medium none !important;
  148.     color: white !important;
  149.     font-size: 12px !important;
  150.     padding: 0 !important;
  151. }
  152. .wikistyle pre.console span {
  153.     color: #888888 !important;
  154. }
  155. .wikistyle pre.console span.command {
  156.     color: yellow !important;
  157. }
  158. .wikistyle .frame {
  159.     display: inline-block;
  160.     margin: 0;
  161. }
  162. .wikistyle .frame img {
  163.     display: block;
  164. }
  165. .wikistyle .frame > span {
  166.     border: 1px solid #AAAAAA;
  167.     display: block;
  168.     padding: 4px;
  169. }
  170. .wikistyle .frame span span {
  171.     display: block;
  172.     font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif;
  173.     font-size: 10pt;
  174.     line-height: 10pt;
  175.     margin: 0;
  176.     padding: 4px 0 2px;
  177.     text-align: center;
  178. }
  179. .wikistyle .float-left {
  180.     float: left;
  181.     padding: 0.5em 1em 0.25em 0;
  182. }
  183. .wikistyle .float-right {
  184.     float: right;
  185.     padding: 0.5em 0 0.25em 1em;
  186. }
  187. .wikistyle .align-left {
  188.     display: block;
  189.     text-align: left;
  190. }
  191. .wikistyle .align-center {
  192.     display: block;
  193.     text-align: center;
  194. }
  195. .wikistyle .align-right {
  196.     display: block;
  197.     text-align: right;
  198. }
  199. .wikistyle pre {
  200.     background-color: #EEEEEE;
  201.     border: 1px solid #DDDDDD;
  202.     border-radius: 3px 3px 3px 3px;
  203.     color: #444444;
  204.     font-size: 12px;
  205.     line-height: 1.5em;
  206.     margin: 1em 0;
  207.     overflow: auto;
  208.     padding: 5px;
  209. }
  210. .wikistyle pre code {
  211.     background-color: #EEEEEE !important;
  212.     border: medium none !important;
  213.     font-size: 12px !important;
  214.     padding: 0 !important;
  215. }
  216. .wikistyle code {
  217.     background-color: #F8F8FF !important;
  218.     border: 1px solid #DEDEDE !important;
  219.     color: #444444 !important;
  220.     font-size: 12px !important;
  221.     padding: 0 0.2em !important;
  222. }
  223. .markdown-format .highlight pre {
  224.     background: none repeat scroll 0 0 #FAFAFA;
  225.     line-height: 12px;
  226. }
  227. .markdown-format .highlight .gu, .markdown-format .highlight .gd, .markdown-format .highlight .gi {
  228.     display: inline-block;
  229.     margin-left: -5px;
  230.     padding: 0 0 0 5px;
  231.     width: 100%;
  232. }
  233. .markdown-format .highlight .gu {
  234.     background: none repeat scroll 0 0 #EAF2F5;
  235.     color: #999999;
  236.     font-weight: normal;
  237. }
  238.     </style>
  239. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement