I have htmltext as
<p>Here is what some pupils told me about how they prepared for and fared in yesterday's preliminary round.</p>
<hr />
<p>"I will stay calm and try my best. If I do not know a word, I will just have to put something down."</p>
<p><strong>some text</strong></p>
<hr />
<p>"I am more confident than last year because I have experience. I read the newspaper and I looked through the dictionary for difficult words and tagged them."</p>
<p><strong>some text</strong></p>
<hr />
I am displaying the same as textarea.htmlText .
But the textarea displays the above with too many blank lines in between them. Is there a way i can remove the line breaks in the text? the text is coming as it is from server side.
Style the p tag in CSS.
Example:
p{
line-height:0.5;
}
Related
I'd like to have <br> elements from CKEditor instances like that, not <br />. I found this question with an answer, but I don't know where that code should go, in config.js? In my <script> element/JS file? And, actually, I want to know if I can use a config in CKEDITOR_CONFIGS to change this.
Example:
I write the following in my browser:
This is the first line
This is the second line.
I get this in the inspector:
<body class="cke_editable cke_editable_themed cke_contents_ltr cke_show_borders" spellcheck="false" contenteditable="true">
This is the first line
<br>
This is the second line.
<br type="_moz">
</body>
I get this in my view when I process the POST request:
'This is the first line<br />\r\nThis is the second line.'
When I save this to the database and then reload the page, I get in the browser:
This is the first line
This is the second line.
Because the \r\n was read as another newline and now I have two line breaks. (See edit below)
Why the <br />? Also, why do I get a newline after the <br> element in the HTML? This causes me to get <br />\r\n in my model instance attributes and thus, in my database. The \r\n won't actually cause a problem (see edit below), but it would be easier if I get rid of it; I think <br> should suffice.
EDIT
Actually, having the \r\n does cause a problem. When I submit the form, I get, as I said, <br />\r\n in my database. Then, when I render this in the browser, I get two linebreaks (<br>) because it read the first <br /> and then the \r\n as another <br>. This happens because I am using the linebreaksbr template tag; my processing code outputs newlines in this way. It would be easier if I can get rid of the \r\n too, instead of changing my code.
I'm trying to read some values from the XML file which I created, but it gives me the following error:
coldfusion.runtime.UndefinedElementException: Element MYXML.UPLOAD is undefined in XMLDOC.
Here is my code
<cffile action="read" file="#expandPath("./config.xml")#" variable="configuration" />
<cfset xmldoc = XmlParse(configuration) />
<div class="row"><cfoutput>#xmldoc.myxml.upload-file.size#</cfoutput></div>
Here is my config.xml
<myxml>
<upload-file>
<size>15</size>
<accepted-format>pdf</accepted-format>
</upload-file>
</myxml>
Can someone help me to figure out what is the error?
When I am printing the entire variable as <div class="row"><cfoutput>#xmldoc#</cfoutput></div> it is showing the values as
15 pdf
The problem is the hyphen - contained in the <upload-file> name within your XML. If you are in control of the XML contents the easiest fix will be to not use hyphens in your field names. If you cannot control the XML contents then you will need to do more to get around this issue.
Ben Nadel has a pretty good blog article in the topic - Accessing XML Nodes Having Names That Contain Dashes In ColdFusion
From that article:
To get ColdFusion to see the dash as part of the node name, we have to "escape" it, for lack of a better term. To do so, we either have to use array notation and define the node name as a quoted string; or, we have to use xmlSearch() where we can deal directly with the underlying document object model.
He goes on to give examples. As he states in that article, you can either quote the node name to access the data. Like...
<div class="row">
<cfoutput>#xmldoc.myxml["upload-file"].size#</cfoutput>
</div>
Or you can use the xmlSearch() function to parse the data for you. Note that this will return an array of the data. Like...
<cfset xmlarray = xmlSearch(xmldoc,"/myxml/upload-file/")>
<div class="row">
<cfoutput>#xmlarray[1].size#</cfoutput>
</div>
Both of these examples will output 15.
I created a gist for you to see these examples as well.
Now I'm biulding a django project with jinja2 dealing with templates. Some page contents are submited by the client with wysiwy editor, and thing's going fine with the detail pages.
But the list pages are wrong with the slice of the contents.
My code:
<div class="summary ">
<div class="content">{{ question.content[:200]|e}}...</div>
</div>
But the output is:
<p>what i want to show here is raw text without markups</p>...
The expected result is that the html markups like <p></p> <section>.... are gone (filtered or eliminated) and only the raw text shows!
So how can I fix it? Thanks in advance!
Use striptags filter:
striptags(value)
Strip SGML/XML tags and replace adjacent whitespace
by one space.
<div class="content">{{ question.content|striptags}}...</div>
Jinja2 striptags filter test will also help you to understand how it works.
Hope that helps.
For example, the following markdown:
# Game Version
Need For Speed Most Wanted v1.3 English version.
Results in the following HTML:
<h1>Game Version</h1>
<p></p>
<p></p>
<p>Need For Speed Most Wanted v1.3 English version.</p>
<p></p>
<p></p>
This is even more annoying in lists where every <li></li> is <br><li></li><br>, contrary to the markdown spec. I have checked my markdown and there are no extra end-of-line spaces or anything of the sort. The data is stored as a text field on Heroku Postgres.
Is this a problem with Bluecloth, or am I doing something terribly wrong?
I was actually calling simple_format on the returned string in the view:
simple_format BlueCloth.new(#event.description)
Replacing simple_format with raw fixed the problem.
I'm building an app in Railo, which uses the jSoup .jar library. It all works really well in my CFML language.
Anyhow, I can grab every element with a "style" attribute doing:
<cfset variables.mySelection = variables.myDocument.select("*[style]") />
But this returns an array which contains elements that sometimes do not have a "background" or "background-image" style on them. As an example, the HTML might looks like so:
<p style="color: red;">I should not be selected</p>
<p style="background: green">I **should** be selected</p>
<p style="text-align: left;">I should not be selected</p>
<p style="background-image: url("/path/to/image.jpg");">I **should** be selected</p>
So I can get these elements above, but I don't want the 1st and 3rd in my array, as they don't have a background style...do you know how I can only grab and work with these?
Please note, I'm not after a COMPUTATED style, or anything that complicated, I'm just wondering if I can filter based on the properties of an inline CSS style. Perhaps some regex after the fact? I'm open to ideas!
I tried messing with :contains(background) as a key word, but I wasn't sure if that was the correct path?
Many thanks for your help.
Michael.
Try with:
variables.myDocument.select("*[style*='background']")
As *= is the standard selector to match a substring in the attribute content.
Elements els = doc.select(div[style*=dashed]);
Or
Elements elements = doc1.select("span[style*=font-weight:bold]");