Removing Quote inside <title> tag - html

The code I used to Produce This is the same as the one WITHOUT this problem
(just pulling from a different database column)
if (!string.IsNullOrEmpty(childspec.titlew)) {
wtitle = childspec.titlew;
ltlMasterPageTitle.Text = HttpUtility.HtmlDecode(wtitle) + "";
} else {
wtitle = childspec.laytitle;
ltlMasterPageTitle.Text = "Company Name - " + HttpUtility.HtmlDecode(wtitle);
}
here is the code that does the output.
When its the ELSE case then the content does not have a wrapper around this
not sure if this is a serious SEO issue as well**
ALSO how do i remove this extra Tab space infront of the text?

I still don't know where the extra space came from but I just applied
Trim()
again before the output code and it removed all extra spacing and quotes

Related

Break word at specific character

I realise that similar questions have been asked, but none quite like this.
I have a situation where I am using BEM to display some classes in code tags. Below is an example:
Obviously the default behaviour is to break words at a hyphen, as we can see is happening in the example. Is there a way that I can control what characters the line-break occurs at? I would like to be able to have class name integrity maintained so that the line break occurs before each period . if necessary.
I have another solution using jquery,
$('.mypara').each(function () {
var str = $(this).html();
var htmlfoo = str.split('.').join('</br>');
$(this).html(htmlfoo);
});
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<code class="mypara">
This is-the HTML if its - characters exceed 50. characters it should go-to next line
</code>
<code class="mypara">
This is the HTM-if its. characters exceed 50 - characters it should. go-to next-line
</code>
Unfortunately I don't think there is a way to do everything you want with pure CSS.
UPDATE: removed spaces before periods in JS solution.
If you are able to use JavaScript you could process the code tag's contents to disable wrapping for words with hyphens and you could wrap each block starting with a period in an inline-block span.
The following code breaks the contents of each code tag into a list of blocks that start with either space or period. Each block is wrapped with a span that prevents wrapping, and blocks that begin with a period are additionally marked as display: inline-block;. This should give the behaviour you are looking for, and additionally preserve all content when copy-pasting text.
CSS:
.no-wrap-hyphen {
white-space: nowrap;
}
.wrap-period {
display: inline-block;
}
JavaScript (run this function on window load and resize):
function wrapPeriodsNotHyphens() { // run on window load or resize
var codes = document.getElementsByTagName( "code" );
for ( var i = 0; i < codes.length; i++ ) {
currentCode = codes[ i ].innerHTML.split(/(?=[ .])/); // split by spaces and periods
for ( var c = 0; c < currentCode.length; c++ ) {
// surround each item with nowrap span
currentCode[ c ] = '<span class="no-wrap-hyphen">' + currentCode[ c ] + '</span>';
if ( currentCode[ c ].indexOf( '.' ) > -1 ) {
// add a zero size space at the start for periods
currentCode[ c ] = '<span class="wrap-period">' + currentCode[ c ] + '</span>';
}
}
codes[ i ].innerHTML = currentCode.join('');
}
}

Is it possible to replace a char by another with CSS?

My goal is to replace the display of _ by a blank space in my HTML document:
ex:
hello_world
should be
hello world
Possible Solutions:
Would be to create a
FONT that uses blank inside the _ character
Still looking for it!
Can this be done with CSS?
It is important that we do not modify the original string (we keep the _ character), but we simply display a blank space instead.
Regards
I think this is possible in CSS for a one-off kind of thing:
<span class="replace-me">hello_world</span>
.replace-me{
display:none;
}
.replace-me:after{
content:'hello world';
}
But I'm guessing that's not exactly what you want.
Otherwise, to replace all instances in JS:
document.body.innerHTML = document.body.innerHTML.replace('_', ' ');
You'll likely have to get a little more fancy with the regex but you could parse the page for underscores and wrap them in a <span>. Then use a pseudo element that has it's content set to a single space to replace the wrapped underscore.
<p>
Some_content with_underscores_going_on.
</p>
span:after {
font-size: 16px;
content: ' ';
}
span {
font-size: 0;
}
// jQuery
var f = $("body");
f.html( f.html().replace(/_/g,"<span>_</span>") );
jsFiddle: http://jsfiddle.net/h2h1bmyn/1/

How to remove more than one whitespace character from HTML?

