Just stopping by, looking good around here Like the new forum.
I have a tiny code change that greatly improves the use of Markdown in blocks. Right now, you can use Markdown in pages, blocks, and blogs to compose your content. However if you use the pages for structure, blocks for content method, you can run into a problem. For example, if you have your home page set up with some code like this:
And then you wish to use Markdown inside either of those content blocks, it will not work since markdown is not parsed when inside of regular html (The divs).
But there is a simple fix that will allow the markdown block to be parsed before it gets put into the page. If you edit the inc/tags/block.php file on line 34.
Change:
echo $home;
to
echo $parsedown->text($home);
Michael - Would be great to get this into the main version.
This seems a specification of markdown: only parsing what’s not in a tag.
I worked around this by using parsedownextra by the original maker of parsedown. Just add it to index.php so the source code reflects the following:
include("inc/plugins/parsedown.php");
include("inc/plugins/parsedownextra.php");
$parsedown = new ParsedownExtra();
Next, add markdown=“1” to every DIV that needs markdown in its block. Like:
Thanks for the input, but my post already contained the solution to the issue I was raising. By editing the block.php file, blocks are parsed prior to being placed thus removing the issue of Markdown inside of tags. And you don’t have to add any additional markdown=“1” attributes.
True, and adding markdown=“1” is not very nice to do.
How would calling parsedown() for “every” block on a page affect the overall performance? And then once again from layout.php while “all” blocks have already been parsed?
Is it negligible?
I guess I’ll just try to combine both “solutions”, so I can still benefit from the other extra’s that parsedownExtra has.
@RoZZaH - I made changes only to index.php, not layout.php. Also, I tested it only with version 4.5.2.
I have not yet tested it on 4.6 or higher, but it could work just fine for all version 4.x releases.
To use parsedownextra in version 4.5.2, I did the following to index.php.
change
include("inc/plugins/parsedown.php");
$parsedown = new ParseDown();
to
include("inc/plugins/parsedown.php");
include("inc/plugins/parsedownextra.php");
$parsedown = new ParsedownExtra(); // mind the capitalized word 'Extra'!
You need to copy the parsedownextra files to the inc/plugins/ folder, of course, but that’s all.
Now, let’s hope that, when pulse5 is released, that this forum will be archived. Or even better: split into separate sections for version 3 and version 4; it contains valuable information.
Thanks dude
I tried this with 4.7 and couldn’t get it to work - as a complication I am using localizer so that may have been interfering - I was getting markup as code/html - including markdown hashes - so I just decided to echo $content
I’ve got something working now so i’m happy enough
can’t wait to get my mitts on pulse 5 - hopefully parsedown extra supported