-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
I'm trying to figure out a way to display some HTML code in a textbox that will be formatted correctly. Is there any component in ZK that will do this?
For example, look at any of the ZK demos and you will see they have a tab to view source. The code is pretty printed in the tab panel.
Thanks!
Hi chantspel,
There are already a lot of code brushs, for example, you can try use http://alexgorbatchev.com/SyntaxHighlighter/ in zul file as below
<zk:zk xmlns:zul="zul" xmlns:zk="zk" xmlns="xhtml"> <zul:window title="test" border="normal"> <zul:html> <!-- Include required JS files --> <script type="text/javascript" src="js/shCore.js"></script> <!-- At least one brush, here we choose JS. You need to include a brush for every language you want to highlight --> <script type="text/javascript" src="js/shBrushXml.js"></script> <!-- Include *at least* the core style and default theme --> <link href="css/shCore.css" rel="stylesheet" type="text/css" /> <link href="css/shThemeDefault.css" rel="stylesheet" type="text/css" /> <!-- You also need to add some content to highlight, but that is covered elsewhere. --> <pre class="brush: xml"> <zk> <zscript> void test() { System.out.println(" test "); } </zscript> <button label="test" ></button> </zk> </pre> <!-- Finally, to actually run the highlighter, you need to include this JS on your page --> <script type="text/javascript"> SyntaxHighlighter.all() </script> </zul:html> </zul:window> </zk:zk>
Regards,
Ben
Asked: 2012-05-02 15:13:21 +0800
Seen: 221 times
Last updated: Jun 14 '12