I want to remove extra whitespace which is coming from the user end, but I can't predict the format of the HTML.
For example:
<p> It's interesting that you would try cfsetting, since nothing in it's
documentation would indicate that it would do what you are asking.
Unless of course you were mis-reading what "enableCFoutputOnly" is
supposed to do.
</p>
<p>
It's interesting that you would try cfsetting, since nothing in it's
documentation would indicate that it would do what you are asking.
Unless of course you were mis-reading what "enableCFoutputOnly" is
supposed to do.</p>
Please guide me on how to remove more than one whitespace character from HTML.
You could use regex to replace any cases of multiple whitespace characters with a single space by looping over the result until no more multiple whitespace occurances exist:
lastTry = "<p> lots of space </p>";
nextTry = rereplace(lastTry,"\s\s", " ", "all");
while(nextTry != lastTry) {
lastTry = nextTry;
nextTry = REReplace(lastTry,"\s\s", " ", "all");
}
Tested working in CF10.
if you don't want to do it thru code out of total lazyness
=> http://jsbeautifier.org/
if you want to do it by code then a regex would be another option
This should do it:
<cfscript>
string function stripCRLFAndMultipleSpaces(required string theString) {
local.result = trim(rereplace(trim(arguments.theString), "([#Chr(09)#-#Chr(30)#])", " ", "all"));
local.result = trim(rereplace(local.result, "\s{2,}", " ", "all"));
return local.result;
}
</cfscript>

Replace continuous space with single space and multiple "&nbsp" elements

I have one html document which contains whitespaces in some nodes. For example,
<B>This is Whitespace Node </B>
When this html is displayed in the browser, more than one continuous space in html is always displayed as one space. To avoid this issue, I want to replace the continuous spaces with a single space and multiple elements.
What is the best solution to achive this?
I am using C# 2005.
Try this,
string str = "<B>This is Whitespace Node </B>";
Regex rgx = new Regex("([\\S][ ])");
string result = rgx.Replace(str, "$1.")
.Replace(" .","?")
.Replace(" ","&nbsp")
.Replace("?"," ");
Use CSS's white-space property as per http://www.w3.org/TR/CSS2/text.html#white-space-prop
white-space: pre-wrap
Or, if you really want to do it with bruteforce, replace two consecutive spaces with a non-breaking-space and a normal space... I strongly recommend against this.
string text = originalText.Replace(" ", " ");
You can try
String.Replace(" ", " ")
if you prefer regex
Regex rgx = new Regex("([ \t]|&nsbp)+");
string result = rgx.Replace(input, " ");
I assume you are setting the value of the control from code behind? If so then ...
<strong><asp:Literal id="myLiteral">This is Whitespace Node </asp:Literal></strong>
And in code behind ...
var myText = "This is Whitespace Node ";
myLiteral.Text = myText.Replace(" ", " ");
If no code behind or not in a literal ...
<strong><%= "This is Whitespace Node ".Replace(" ", " ") %></strong>

Is Flying Saucer's treatment of images in cells a bug?

