Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ function get_flags($setflags) {
case 'aftereach':
$flags['aftereach'] = $value;
break;
case 'paragraphs':
$flags['paragraphs'] = $value;
break;
}
}
// the include_content URL parameter overrides flags
Expand Down Expand Up @@ -305,8 +308,18 @@ function _convert_instructions(&$ins, $lvl, $page, $sect, $flags, $root_id, $inc
$no_header = false;
$sect_title = false;
$endpos = null; // end position of the raw wiki text
$paragraphs = 0;
$skip_mode = false;
$open_sects = 0;

for($i=0; $i<$num; $i++) {

if ($skip_mode) {

unset($ins[$i]);

}

// adjust links with image titles
if (strpos($ins[$i][0], 'link') !== false && isset($ins[$i][1][1]) && is_array($ins[$i][1][1]) && $ins[$i][1][1]['type'] == 'internalmedia') {
// resolve relative ids, but without cleaning in order to preserve the name
Expand Down Expand Up @@ -341,15 +354,37 @@ function _convert_instructions(&$ins, $lvl, $page, $sect, $flags, $root_id, $inc
}
break;
case 'section_open':
$open_sects++;
if ($flags['inline'])
unset($ins[$i]);
else
$conv_idx[] = $i;
break;
case 'section_close':
$open_sects--;
if ($flags['inline'])
unset($ins[$i]);
break;
case 'p_open':
$paragraphs++;
if (
($flags['paragraphs']) &&
($paragraphs > $flags['paragraphs'])
) {
// Maximum paragraph count reached. Stop processing.
$skip_mode = true;

$ins[] = array('p_close', array());
$ins[] = array('plugin', array('include_readmore',
array($page)));

for ($a=0; $a<$open_sects; $a++) {

$ins[] = array('section_close', array());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there can't be more than one open section (sections aren't nested) but paragraphs can occur e.g. inside instructions from the wrap plugin. I fear the best we can do is keeping track of all possible instructions we know.


}
}
break;
case 'internallink':
case 'internalmedia':
// make sure parameters aren't touched
Expand Down