迷你纺织品类

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了迷你纺织品类相关的知识,希望对你有一定的参考价值。

This is a version of Textile that only accepts paragraps, bold, italics, links, and images. Enjoy.
  1. <?php
  2.  
  3. class TextiLite{
  4.  
  5. /*
  6.   TextiLite:
  7.   A lightweight version of Textile built with PHP by Evan Walsh
  8.   Version 001
  9.  
  10.   Based on the work of:
  11.   http://codeigniter.com/wiki/BBCode_Helper/
  12.   http://codeigniter.com/forums/viewthread/69615/
  13.  
  14.   Supports:
  15.   <br/> by the way of newline
  16.   *Text* => <strong>Text</strong>
  17.   _Text_ => <em>Text</em>
  18.   !http://image.url! => <img src="http://image.url"/>
  19.   "Text":http://text.url => <a href="http://text.url" title="Text">Text</a>
  20.   */
  21.  
  22. function paragraph($text){
  23. $paragraphs = explode(" ", $text);
  24. $output = null;
  25. foreach($paragraphs as $paragraph) {
  26. $output .= " <p>".$paragraph."</p> ";
  27. }
  28. return $output;
  29. }
  30.  
  31. function textile($text = null){
  32. $regex = array(
  33. '/(.+) (.+)/',
  34. '/*([^*]+)*/',
  35. '/\_([^*]+)\_/',
  36. '/(!)((?:http|https)(?::\/{2}[\w]+)(?:[\/|\.]?)(?:[^\s"]*))(!)/',
  37. '/(")(.*?)(").*?((?:http|https)(?::\/{2}[\w]+)(?:[\/|\.]?)(?:[^\s"]*))/',
  38. );
  39. $replace = array(
  40. "$1<br/>$2",
  41. "<strong>$1</strong>",
  42. "<em>$1</em>",
  43. "<img src="$2"/>",
  44. "<a href="$4" title="$2">$2</a>",
  45. );
  46. return preg_replace($regex,$replace,$text);
  47. }
  48.  
  49. function process($text){
  50. $text = $this->paragraph($text);
  51. $text = $this->textile($text);
  52. return $text;
  53. }
  54.  
  55. }
  56.  
  57. ?>

以上是关于迷你纺织品类的主要内容,如果未能解决你的问题,请参考以下文章

摆摊心得

ruby RubySteps 012 - Rails - 迷你框架片段

中国制造升级 中国品牌“绽放”加拿大

福柜智能货柜三步消费体验,布局在消费者身边的迷你小超市

敲黑板2020yarnexpo秋冬纱线展展商报名接近尾声!

敲黑板丨2020yarnexpo秋冬纱线展展商报名接近尾声!