I managed to whittle my example down to the following (it uses some reasonably hefty data URLs but stackoverflow should flow them off the side nicely...):
static
{
String oldValue = System.getProperty("java.protocol.handler.pkgs");
if (oldValue == null)
{
System.setProperty("java.protocol.handler.pkgs", "org.xhtmlrenderer.protocols");
}
else if (!oldValue.contains("org.xhtmlrenderer.protocols"))
{
System.setProperty("java.protocol.handler.pkgs", oldValue + "|org.xhtmlrenderer.protocols");
}
}
#Test
public void testLegacyCellSpacing() throws Exception
{
ITextRenderer renderer = new ITextRenderer();
renderer.setDocumentFromString("<html>\n" +
" <head>\n" +
" <title>Some title</title>\n" +
" </head>\n" +
" <body>\n" +
" <div>\n" +
"<table cellpadding=\"0\" cellspacing=\"0\">\n" +
"<tr>\n" +
"<td>\n" +
" <img src=\"data:image/png;base64,/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAHgAA/+4ADkFkb2JlAGTAAAAAAf/bAIQAEAsLCwwLEAwMEBcPDQ8XGxQQEBQbHxcXFxcXHx4XGhoaGhceHiMlJyUjHi8vMzMvL0BAQEBAQEBAQEBAQEBAQAERDw8RExEVEhIVFBEUERQaFBYWFBomGhocGhomMCMeHh4eIzArLicnJy4rNTUwMDU1QEA/QEBAQEBAQEBAQEBA/8AAEQgAUwC5AwEiAAIRAQMRAf/EAJQAAAEFAQEAAAAAAAAAAAAAAAIAAQMEBQYHAQADAQEBAAAAAAAAAAAAAAAAAQIDBAUQAAEDAwIDBgQEBgEFAAAAAAERAgMAIQQxEkETBVFhcYEiMpFCFAahscHR4VIjM2M08fBygqIVEQACAgEDAgUDBAMBAAAAAAAAARECMSFBEnEDUWGBIjKRQoKhwRMz4VJyBP/aAAwDAQACEQMRAD8Ayl/5pwUShA8+6nW9eqecHuQ0bfitQrf8hVfNzXQpDAN07u3RtDaSljSbcIvlhbcrTFBWOB1lQ4SFexf0q1j5mTu5GXHtcR6JALHuNSry4dbV6obrG9X0Li6FKZSaZTqAgpJddFqyQgfKiXgPGgA/4ohe3GgAwb99EHVGB23oxp+f50AQujcMtmSwOcSDHIBohuvkatFyoCNSP3oGr5m60Zj5npKg/K4agmy0gK2DnbxHhtBL4g7muIREcgaDV8Ncbi4qt02MB00RN43ua48DdVWtfHiYoBuulC8wZUDXLdQtTMiPE1eMLBoN3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RTJOHUePGsxLgtpMcWamWXU9KY6R1N41k67LT0MgTA9KuDGcUKSCTMk5mjLg4cqTGglGEE1GYLkJ8aHUoOeNWYNSUUpZ2ygcTTRFJLEQFpb3jqKjGKfa2Lug0sVzNJddXSAceNc3eb+5ZKlhnlFI/9HdIveZDpOCDP51a+trZLunoLfrs7FxbSmbrZKPpGcmsPct2iCzTics5NTc33uXA3b03OJ8Kz3WRrwmAFHU3ia0Rmxl99ZlXJnCP3mlPb0jrzABwyqu5Z2vcZxrZhCBcaXrvRN1CpbhTAYzTCA4nhwNCbo0STqIyBg/OlziGYRh8hR27aAG42Jn2+FACrT2QzFiUkYim7fcql2MgfZhHzpJhX1FZGRn9tZrl0OzKxhcYOU8KQHZP3FLVwK0uGyIOFbLd3q1p515/YWrRcC4cG9s11rVy5bftwXtmPOmB0lutEg48qqHuYnTC5k0plKdUyuYBoluyRrXDkDhQBp20mQMDhHLxrZDc6w2m7d0Nhjy4VplvxFLY9EaO2conx9eNPtf4x7f7cqlSs7cbLXOic6H8YVKlJACtW04RP9sfnUqVW/cWvYJchVLxy/OpUqRmDd5XPbMcc/wC3hQW47CT/ALp9IqVK1Rmzn3v8pzyOX51zt177n9P0eXGpUpgL2cd+zz/1+XDhNdLdzJ93CMv9tSpSAyH/ABmZ4+7P04ULz21zjwqVKYF49sZ5N7orntHcGXHOYqVKAGW8hnmfwK7P2/24T+OU1KlAHQu+3H1/hQ248PhNSpQBH/yifD8YVtw8PWpUpAf/2Q==\" width=\"185\" height=\"83\"/>\n" +
"</td>\n" +
"</tr>\n" +
"</table>\n" +
" </div>\n" +
" </body>\n" +
"</html>", null);
renderer.layout();
File pdfFile = File.createTempFile("TestFlyingSaucer", ".pdf");
OutputStream output = new BufferedOutputStream(new FileOutputStream(pdfFile));
try
{
renderer.createPDF(output, true);
}
finally
{
output.close();
}
System.out.println(); // breakpointing here to look at the output. no good assertions available for checking this problem yet. :(
}
This code runs, and generates a PDF which has incorrect spaces between each image. I can't figure out what is causing the spaces, but I can't figure out if it's a bug either. What I do know:
Web browsers don't show spaces between the images.
If you remove the images and replace it with something like a fixed size div, the problem magically goes away (this proves that flying saucer is doing the right thing with the legacy cellpadding and cellspacing attributes, which was my initial concern.)
If you add a 1 pixel border to the cells (td { border: 1px solid red; }), it shows that the extra space is outside the td elements.
If you remove the whitespace between <td> and <img the problem appears to vanish.
It seems odd to me that extra space inside the element could result in extra padding/margins outside the element. Perhaps I'm completely misunderstanding HTML though, so I'm hoping that someone will set me straight here before I jam an issue in their tracker.
(Also: Preempting the typical knee-jerk answer of "don't use tables for that" - this is not my HTML, I'm trying to render real world HTML to PDF after cleaning it up. This example shows post-cleanup HTML to rule out the problem being in the cleanup code.)
Browsers are sensitive to white space in HTML in many places, including inside and in between elements, and even in places you would not expect. For instance, if you had a ul with li elements, if you use CSS to style the items with li {display:inline} to make a horizontal menu, any white space between </li> and the next <li> will space the menu items apart!
In this particular case, seeing the white space indenting the first child element is certainly unusual but I can't say categorically if it would be considered a bug according to the HTML standards. Your best solution is indeed to simply eliminate white space where it causes issues.