summaryrefslogtreecommitdiff
path: root/inc/parser
diff options
context:
space:
mode:
Diffstat (limited to 'inc/parser')
-rw-r--r--inc/parser/handler.php42
-rw-r--r--inc/parser/parser.php5
-rw-r--r--inc/parser/xhtml.php6
3 files changed, 43 insertions, 10 deletions
diff --git a/inc/parser/handler.php b/inc/parser/handler.php
index 23c830abf..17429e69a 100644
--- a/inc/parser/handler.php
+++ b/inc/parser/handler.php
@@ -1185,7 +1185,29 @@ class Doku_Handler_Block {
var $stackClose = array(
'footnote_close','section_close',
);
-
+
+ function closeParagraph($pos){
+ // look back if there was any content - we don't want empty paragraphs
+ $content = '';
+ for($i=count($this->calls)-1; $i>=0; $i--){
+ if($this->calls[$i][0] == 'p_open'){
+ break;
+ }elseif($this->calls[$i][0] == 'cdata'){
+ $content .= $this->calls[$i][1][0];
+ }else{
+ $content = 'found markup';
+ break;
+ }
+ }
+
+ if(trim($content)==''){
+ //remove the whole paragraph
+ array_splice($this->calls,$i);
+ }else{
+ $this->calls[] = array('p_close',array(), $pos);
+ }
+ }
+
function process($calls) {
foreach ( $calls as $key => $call ) {
@@ -1212,7 +1234,8 @@ class Doku_Handler_Block {
if ( in_array($call[0],$this->stackClose ) ) {
if ( $this->inParagraph ) {
- $this->calls[] = array('p_close',array(), $call[2]);
+ //$this->calls[] = array('p_close',array(), $call[2]);
+ $this->closeParagraph($call[2]);
}
$this->calls[] = $call;
$this->removeFromStack();
@@ -1238,7 +1261,8 @@ class Doku_Handler_Block {
if ( isset($calls[$key+1]) && $calls[$key+1][0] == 'eol' ) {
if ( $this->inParagraph ) {
- $this->calls[] = array('p_close',array(), $call[2]);
+ //$this->calls[] = array('p_close',array(), $call[2]);
+ $this->closeParagraph($call[2]);
}
$this->calls[] = array('p_open',array(), $call[2]);
@@ -1260,7 +1284,8 @@ class Doku_Handler_Block {
$storeCall = TRUE;
if ( $this->inParagraph && in_array($call[0], $this->blockOpen) ) {
- $this->calls[] = array('p_close',array(), $call[2]);
+ //$this->calls[] = array('p_close',array(), $call[2]);
+ $this->closeParagraph($call[2]);
$this->inParagraph = FALSE;
$this->calls[] = $call;
$storeCall = FALSE;
@@ -1268,7 +1293,8 @@ class Doku_Handler_Block {
if ( in_array($call[0], $this->blockClose) ) {
if ( $this->inParagraph ) {
- $this->calls[] = array('p_close',array(), $call[2]);
+ //$this->calls[] = array('p_close',array(), $call[2]);
+ $this->closeParagraph($call[2]);
$this->inParagraph = FALSE;
}
if ( $storeCall ) {
@@ -1320,10 +1346,12 @@ class Doku_Handler_Block {
// Ditch the last call
array_pop($this->calls);
} else if ( !in_array($call[0], $this->blockClose) ) {
- $this->calls[] = array('p_close',array(), $call[2]);
+ //$this->calls[] = array('p_close',array(), $call[2]);
+ $this->closeParagraph($call[2]);
} else {
$last_call = array_pop($this->calls);
- $this->calls[] = array('p_close',array(), $call[2]);
+ //$this->calls[] = array('p_close',array(), $call[2]);
+ $this->closeParagraph($call[2]);
$this->calls[] = $last_call;
}
}
diff --git a/inc/parser/parser.php b/inc/parser/parser.php
index 23f2c13d7..d66ed5cca 100644
--- a/inc/parser/parser.php
+++ b/inc/parser/parser.php
@@ -165,10 +165,11 @@ class Doku_Parser_Mode_Footnote extends Doku_Parser_Mode {
class Doku_Parser_Mode_Header extends Doku_Parser_Mode {
function preConnect() {
+ //we're not picky about the closing ones, two are enough
// Header 1 is special case - match 6 or more
$this->Lexer->addSpecialPattern(
- '[ \t]*={6,}[^\n]+={6,}[ \t]*\n',
+ '[ \t]*={6,}[^\n]+={2,}[ \t]*\n',
'base',
'header'
);
@@ -176,7 +177,7 @@ class Doku_Parser_Mode_Header extends Doku_Parser_Mode {
// For the rest, match exactly
for ( $i = 5; $i > 1; $i--) {
$this->Lexer->addSpecialPattern(
- '[ \t]*={'.$i.'}[^\n]+={'.$i.'}[ \t]*\n',
+ '[ \t]*={'.$i.'}[^\n]+={2,}[ \t]*\n',
'base',
'header'
);
diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php
index 70a8c7830..37cd36cf3 100644
--- a/inc/parser/xhtml.php
+++ b/inc/parser/xhtml.php
@@ -750,8 +750,12 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$ret .= ' class="media'.$align.'"';
- if (!is_null($title))
+ if (!is_null($title)) {
$ret .= ' title="'.$this->_xmlEntities($title).'"';
+ $ret .= ' alt="'.$this->_xmlEntities($title).'"';
+ }else{
+ $ret .= ' alt=""';
+ }
if ( !is_null($width) )
$ret .= ' width="'.$this->_xmlEntities($width).'"';