wordpress wpautop function adds empry paragraph tags - wordpress

I created an "About Me" widget which contains title, image and description fields.
I want to replace new lines with html tags <p>text</p>.
When I try to use "wpautop" function it adds empty tags "<p></p>" in the beginning and end of the text.

Please use javascript for this-
$('p:empty').remove();

Related

GTM - CSS Element

I'm wanting to create a variable to grab the username from a landing page (assuming it's possible). In my attached examples, I'd like to grab the text "Landing_page_test".
I'm just learning CSS so I'm not able to single out just that text.
Any thoughts/suggestions would be much appreciated! enter image description here
Console
Elements Pane of Landing Page
document.querySelector returns an element, not the text. Add .innerText
Try it out on this page: document.querySelector("a.question-hyperlink").innerText to get the name of the question.
But you probably don't want to do it as custom html tag. You probably want to do it on click. in that case, you have {{Clicked Element}} variable in GTM, of which you can also get .innerText, or get its .parentElement and further navigate DOM from the clicked element as you wish and get whatever you need.
Here's the html of the Location & Date/Time text blocks
Text Block

How I can have only link body copied?

For example, if link is < a href ...> stuff </a>, so that you copy it in textfield, only string 'stuff' is copied and nothing more?
When I copy some page with links in text in redactor editor, it copies links AS links, I want only string (link name, string inside link tag) be copied, and nothing more
Have you test to add HREF LINK in deniedTags like this:
jQuery('#redactor').redactor({
deniedTags: ['a']
});
Reference
In redactor 9.1.1 use setting pastePlainText
This setting allows users to have all html tags stripped from the pasted text. Generally it is "paste as plain text" feature.
Default setting is false, to turn on, set the following:
$('#redactor').redactor({
pastePlainText: true
});

Formatting Title element in XML Feed with HTML tags

I am using ASP.Net's inbuilt classes to create XML feeds for a website. Here's the code I have,
SyndicationFeed myFeed = new SyndicationFeed();
myFeed.Title = TextSyndicationContent.CreatePlaintextContent
("XYZ - In the first line <br/> in the second line");
When rendered it shows as it is -
XYZ - In the first line <br/> in the second line
whereas I want it
XYZ - In the first line
in the second line
I see that the behavior is only to myFeed.Title, whereas in myFeed.Description, I can use any HTML tags.
Any way to get HTML tags working with Titles?
Use the SyndicationContent.CreateHtmlContent Method instead. SyndicationContent.CreatePlaintextContent always escapes the text to make it render literally.

How to trim html tags from text in asp.net grid view?

I have used asp.net ajax html editor and i saved data in database. But now i want to retrieve it and show it in grid view. But when i retrieve that, it also shows those html tags (generated by asp.net ajax editor). So, i want to trim those tags and show plain text in grid view. How do i do that?
Thanks
Go to you db and look, how it is saved. Maybe it is save encoded. If it is not the case, you can use some simple regex to remove all those tags.
<[^<]+?>
This shows you just plain text and removes all Tags
To stripe the html tags from text you can utilize the
RegEx.Replace("str","Pattern","replacementstring "); method which there exist in
System.Text.RegularExpressions namespace
for example
Plain_Body = Regex.Replace(txtBody.Text, #"<[^>]*>", string.Empty);
here i am replacing the html specific characters with String.Empty or "" you can add additional characters if you wish to pattern like #"<[^>]*>" and spaces(&nbsp) and Ampersand(&amp) etc

Write html code inside asp.net (C#) (.cs) page

I would like to add some paragraphs or new lines or words dynamically but I want to make gaps between every part and the other. How is it possible to do that in the c# code page?
You can use LiteralControl to add HTML tags like that :
Page.Controls.Add(new LiteralControl("<p>New<br />Line</p>"));
I was able to do it using lblMessage.Text and then replacing the " character by the ' character in the HTML code...
lblMessage.Text = "<a href='javascript:history.go(-1)'>Go Back</a>";
Ideally, you don't want to add markup code to your codebehind pages. But if you must, you can perhaps use HTML's <p> element to make different paragraphs. By default, each paragraph has some top and bottom margin to separate it from other elements on the page.
You can do this using HttpModule. HttpModule can intercept request and response and modify as you need.
Maybe this is the proper way:
http://msdn.microsoft.com/en-us/library/620b4fzf(VS.71).aspx
So if you like to add what a paragraph with a break inside:
HtmlGenericControl paragraph = new HtmlGenericControl("p");
paragraph.Controls.Add(new HtmlGenericControl("br"));
Page.Controls.Add(paragraph );

Resources