HTML Purifier new line after shift+enter (As Intagram) - htmlpurifier

Sorry I'm not sure how to say this (I don't remember the exact term for that).
But if the user writes for example:
Hi
My Name is
Phil
The result should be (as it is in Instagram)
Hi
My Name is
Phil
I don't how I can change it with Purifier, because I get only one line:
Hi My Name is Phil
How should my config be?

Ok it was easier than thought.
I changed the DOM Element (in my case span) with CSS to:
white-space: pre-wrap;
word-wrap: break-word;
And before getting my Result I'm going through this line
preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $string);
It works perfectly

Related

How to include span tags in an array?

I think this question has been asked before but I couldn't find a satisfactory answer. I am building a page using React and I need to make some parts of the text bold. Normally I would do this using span tags but the problem is that the text is coming from an array. I tried including the span tag in the array by concatenation but I am getting a weird result. Anyone knows a workaround?
the code
the result
Try wrapping your string in a p tag like:
<p>Bla bla bla <span>...</span></p>

Not able to get text value from tag

Can anyone tell, how to get text fightname(Spicejet) as a string?
Tried code but giving me blank value
WebElement flightname= driver.findElement(By.xpath("//div[#class='top_first_part clearfix']/div[2]/span[1]")).getText();
also tried with javascript also but it giving me null value
Thanks in advance!!!
Url - https://flights.makemytrip.com/makemytrip/search/O/O/E/1/0/0/S/V0/DEL_BOM_08-08-2017?contains=false&remove=
Image of tag FYI
The xpath you were using was not able to uniquely identify the container for first flight name. Try following:
WebElement flightname= driver.findElement(By.xpath("//div[starts-with(#class, 'clearfix listing_row')][1]//div[#class='top_first_part clearfix']//span[#class='pull-left airline_info_detls']/span[1]")).getText();
Let me know, whether it works for you.
WebElement Name=driver.findElement(By.xpath(".//*[#id='content']/div/div[2]/div[4]/div[2]/div[5]/div/div[1]/div[1]/span[1]/span[2]/span[1]"));
String flightName= Name.getText();
System.out.println(flightName);
Try this code it is working fine, I guess your xpath is wrong, it does not locate any Node. So try this. I hope it works for You.
driver.get("http://flights.makemytrip.com/makemytrip/search/O/O/E/1/0/0/S/V0/DEL_BOM_08-08-2017?contains=false&remove=");
WebElement Name= driver.findElement(By.xpath(".//[#id='content']/div/div[2]/div[4]/div[2]/div[5]/div/div[1]/div[1]/span[1]/span[2]/span[1]"));
String flightName= Name.getText();
System.out.println(flightName);

Time page load and display in layout footer

Best solution for timing the page load from as early as possible in the app process, and displaying in the layout footer, without modifying Cake source?
Edited solution. Credit to Everton Yoshitani.
// app/Layouts/default.ctp
echo round(microtime(true) - TIME_START, 3);
Nothing wrong with your code, but if you wanted even more accurate, use a constant inAPP/webroot/index.php right at the top:
<?php
// set a constant for use in app/view/layout/default.ctp
define('MTIME', microtime(true));
/**
* PHP 5
*
and layout:
// see app/webroot/index.php for constant declaration
echo round(microtime(true) - MTIME, 3);
as this file is the very first one accessed (assuming using .htaccess). This relies on you using a constant in an unexpected place.
bootstrap.php is generally the place to put code like this, but a simple comment in your webroot/index.php explaining why the constant is there would clarify any confusion for anyone reading your code.

How to set width and height of text field in cakephp?

In my application, I need to take input from the user for a column named 'body' in a table in the database.
My code in the .ctp file is:
echo $form->input('body',array('style'=>'width: 900px'));
In this way, i am able to specify the width of the body field which works fine. But, I want to specify the height as well.
I tried echo $form->input('body',array('style'=>'width: 900px height: 500px'));
echo $form->input('body',array('style'=>'width: 900px','style'=>'height: 500px'));
The first one doesnt work for either width or height and the second one modifies only the height but not the width.
Can someone please tell me how to overcome this issue.
Thank you very much in advance.
// in a css file.
.txtArea { width:900px; height:500px; }
// in your view
echo $form->input('body', array('class'=>'txtArea'));
would be the recommended and preferred manner.
Alternatively, make sure your inline CSS is correct:
echo $form->input('body', array('style'=>'width:900px; height:500px;'));
Your code appears to be missing a ;, and of course by specifying style twice you will be overwriting the previous value.

Problem with word wrap (?) in IE7

I am making great progress on a current project, but of coarse, now I need to go through and fix all the various bugs popping up in Internet Explorer - one of my biggest issues right now is that the text lines for a div added via a jquery script is not wrapping properly.
I tried using this, but didnt work in IE7:
.AuthorBlurb, .AuthorBlurb p {
white-space: pre-wrap; /* CSS3 */
white-space: -moz-pre-wrap; /* Firefox */
white-space: -pre-wrap; /* Opera < 7 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* IE */
}
Here is a link to view an example: http://arcaspicio.squarespace.com/insights/2010/7/23/risk-management-for-border-security.html -- when i view it, the "Contributor" info on the left is not wrapping properly in Internet Explorer 7. I have tried all sorts of stuff with no success!
Any help is greatly appreciated!!
IE Developer Toolbar is showing that the containing <p> has white-space: nowrap; set, coming from .journal-entry-tag .posted-by. Most likely IE has the white-space setting overriding the word break, so the whole thing is being treated as one big long single word, hence it running off the screen the way it is.

Resources