瀏覽代碼

Merge dee3ec7cfe945f0977174749d207f9168d77c545 into 69d67b2b7198d2e1483d7f44d5d4320a63903572

Roberts 12 年之前
父節點
當前提交
6c9dffb996
共有 1 個文件被更改,包括 12 次插入0 次删除
  1. 12 0
      lib/pico.php

+ 12 - 0
lib/pico.php

@@ -167,6 +167,18 @@ class Pico {
 		}
 		
 		if($headers['date']) $headers['date_formatted'] = date($config['date_format'], strtotime($headers['date']));
+		
+		if(empty($headers['title'])){
+			preg_match('/^(.+?)[ ]*\n(=+|-+)[ ]*\n+/imu',$content,$matches);
+			if(count($matches) > 0){
+					$headers['title'] = $matches[1];
+			}else{
+				preg_match('/^\#{1}([^\#].*)$/imu',$content,$matches);
+				if(count($matches) > 0){
+					$headers['title'] = $matches[1];
+				}
+			}
+		}
 
 		return $headers;
 	}