Skip to content

Instantly share code, notes, and snippets.

@mrmt
Created September 23, 2010 03:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrmt/593017 to your computer and use it in GitHub Desktop.
Save mrmt/593017 to your computer and use it in GitHub Desktop.
--- nucleus/plugins/NP_ImpExp.php.org 2010-09-11 13:22:20.939423749 +0900
+++ nucleus/plugins/NP_ImpExp.php 2010-09-10 20:52:50.000000000 +0900
@@ -107,6 +107,29 @@
);
}
+ // mrmt
+ function unfold($source){
+ $in_pre = 0;
+ $buf = '';
+ foreach(explode("\n", $source) as $line){
+ $line = rtrim($line);
+ if(preg_match('<pre>', $line)){
+ $in_pre = 1;
+ }
+ if(preg_match('</pre>', $line)){
+ $in_pre = 0;
+ }
+ if(preg_match('/[a-zA-Z0-9]$/', $line) && !$in_pre){
+ $buf .= ' ';
+ }
+ $buf .= $line;
+ if($in_pre){
+ $buf .= "\n";
+ }
+ }
+ return $buf;
+ }
+
function init(){
// include language file for this plugin
$language = ereg_replace( '[\\|/]', '', getLanguageName());
@@ -388,6 +411,7 @@
$itemVar['convert_breaks'] = $stripbr ? 1 : 0;
$itemVar['body'] = $item->body;
+ $itemVar['itemid'] = $item->itemid; // mrmt
$itemVar['more'] = $item->more;
$preg_expr = "#<\%(image|popup|media)\((.*?)\)%\>#i";
$this->currentItem = $item;
@@ -397,11 +421,15 @@
$itemVar['body'] = preg_replace_callback($delim_expr, array(&$this, '_convertDelim'), $itemVar['body']);
$itemVar['more'] = preg_replace_callback($delim_expr, array(&$this, '_convertDelim'), $itemVar['more']);
if( $stripbr ){
$itemVar['body'] = preg_replace("/
([\r\n])/","$1",$itemVar['body']);
$itemVar['more'] = preg_replace("/
([\r\n])/","$1",$itemVar['more']);
}
+ // mrmt
+ $itemVar['body'] = $this->unfold($itemVar['body']);
+ $itemVar['more'] = $this->unfold($itemVar['more']);
+
echo preg_replace("/(\r\n|\n|\r)/m", "\n", mb_convert_encoding( $tpl->fill($entryTpl, $itemVar, null), 'UTF-8', _CHARSET));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment