I thought that excessive blank lines had been sorted
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Feedback
- :
- Community Site Feedback
- :
- Re: I thought that excessive blank lines had been ...
Re: I thought that excessive blank lines had been sorted
08-06-2016 12:25 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
@jaread83 - OK one more thought, what about reverse iterating the <div> tag looking at each <p> element, if this element is 'empty' it can be removed provided it is the last element in the sub tree i.e. the next forward tag would be the </div>, just a thought.
Re: I thought that excessive blank lines had been sorted
08-06-2016 12:28 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Thats what my second bit of code is attempting to do by using the 'reverse' order working up the DOM. You will see that for each post it is attempting to start at the end and go back looking for empty paragraph tags. Once it reaches something that doesn't match the regex it should return false and then move on to the next post.
Unfortunately my code doesn't work so it needs something else.. I am just unsure what its failing on.
Frontend Web Developer | www.plus.net
If you have an idea to improve the community, create a new topic on our Community Feedback board to start a discussion about your idea.
Re: I thought that excessive blank lines had been sorted
08-06-2016 12:32 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
I have added comments to demonstrate what it 'should' do...
// find each instance of the post message on a page
$(".lia-message-body-content").each(function(){
// now within the post message, collect the p tags in reverse order $($("p").get().reverse()).each(function() {
// define context to the p tag var $this = $(this);
// check if the pattern matches <p> </p> if ($this.html().replace(/\s| /g, '').length == 0){
// remove if matches.. $this.remove(); console.log('found a match'); } else {
// don't do anything and stop the function if there is content return false; console.log('stop!'); }; }); });
Frontend Web Developer | www.plus.net
If you have an idea to improve the community, create a new topic on our Community Feedback board to start a discussion about your idea.
Re: I thought that excessive blank lines had been sorted
08-06-2016 1:34 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
@jaread83 - Well this works for me.
<html> <head> <meta content="text/html;charset=utf-8" http-equiv="Content-Type"> <meta content="utf-8" http-equiv="encoding"> <title>Test</title> <style> .lia-message-body-content { background-color:red; border:1px solid black ; font-size: 18px; } </style> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"> </script> <script> $(document).ready(function() { $(".lia-message-body-content").each(function() { $($("p").get().reverse()).each(function() { var $this = $(this); if ($this.html().replace(/\s| /g, '').length == 0) { $this.remove(); } else { return false; } }); }); }); </script> </head> <body> <div class="lia-message-body-content"> <p>Blah</p> <p> </p> <p> </p> <p>Another Paragraph I want to keep</p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> </div> </body> </html>
So as to why is doesn't work for you then, I don't know But you might want to fix the return false statement and put it after the console.log('stop') as that is unreachable.
Re: I thought that excessive blank lines had been sorted
08-06-2016 1:42 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
I will give this a try out on staging and see what happens. Cheers for sparing a bit of your time to help out with this.
Frontend Web Developer | www.plus.net
If you have an idea to improve the community, create a new topic on our Community Feedback board to start a discussion about your idea.
Re: I thought that excessive blank lines had been sorted
08-06-2016 2:32 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
That didn't work and I think its becuase of the return false. It removes the empty paragraphs from the very last instance but skips over the rest. I created a jsfiddle here:
https://jsfiddle.net/659Lejgz/
Maybe its the for each loop, maybe it needs to be an array.. hmmm
Frontend Web Developer | www.plus.net
If you have an idea to improve the community, create a new topic on our Community Feedback board to start a discussion about your idea.
Re: I thought that excessive blank lines had been sorted
08-06-2016 3:16 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
boom!
https://jsfiddle.net/659Lejgz/4/
Frontend Web Developer | www.plus.net
If you have an idea to improve the community, create a new topic on our Community Feedback board to start a discussion about your idea.
Re: I thought that excessive blank lines had been sorted
on 08-06-2016 3:24 PM - last edited on 08-06-2016 8:04 PM by dvorak
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Glad to see it's all working now, but are you going to install it?
Moderator's note by Adie (Dvorak) removed excessive white space.
Re: I thought that excessive blank lines had been sorted
08-06-2016 3:31 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
I can't put it up yet as there are a few other things on staging waiting to go up as well which needs to go through change management. I have implemented it on staging and it looks like it is all working. There is also an issue that if you quote someone who has empty paragraphs it carries over into the quote (very annoying!).
Frontend Web Developer | www.plus.net
If you have an idea to improve the community, create a new topic on our Community Feedback board to start a discussion about your idea.
Re: I thought that excessive blank lines had been sorted
08-06-2016 3:35 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
scratch that, I just extended the function to include blockquotes too and it works for that as well (woohoo).
Frontend Web Developer | www.plus.net
If you have an idea to improve the community, create a new topic on our Community Feedback board to start a discussion about your idea.
Re: I thought that excessive blank lines had been sorted
08-06-2016 6:44 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
I shall go and play
Re: I thought that excessive blank lines had been sorted
08-06-2016 9:03 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
@Anonymous wrote:
Glad to see it's all working now, but are you going to install it?
Moderator's note by Adie (Dvorak) removed excessive white space.
Of course the space was put there for testing!
Re: I thought that excessive blank lines had been sorted
09-06-2016 5:15 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
jaread83 wrote:
I can't put it up yet as there are a few other things on staging waiting to go up as well which needs to go through change management. I have implemented it on staging and it looks like it is all working.
Re: I thought that excessive blank lines had been sorted
28-07-2016 11:11 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
@Oldjim wrote:
https://community.plus.net/t5/General-Chat/H-D-T-V/m-p/1340819#M202879
Is a quote of the post with the problem
There are numerous lines with
<p> </p>
Just going through the threads that were mentioned in the latest update thread.
A fix for this issue will be pushed live today, you can view details of the fix on the update thread here. See the second and third item on the 'regular changes' section.
Frontend Web Developer | www.plus.net
If you have an idea to improve the community, create a new topic on our Community Feedback board to start a discussion about your idea.
Re: I thought that excessive blank lines had been sorted
29-07-2016 11:31 PM - edited 29-07-2016 11:38 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
I've thanked your post above and will just test the fix out here ..... and then edit the post after to tidy up anything that needs to be.
Well I put loads of blank lines at the end of the post which got successfully removed from the "posted" post. I've left some above to show they correctly remain.
@jaread83 wrote:
Just going through the threads that were mentioned in the latest update thread.
A fix for this issue will be pushed live today, you can view details of the fix on the update thread here. See the second and third item on the 'regular changes' section.
Above, I've now quoted part of your post and put some extra blank lines within the quote which should remain, and put some at the end which should get removed
And that all seems to work perfectly as expected, so another one for @Oldjim to hopefully mark your post above as a fix
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Feedback
- :
- Community Site Feedback
- :
- Re: I thought that excessive blank lines had been ...