0

Pretty code viewer

asked 2012-05-02 15:13:21 +0800

chantspel gravatar image chantspel
12

updated 2012-05-02 15:16:23 +0800

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!

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2012-05-04 15:39:44 +0800

chantspel gravatar image chantspel
12

No one knows how to do this? I guess I could try using some client side script but I'm surprised ZK doesn't let you do it.

link publish delete flag offensive edit

answered 2012-06-13 18:13:33 +0800

chantspel gravatar image chantspel
12

bump

link publish delete flag offensive edit

answered 2012-06-14 05:11:38 +0800

benbai gravatar image benbai
2228 6
http://www.zkoss.org

updated 2012-06-14 05:12:19 +0800

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

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2012-05-02 15:13:21 +0800

Seen: 221 times

Last updated: Jun 14 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More