1<?php 2/** 3 * Render Plugin for XHTML output, 4 * with preserved line break between non-ASCII characters removed, 5 * which may otherwise result in a blank between two characters unexpectedly. 6 * 7 * @author Huizhe Wang <huizhewang@outlook.com> 8 */ 9 10if(!defined('DOKU_INC')) die(); 11if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/'); 12 13require_once DOKU_INC . 'inc/parser/xhtml.php'; 14 15/** 16 * The Renderer 17 */ 18class renderer_plugin_nonblank extends Doku_Renderer_xhtml { 19 /** 20 * Make available as XHTML replacement renderer 21 * 22 * @param string $format requested format 23 */ 24 public function canRender($format) { 25 return $format == 'xhtml'; 26 } 27 28 /** 29 * Render plain text data, and remove the single line break 30 * if the previous and following characters are both full-width characters, 31 * especially CJK. 32 * 33 * @param $text 34 */ 35 function cdata($text) { 36 $esc = $this->_xmlEntities($text); 37 $this->doc .= preg_replace('/(?<=[^\x00-\xFF])\n(?=[^\x00-\xFF])/um', '', $esc); 38 } 39} 40