summaryrefslogtreecommitdiff
path: root/inc/parser.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/parser.php')
-rw-r--r--inc/parser.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/inc/parser.php b/inc/parser.php
index 0fe04afba..e14c5bcd5 100644
--- a/inc/parser.php
+++ b/inc/parser.php
@@ -838,4 +838,21 @@ function mediaformat($text){
return format_link_build($link);
}
+/**
+ * Get first heading, to be used as a page title
+ *
+ * @author Jan Decaluwe <jan@jandecaluwe.com>
+ */
+function getFirstHeading($text){
+ $title = '';
+ $lines = split("\n",$text);
+ foreach($lines as $line){
+ if(preg_match('/^\s*==+(.+?)==+\s*$/',$line,$matches)){
+ $title = $matches[1];
+ break;
+ }
+ }
+ return $title;
+}
+
?>