There is showdown.js to convert markdown to HTML, and PHP Markdown to convert markdown to and from HTML. My question is, is there javascript library to convert HTML to markdown?
In the intent of preventing XSS attacks, I am updating a page in which we have a textbox that accepts HTML, stores it in a database and retrieves and renders it at a later time.
My understanding is that I can sanitize the HTML using AntiXSS.GetSafeHtmlFragment() method. As long as I do this before storing the HTML in the database, am I covered? Do I need to do anything when the HTML is outputted on a web page?
Also, it appears that the white list is kind of a black box. Is there a way to update this based on our requirements?
Hi, I would like to render specific HTML snippets for displaying banners, because each banner has a different nature (some images, some flash, etc). Every banner file is under app/public/banners/. I tried many ways, like:
render :file => "/banners/somebanner.html"
But it can't locate the file, because Rails looks under app/views. Any ideas ? Thanks!
Missing template banners/somebanner.html in view path app/views
I have my IIS 6 server setup to process server side includes, we're also using the WebLogic ISAPI plugin for IIS.
I have a simple html file that I'm trying to include in the JSP using the following include:
<!-- #include file="/pleaseWait/pleaseWait.html" -->
When I use the above line in a JSP I get an error message saying: "pleaseWait is not defined". From an HTML file on the web server it works fine.
The include works in the HTML whether I use file or virtual. I can't use the jsp @ include because that's resolved at build time and the HTML file does not exist in the Java project. It's static content so it's on the IIS server.
In the past we've change the extension to .jsp and included the images and static content in the .war file....the problem with that is we now have 10 different versions of this code in our apps and not all of them look or function the same. This is an attempt to standardize and centralize the code for this feature across our apps.
Any ideas or suggestions?
I have a element and I want to change the color of the links within it, but all other links on my page are styled using the following CSS:
a:link {
color:#22b14c;
text-decoration:none;
}
and here is the nav:
<nav id="Nav">
<a href="index.html">Home</a> |
<a href="Gallery.html">Library</a> |
<a href="Contact.html">Contact</a> |
<a href="About.html">About</a>
</nav>
and the nav css:
#Nav {
margin-top: 20px;
background-color: #000000;
color: #f2f2f2;
font-size: 40px;
font-family: "Calibri";
text-align: center;
}
I tried a span inside the nav element but that didn't work. How can I change the color for these links only inside the element?
I've been trying to make this cross browser (specifically IE), but I do not want to use tables. I will not be able to specify the container width with CSS because its contents (the image) will dynamically change with Javascript, so I need the container to 'auto-size' horizontally.
The desired effect would be a centered image with two sets of text (one of the left and one of the left) directly underneath the image, aligned to it's inner edges.
Example (Doesn't work on IE): http://pastehtml.com/view/19pbyw9.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#container { display:table; }
</style>
</head>
<body>
<center>
<div id="container">
<img src="http://www.google.com/intl/en_ALL/images/srpr/logo1w.png" alt="" /><br />
<span style="float: left;">test</span>
<span style="float: right; text-align: right;">test2</span>
</div>
</center>
</body>
</html>
I'm extracting XML node from an XElement. When I use XElement.Value it strips any HTML that may be in the node.
I know that if I do XElement.ToString() I can keep the HTML, but it also gives me the node tags. Is there any way to extract the content of a Node as is without the HTML being stripped out?
Cheers.
Hi guys
I'm using matplotlib at the moment to try and visualise some data I am working on. I'm trying to plot around 6500 points and the line y = x on the same graph but am having some trouble in doing so. I can only seem to get the points to render and not the line itself. I know matplotlib doesn't plot equations as such rather just a set of points so I'm trying to use and identical set of points for x and y co-ordinates to produce the line.
The following is my code
from matplotlib import pyplot
import numpy
from pymongo import *
class Store(object):
"""docstring for Store"""
def __init__(self):
super(Store, self).__init__()
c = Connection()
ucd = c.ucd
self.tweets = ucd.tweets
def fetch(self):
x = []
y = []
for t in self.tweets.find():
x.append(t['positive'])
y.append(t['negative'])
return [x,y]
if __name__ == '__main__':
c = Store()
array = c.fetch()
t = numpy.arange(0., 0.03, 1)
pyplot.plot(array[0], array[1], 'ro', t, t, 'b--')
pyplot.show()
Any suggestions would be appreciated,
Patrick
I have the following html:
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<span>not so important</span>
<span title="some specific text"><img src="/img/some.gif" /></span>
<span title="more specific text">important 1</span>
<span title="more specific text">important 2</span>
<span title="more specific text">important 3</span>
<span title="more specific text"><img src="/img/some.gif" /></span>
<ul>
<li>example 1</li>
<li>example 2</li>
<li>example 3</li>
<ul>
<script>
var ul = $('body').append($('<ul>'));
$("span[title*='specific text']")
.contents()
.filter(function(){ return $(this).nodeType != 1; })
.each(function(){
ul.append($('<li>' + $(this).text() + '</li>'));
})
</script>
</body>
</html>
I want to retrieve the text within a 'span' whose title attribute contains "specific text", in this case "important 1", "important 2" and "important 3". Then I want to list them below just like the example. However the bullets do not appear, why is that? Any hints would be appreciated!
Hi, what's wrong with this code?
The background disappears behind the divs when I add float: left to #text and #text2. But when I remove the float: left, everything looks good.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style type="text/css">
#first{
width: 200px;
background-color: #345752;
}
#left_b{
background:transparent url('img/left.png');
background-position: left top;
background-repeat: repeat-y;
min-height: 30px;
}
#right_b{
background:transparent url('img/right.png');
background-position: right top;
background-repeat: repeat-y;
}
#text{
float: left;
width: 50px;
height: 30px;
}
#text2{
float: left;
width: 70px;
height: 30px;
}
</style>
</head>
<body>
<div id = "first">
<div id = "left_b">
<div id = "right_b">
<div id = "text">text 1</div>
<div id = "text2">text 2</div>
</div>
</div>
</div>
</body>
</html>
I have a series of points which I will turn into a line on a graph. What I want is to give the area under the graph a gradient fill. It would look somewhat similar to a Bloomberg graph like this;
My question really has three parts;
First, how should I fill only the area under the graph?
Second, how do I fill that with a gradient?
Finally, if I have multiple lines on the same graph any area under more than one line should have a greyscale gradient fill, how would you set this up?
My biggest problem is deciding on the data structures to use, I could use many multiple sided shapes (One for each line/ data series) and then tell the brush to draw;
Transparent if it's not in any shape
The colour of one series if it's in one shape (Alpha relative to height to give grad)
Black if it's in multiple shapes (Alpha relative to height to give grad)
Then I'd draw the shapes' boundaries in white afterwards.
Thanks,
Gav
I am taking an XML document and creating a word document using XSLT and OpenXML. The problem is that when I create the word document, all of the HTML that is within the CDATA tags are not escaped and look like this:
GET /recipe/recipe/cat.php/>"><script>alert(document.domain)</script>
I have tried defining "cdata-section-elements" in my xsl:output; however I receive an error stating that p tag doesn't match the w:t tag.(the p tag is apart of the CDATA HTML).
Here is what one of my xsl templates looks like:
<xsl:template match="SECTION">
<w:p w:rsidR="00272D24" w:rsidRPr="00272D24" w:rsidRDefault="00272D24">
<w:pPr>
<w:rPr>
<w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
</w:rPr>
</w:pPr>
</xsl:template>
<w:r w:rsidRPr="00272D24">
<w:rPr>
<w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
</w:rPr>
<w:t>
<xsl:value-of select="INFORMATION"/>
</w:t>
</w:r>
</w:p>
Here is what the xml looks like:
<INFORMATION>
<![CDATA[
<P> line 1 of information
<P> line 2 of information.......]]>
</INFORMATION>
Here is what the word output looks like: (white space and poor formatting)
DIAGNOSIS:
<P> line 1 of information. <P> line 2 of information
I need to be able to somehow render the HTML or strip out the HTML. If I strip out the HTML then I would have to search for every possible HTML element, which is madness! Any help at all would be appreciated...
Thanks.
I have an issue where Internet Explorer is generating an additional br element that is not in my source. The additional br effects the page's layout and is visible when using the developer tool. I've tried removing all hard returns between the surrounding elements but the additional br persists. Firefox and Chrome do not have this issue. Ideas on what I can do to fix the issue?
Instead of
First line.
Second line.
I get
First line
Second line.
Code Example
<asp:ImageButton ID="RemoveItem" AlternateText="Remove Item"
ImageUrl="~/img/buttons/remove.png" runat="server" CssClass="remove"
CommandName="Remove" OnCommand="RemoveCartItem_Command" />
<br runat="server" id="TotalBreak" />
Hello!
I have this html code:
<table>
<tr>
<td class="test"><b><a href="">aaa</a></b></td>
<td class="test">bbb</td>
<td class="test">ccc</td>
<td class="test"><small>ddd</small></td>
</tr>
<tr>
<td class="test"><b><a href="">eee</a></b></td>
<td class="test">fff</td>
<td class="test">ggg</td>
<td class="test"><small>hhh</small></td>
</tr>
</table>
I use this Python code to extract all <td class="test"> with lxml module.
import urllib2
import lxml.html
code = urllib.urlopen("http://www.example.com/page.html").read()
html = lxml.html.fromstring(code)
result = html.xpath('//td[@class="test"][position() = 1 or position() = 4]')
It works good! The result is:
<td class="test"><b><a href="">aaa</a></b></td>
<td class="test"><small>ddd</small></td>
<td class="test"><b><a href="">eee</a></b></td>
<td class="test"><small>hhh</small></td>
(so the first and the fourth column of each <tr>)
Now, I have to extract:
aaa (the title of the link)
ddd (text between <small> tag)
eee (the title of the link)
hhh (text between <small> tag)
How could I extract these values?
(the problem is that I have to remove <b> tag and get the title of the anchor on the first column and remove <small> tag on the forth column)
Thank you!
Wanted
A command line HTML5 beautifier running under Linux.
Input
Garbled, ugly HTML5 code. Possibly the result of multiple templates. You don't love it, it doesn't love you.
Output
Pure beauty. The code is nicely indented, has enough line breaks, cares for it's whitespace. Rather than viewing it in a webbrowser, you would like to display the code on your website directly.
Suspects
tidy does too much (heck, it alters my doctype!), and it doesn't work well with HTML5. Maybe there is a way to make it cooperate and not alter anything?
vim does too little. It only indents. I want the program to add and remove line breaks, and to play with the whitespace inside of tags.
DEAD OR ALIVE!
add({
title: args.node.id,
iconCls: 'tabs',
items: [{html: '<code class="prettyprint"><?php\necho \'Hello World!\';</code>', width: '100%', hieght: '100%', plain: true}],
closable: true
}).show();
I am running the above method on Ext.TabPanel and it is returning '' as the html...
If I do
<code class="prettyprint"><html><head><title>Whatever</title></head><body.The body!</body></html></code>
It just renders The body!... how can I get it to display the source code??
Many thanks...
def mailTo(subject,msg,folks)
begin
Net::SMTP.start('localhost', 25) do |smtp|
smtp.send_message "MIME-Version: 1.0\nContent-type: text/html\nSubject: #{subject}\n#{msg}\n#{DateTime.now}\n", '[email protected]', folks
end
rescue => e
puts "Emailing Sending Error - #{e}"
end
end
when the HTML is VERY large I get this exception
Emailing Sending Error - 552 5.6.0 Headers too large (32768 max)
how can i get a larger html above max to work with Net::SMTP in Ruby
I have a encrypted sqlite db and its key. (Which is generated by an android program).
However, when I open the db in command line I can not read the db.
The command line tool is installed by:
brew install sqlcipher
I open the database by:
sqlcipher EnDB.db
>pragma key="6b74fcd";
>select * from bizinfo;
It keeps telling me "Error: file is encrypted or is not a database"
However, if I open the database file with gui app sqlite database browser (which is a windows program and I run it in wine). It pops up a window for me to enter the key, with 6b74fcd as the key it successfully read the database.
As I want to automatically process the db in the future, I can not depend on the GUI.
Do you know why the command line is not working?
When I see website starter code and examples, the CSS is always in a separate file, named something like "main.css", "default.css", or "Site.css". However, when I'm coding up a page, I'm often tempted to throw the CSS in-line with a DOM element, such as by setting "float: right" on an image. I get the feeling that this is "bad coding", since it's so rarely done in examples.
I understand that if the style will be applied to multiple objects, it's wise to follow "Don't Repeat Yourself" (DRY) and assign it to a CSS class to be referenced by each element. However, if I won't be repeating the CSS on another element, why not in-line the CSS as I write the HTML?
The question: Is using in-line CSS considered bad, even if it will only be used on that element? If so, why?
Example (is this bad?):
<img src="myimage.gif" style="float:right" />
When I write a comment, it's often a paragraph or a few lines that explains clearly what a bit of code is doing and why it's doing that.
What I'd like is if I could start a comment, and have the editor automatically insert a line break and continue the comment to the nest line when I reach, say, 80 characters long.
So I'd type:
// Lorem ipsum dolor sit amet, consectetur adipiscing elit. < here the editor breaks automatically and continues onto the next line:
// Etiam congue quam eget leo dignissim tincidunt.
Is there a clean way to have your fabfile take command line arguments? I'm writing an installation script for a tool that I want to be able to specify an optional target directory via the command line.
I wrote some code to test what would happen if I passed in some command line arguments:
# fabfile.py
import sys
def install():
_get_options()
def _get_options():
print repr(sys.argv[1:])
A couple of runs:
$ fab install
['install']
Done.
$ fab install --electric-boogaloo
Usage: fab [options] <command>[:arg1,arg2=val2,host=foo,hosts='h1;h2',...] ...
fab: error: no such option: --electric-boogaloo
Hi,
I wonder if the following things can be done with the HTML notes pane of freemind:
1- is it possible on the layout view to decrease the separation between lines?
2- the panel is horizontal, is it possible to setup a vertical view? (I have a big, horizontal-like monitor)
By the way, when I move the mouse pointer over a node, i can see the HTLM note associated with it, but its view (as a yellow square) only lasts for some seconds. Can it be made permament?
Thanks a lot