Why are Paragraph spaces being omitted - database

I have a form which accepts varchar2(5000). It is basically a description field. Now when users enter spces after paragraphs, they are all combined into on paragraph, and not multiple as it is entered.
Why? Ex - This is one paragraph.
This is another paragraph.
Here is what is happening -
This is one paragraph.This is another paragraph.

Are you displaying this data on a webpage or via HTML in some way? If so, then white-space is not handled in a straightforward fashion and that might be causing confusion.
Update - it appears that this is being displayed on a webpage.
You need to do one of several things:
Display your text inside a <pre> element on your page
OR
Replace carriage returns in your text with <br/> chars before sending to the webpage
(You might also need to do something with spaces too, if you need to have multiple of them displayed accurately).
This is nothing to do with databases and only to do with how HTML is displayed.
Have a look at this answer Rendering Plaintext as HTML maintaining whitespace – without <pre>

Related

Algolia InstantSearch: How to make a search agnostic to formatting with parens?

I'm trying to make a React instantsearch that lets you search phone numbers. They need to be displayed in this format: "(123)456-7890" but I want to be able to be able to search with either "(123)456-7890" or "1234567890".
I thought I could just store it in the index formatted and then the typo tolerance would take care of non-formatted queries. But I get no results with the query "1234567890". It apparently has to do with the fact that the formatting splits the number into three words and the query is just one word. Bizarrely, this means that adding the parentheses doesn't get you more matching characters on the search, but leaving them out can cause the query not to match at all.
I then tried just storing it as non-formatted (only digits) in the index. This time, both the formatted and unformatted queries got a match. But when typing it in digit-by-digit, the result disappears when I get to "(123)", only reappearing when I get to "(123)456-7". It seems like a frustrating and bizarre user experience to be typing exactly the number the result shows and having it disappear.
I've tried adding the perens to the optional words setting, but that didn't seem to have any effect. I think if I could get Algolia to ignore the perens and dash instead of replacing them with a space, this whole thing wouldn't be a problem. Is there a way to accomplish that? Maybe it's best to find a way to filter the query before it gets sent to Algolia? How should I go about that?
Store 1234567890 in an attribute named phoneNoFormat and (123)456-7890 in an attribute named phoneFormat. Include both in searchableAttributes. On the display side, look in the _highlightResult field to see which attribute matched and render the highlighted result for that attribute. With default typo tolerance each of these queries will match and correctly highlight either one or both of the attributes.
1234567890
123-456-7890
(123)456-7890
(123) 456-7890
(123)4567890
(123) 4567890
Since you're using React InstantSearch, you will need to make your own Hits component, where you can change the attribute name used to display the result on a per-hit basis. Thankfully this is not too complicated. Just see the documentation for connectHits.
When you are looping through the hits, look at each the _highlightResult property of each hit to see which of the two attributes matched. Then, when you create the <Highlight /> component set the attributeName property to the right attribute. So you have this:
<Highlight attributeName='phoneFormat' hit={hit}/>
Or this:
<Highlight attributeName='phoneNoFormat' hit={hit}/>

Angular template variable replace markup on the fly

I am working on a heavy dataset.
so I am placing a nested variable inside a table
{{entry.text}}
but this can have several names like
Clare Butterfield /n/r Barry Burton
--
really I want to replace the carriage returns with a br tag
so each name goes on another line
{{(entry.text).replace("/n", "<br>")}}
You'll need two pieces to complete this:
1) A filter that will take in the text and replace /n with <br/>, and
2) The ng-bind-html directive to get angular to use that <br/> instead of just displaying Clare Butterfield <br/> Barry Burton
in the end your html will look something like this:
<span ng-bind-html="::entry.text | newLineFilter"/>
For an example of a similar filter to what you need, see this SO question here:
Angular filter to replace all underscores to spaces
For the ngBindHTML directive, see here:
https://docs.angularjs.org/api/ng/directive/ngBindHtml
any questions?
p.s. since your data-set is large you may notice that I added 2 colons in the example above to indicate that it's using one-time binding. This will prevent angular from recalculating the value too often and save on performance. Those aren't strictly necessary, so if you find your text is not updating when you expect it to, just remove them.

Add blank line between two lines of text in webcal event's description

How to add blank line between two lines of text in webcal event's description? This \n\n doesn't work.
It might help if you would provide a full iCalendar stream but, assuming you encoded them correctly, using "\n" is the only way to express intentional line break. Did you try to display your event using different clients ?

AngularJs Search functionality is not working when more than one special characters

I have implemented Angular Js search functionality in application. When I have enter more than one special characters for example '!#' it will display all the results.I think the exclamation character is the problem. How can I resolve this? In their demo site is also not working.http://docs.angularjs.org/api/ng.filter:filter
source can find from their site.
See you are working somewhat wrong, because it allows you to have the multiple special characters search, but in your case you are using "!#" it means not include all those result having "#" in it.
So, if you choose to have "#*" it will show you to get all the result having these characters together.

Confusion rendering unescaped HTML and newlines

I have a forum like site, where people should be able to add strings like:
<<<<<
>.<
etc.
Also I want to preserve the new lines. Besides I replace many newlines in the server with 1.
For first feature I found the solution is to use ng-bind-html="myText"
that works.
But I have a problem with the newlines, not matter what I do, they are not displayed.
If I don't do anything (also no replacements in the server), they are rendered as newlines in the source and not displayed.
If I replace them with <br> or <br/> before rendering, they show as source -> <br> or <br/>.
If I don't use ng-bind-html anymore, and render the text as normal expression, I get escaped html: <br> (besides, in this case, the strings mentioned first also don't work).
What do I have to do? Thanks in advance!
It's more of a CSS issue. Use: white-space: pre;.

Resources