Is there anyway that I can get this plugin to honor carriage returns / line breaks etc? All the text just runs together and looks awful.
Also, inside the ending section is seems to not be honoring my class or spans. My code looks like so:
{exp:trunchtml chars="100" ending="<a class="button" href='{title_permalink=blog/}'><span>Keep Reading</span></a>"}
{body}
{/exp:trunchtml}
Sorry about that, what happened is I just had tried your plugin, and it didn’t honor carriage returns / line breaks or work with a class / span. So I installed the TruncHTML to give that a shot, but it keeps images in which I don’t want. I forgot I had that one setup when I pasted the code into my post above. My issue with the MD Eexcerpt plugin still stands though. I think MD Eexcerpt would be a better plugin for me to use, it just needs some kind of option to honor the carriage returns and needs to be able to use class/span tags in the the_link= section.
My issue with the MD Eexcerpt plugin still stands though. I think MD Eexcerpt would be a better plugin for me to use, it just needs some kind of option to honor the carriage returns and needs to be able to use class/span tags in the the_link= section.
It doesn’t currently have an option to honor carriage returns, because I’ve never, ever needed that to do simple excerpts, which is all I needed this plugin for.
You certainly can have span tags with a class in the_link. You just need to watch your quotes. If your parameter is using double quotes, use single quotes for everything within it, and vice versa.
These work:
the_link="<a href='#'><span class='foo'>MORE...</span></a>"
the_link='<a href="#"><span class="foo">MORE...</span></a>'
These don’t:
the_link="<a href='#'><span class="foo">MORE...</span></a>"
the_link='<a href="#"><span class='foo'>MORE...</span></a>'
Thank you for pointing out the error with my quotes around the class, that solved the issue I was having with my keep reading button.
I thought maybe you had included the carriage return pass through functionality in the plugin based off of your post below. It seems I’m not the only one who needed functionality like this. The way Markus proposed seems like a good way to let carriage returns pass through. I think it would make the plugin really useful to quite a few people who want to do larger excerpts.
Markus - I just came upon the need to preserve line breaks myself. I think I’ll look at updating this plugin to preserve those if possible - when I get a spare moment 😊 . As you can see, we were having a discussion about that over on this thread.
However, I do later go on to say:
My eexcerpt plugin strips everything out first, then counts based on what’s left over. And in my case, I’ll never use it on a heading and another element…always a body element or basic block of text.
I can maybe look at doing this, but considering my workload, it’s pretty low priority. Anyone is welcome to fork this on Github and add the functionality themselves, of course.
@trixpan: Is it not replacing newlines with spaces for you? I juts did some tests and I think line 81 is taking care of that.$str = str_replace("\n", " ", $str);
Ryan,
Strangely enough it was not. I had to add a @\n@siU to line 71 to get it done.
Without it the result of the parsing is the following:
<meta name="description" content="Ficar doente fora do Brasil tem lá as suas vantagens afinal muitos dos países de destino possuem um ótimo nível de serviços de saúde ainda assim nem todas as experiências são positivas.
Augusto fala da experiência de cuidar de sua tendinite morando no Canadá." />
While with the @\n@siU added I get
<meta name="description" content="Ficar doente fora do Brasil tem lá as suas vantagens afinal muitos dos países de destino possuem um ótimo nível de serviços de saúde ainda assim nem todas as experiências são positivas.Augusto fala da experiência de cuidar de sua tendinite morando no Canadá." />
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.