Problem with custom kirbytext tag. No output after closing </div>

I’m experiencing strange behavior with kirbytext having multiple divs. In the basic example below, all output after the first closing div is suppressed. I’m running Kirby 2.0.6 running on a local environment (Mac OS 10.10) with MAMP.

Is this a bug? How can I have multiple divs in a custom tag?

I love Kirby. Keep up the great work.

<?php

kirbytext::$tags['dummytag'] = array(
'html' => function($tag) {

$html = '<div id="one">';
    $html .= '<p>This is the first div</p>';
$html .= '</div>';     //All output after this is suppressed

$html .= '<div id="two">';
    $html .= '<p>This is the second div</p>';
$html .= '</div>';

return $html;

}

);

?>

I’m also having some very strange results with custom tags. Like white space not collapsing and broken images with div tags in an unordered list. The broken images are even somewhat random. These problems appeared after version 2.0.5.

I’ve been in contact with Bastian about this and it seems that Parsedown might be causing some problems. That’s why I am hoping that Bastian implements an option to switch back to the original Markdown parser. Which, so I’m told, is ‘slow’ in comparison, but hey it worked imho very well.

Waiting for Bastian to chime in …

As a temporary fix, is there any way to get an older version of Kirby? I can’t find any downloads online.

Using Git you can check out any old version of Kirby …

I can confirm that the bug is not present for Kirby 2.0.0. With that old version of Kirby, the example kirbytext tag above generates the following code:

<div id="one"><p>This is the first div</p></div><div id="two"><p>This is the second div</p></div>

With the current version of Kirby (2.0.6), the example kirbytext tag generates:

<div id="one"><p>This is the first div</p></div>

Why do I need two divs? I am creating a kirbytext tag for two synced Owl Carousels, so the presence of two divs in the output is essential:
http://owlgraphic.com/owlcarousel/demos/sync.html

The parser should not touch your mark up. Having some nested divs is nothing out of the ordinary …

Could you please try with the nightly build: http://download.getkirby.com/nightly. Parsedown — our third-party Markdown parser — acted up a bit in older versions.

This nightly version doesn’t solve my problems with custom Kirby tags not collapsing white space. Divs in unordered lists are properly parsed tough.

Also have some broken images where “placeholder” in the filename of thumbnails completely disappear:
filename: 01-blocks-01-placeholder-2474211f6c8e53190ecbeaae13ac3b40.jpg
parsed: 01-blocks-01–2474211f6c8e53190ecbeaae13ac3b40.jpg

This is not consistent on another page the thumbs are properly displayed. The thumbnails are in a div in an unordered list.

(Sorry for ‘hijacking’ this thread …)

The nightly build does not work. It too only generates:

<div id="one"><p>This is the first div</p></div>

Tis strange, I just tested it with a version 2.0.6 starter kit and it works perfectly, outputting two divs …

@keith: I’ve also tried your dummytag with kirby-nightly-2.0.7-20150226163831 and it works ok.

(I’m still getting strange behaviour with thumbs in a tag. Like thumbs getting repeated underneath the body text or still displaying after I have deleted the tag. I’m going to rewrite the tag so I can track at which point it fails.)

Problems with images and nested div tags in ul’s are now solved as of Kirby v. 2.1

I am still experiencing the original problem.

What I am typing into the page is: (dummytag: text)

And here is the physical link to my dummytag.php file:

For Kirby 2.0.0 and 2.0.5 I get the following output:

`

This is the first div

This is the second div

`

For Kirby 2.06 and 2.1 I get:
<div id="one"><p>This is the first div</p></div>

Here is my config file, but these seem to have no effect :

c::set('content.file.extension', 'md');
c::set('debug', true);
c::set('markdown.extra', 'true');

I just tried it on the default site that comes with the Kirby nightly build (2.1.0 currently) and my dummy tag does work. This means there is something else in my other site that it interfering with how markdown is rendered. Will work on troubleshooting…

Whatever it is, it was not a problem for older versions of Kirby (<2.0.5)

Eureka! It’s the .md extension for my content files. I changed the home.txt file to home.md and I only get the first div outputted now.

I must admit that I can’t confirm your findings and found no matter if the files have the extension .txt or .md, the result is same:

  • 2 divs with markdown.extra deactivated
  • 1 div with markdown.extra activated

Yes, I must admit that I now am confused. I tried toggling both the extension and markdown extra and now I only get one div. This is on a “clean” Kirby 2.1.0 site.


File:
home.md

Config:
c::set('content.file.extension', 'md'); c::set('markdown.extra', 'false');

Result: 1 div


File:
home.md

Config:
c::set('content.file.extension', 'md'); c::set('markdown.extra', 'true');

Result: 1 div


File:
home.txt

Config:
c::set('content.file.extension', 'txt'); c::set('markdown.extra', 'true');

Result: 1 div


File:
home.txt

Config:
c::set('content.file.extension', 'txt'); c::set('markdown.extra', 'false');

Result: 1 div