Jump to content

XML in HTML - strange lineheight


mike_g
 Share

Recommended Posts

Hi, I'm making a syntax highlighter. It can output to html, which creates quite a bit of bloat. To reduce the file size I am having a go at using XML. I'm not sure if i'm doing this right; havent really used xml before, but FF seems to display the content alright except for one thing. The line height seems to be too big for some reason. Heres a test page showing what I mean:

<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html>	<head>		<style type="text/css">			code_x{font-family:courier new, sans;font-size:10px;white-space:pre;line-height:0;}			dft{color: #888888;font-weight: normal;}			kwd{color: #000000;font-weight: bold;}			nbr{color: #00FF00;font-weight: normal;}		</style>	</head>	<body>		<code_x>		<kwd>int </kwd><dft>main()		{			</dft><kwd>return</kwd><nbr> 0</nbr><dft>;		}</dft>			</code_x>	</body></html>

Could someone please explain what I am doing wrong, or how to fix this?Cheers.

Link to comment
Share on other sites

Umm why are you using the XHTML DTD when your document obviously isn't XHTML? You'll need to create your own.Anyway, the line-height (without that line-height:0 property) seems fine, but there is a double line break after the opening brace - is that what you meant?

Link to comment
Share on other sites

there is a double line break after the opening brace - is that what you meant?
No. every line had a big gap below it.
Umm why are you using the XHTML DTD when your document obviously isn't XHTML? You'll need to create your own.
Yeah removing the doctype sorted out the line spacing problem. IDK why I put it there; just ripped the top two lines from some other site since i never know what to put as the doctype and stuff. Cheers.
Link to comment
Share on other sites

i never know what to put as the doctype and stuff.
If you learn how to make a DTD (e.g. through the W3School's DTD tutorial), you can make one that describes your new syntax-highlighting language.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...