The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> How to Break line after a special character, How to Break line after a special character
Sachin Gupta
post Sep 14 2021, 08:25 AM
Post #1





Group: Members
Posts: 9
Joined: 14-December 20
Member No.: 27,685



Dear All,

I have one HTML Script which generate a table and fields input from some database table. There is one field in my table name NC Details , i want whenever field input finds a special character like "-" . it should shift the rest of the text in new line.
Kindly be noted NC Details filed gets data from some application so user writes text there , here i am using HTML just to get the table design.
below is the code i am writing in NC Details field
[code]
<tr>
<td style="vertical-align: middle; background-color: #E1F8DA;"><span style="color: #333399; font-family: Cambria, 'Hoefler Text', 'Liberation Serif', Times, 'Times New Roman', 'serif'"><strong>NC Details</strong></span></td>
<td style="vertical-align: middle;" ><span style="color: #000000;"><strong>['NCDETAILS']</strong></span></td>
</tr>

['NCDETAILS'] is input field column name which gets data from application, Please advise
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Sep 14 2021, 09:16 AM
Post #2


Jocular coder
********

Group: Members
Posts: 2,389
Joined: 31-August 06
Member No.: 43



Unless I'm missing something, you simply use <br> as your "special character", and this then creates an HTML "newline". If the text is somehow fixed in a different format, you will need to make your server script replace the newline indication by <br>.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Sachin Gupta
post Sep 14 2021, 11:49 PM
Post #3





Group: Members
Posts: 9
Joined: 14-December 20
Member No.: 27,685



QUOTE(Brian Chandler @ Sep 14 2021, 09:16 AM) *

Unless I'm missing something, you simply use <br> as your "special character", and this then creates an HTML "newline". If the text is somehow fixed in a different format, you will need to make your server script replace the newline indication by <br>.


Hello Brian Chandler,

This is working perfectly for my case , very much thankful to you.my problem solved very easily
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Sachin Gupta
post Sep 21 2021, 12:27 AM
Post #4





Group: Members
Posts: 9
Joined: 14-December 20
Member No.: 27,685



Hello All,

I have showed this to my management and they don't want to mention <br> in the form text , can we configure ENTER or TAB button for the same . for example while writing whenever user press TAB or ENTER , it should consider the text from next line.
overall i want to replace <br> with ENTER or TAB
Please advise smile.gif

This post has been edited by Sachin Gupta: Sep 21 2021, 12:52 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Sep 21 2021, 12:49 AM
Post #5


Jocular coder
********

Group: Members
Posts: 2,389
Joined: 31-August 06
Member No.: 43



QUOTE(Sachin Gupta @ Sep 21 2021, 02:27 PM) *

Hello Brian Chandler,


Please don't just ask me! Others may also be able to help...

So do I have this right: in your DB you have text data which gets accessed and put into an html page? So where is the program that does this (generating the page)?

You just have to change it to convert newline characters in the text to '<br>' for the html document.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Sachin Gupta
post Sep 21 2021, 01:19 AM
Post #6





Group: Members
Posts: 9
Joined: 14-December 20
Member No.: 27,685



QUOTE(Brian Chandler @ Sep 21 2021, 12:49 AM) *

QUOTE(Sachin Gupta @ Sep 21 2021, 02:27 PM) *

Hello Brian Chandler,


Please don't just ask me! Others may also be able to help...

So do I have this right: in your DB you have text data which gets accessed and put into an html page? So where is the program that does this (generating the page)?

You just have to change it to convert newline characters in the text to '<br>' for the html document.


yes you are right ,That program is in Power Automate which generate the HTML Page. and here is the code which generates html page. how can i find and replace here , i fond few example that sis throgh Jquery , i am not aware of it.
[/code]
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>

<body>
<table width="100%" border="3">
 <tbody>
   <tr>
     <td colspan="7" style="text-align: left; background-color: #2e3692;"> <img src="http://beebuzz.bee.local/wp-content/uploads/2019/08/ncr-2020-Copy.png" width="492" height="93" alt=""/><strong style="font-size: 50px; color: white;"><img src="http://beebuzz.bee.local/wp-content/uploads/2019/08/ncr-clipart.png" width="100" height="112" alt=""/></strong><img src="http://beebuzz.bee.local/wp-content/uploads/2019/08/office-work.gif" width="250" height="100" /></td>
     
   </tr>
 

<tr>
<td style="vertical-align: middle; background-color: #E1F8DA;"><span style="color: #333399; font-family: Cambria, 'Hoefler Text', 'Liberation Serif', Times, 'Times New Roman', 'serif'"><strong>NC Details</strong></span></td>
<td style="vertical-align: middle;" ><span style="color: #000000;"><strong><div> @{items('Apply_to_each')?['NCDETAILS']}</div></strong></span></td>
</tr>



 </tbody>
</table>
</body>
</html>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Sep 21 2021, 02:21 AM
Post #7


Jocular coder
********

Group: Members
Posts: 2,389
Joined: 31-August 06
Member No.: 43



CODE

<div> @{items('Apply_to_each')?['NCDETAILS']}</div>


I'm sorry, I have no idea. If "Power Automate" processes this @ thing, you need to ask experts in Power Automate. I doubt if anyone else here knows about this either.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Sep 21 2021, 06:09 AM
Post #8


.
********

Group: WDG Moderators
Posts: 8,881
Joined: 10-August 06
Member No.: 7



Possibly you could use the PRE element with linebreak characters like \n instead of BR.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Sep 21 2021, 06:31 AM
Post #9


Jocular coder
********

Group: Members
Posts: 2,389
Joined: 31-August 06
Member No.: 43



QUOTE(Christian J @ Sep 21 2021, 08:09 PM) *

Possibly you could use the PRE element with linebreak characters like \n instead of BR.


Yes, but then the text won't wrap, which is generally No Good.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Sep 21 2021, 06:06 PM
Post #10


.
********

Group: WDG Moderators
Posts: 8,881
Joined: 10-August 06
Member No.: 7



CSS then:

CODE
<td style="white-space: pre-line;">
Lorem ipsum dolor sit amet-
consectetuer adipiscing elit-
sed diam nonummy nibh euismod-
tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper uscipit lobortis nislut aliquip ex ea commodo consequat.
</td>


From the spec:
QUOTE
"This value directs user agents to collapse sequences of white space. Lines are broken at preserved newline characters, and as necessary to fill line boxes."
https://www.w3.org/TR/CSS21/text.html#propdef-white-space

So you add a newline after the "-" characters (using say the Enter key, if you do it manually), then the line of text will break there but also to fill the table cell.

As a sidenote, the following is invalid:

QUOTE
CODE
<td style="vertical-align: middle;" ><span style="color: #000000;"><strong><div> @{items('Apply_to_each')?['NCDETAILS']}</div></strong></span></td>

The DIV element can't be inside SPAN or STRONG. You can also simplify the HTML, by either remove the SPAN element and instead style STRONG, or remove STRONG and style SPAN to look bold.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 27th September 2021 - 03:33 PM