In an attempt to simplify the process of formatting my reports, I am considering creating a basic XML language. This would resemble something like this:
<?xml-stylesheet href="./report.css"?>
<report>
<title>A Tale of Two Cities</title>
<author>Charles Dickens</author>
<code>
int main (int argc, char **argv)
{
int x = 5;
}
</code>
</report>
The accompanying stylesheet, titled report.css
, might contain rules such as:
title {
font-family: serif;
background: white;
color: #003
}
author {
font-size: large;
margin: 1em 0
}
code {
font-style: italic
}
A challenge arises when attempting to preserve whitespace within certain tags, like code
. While HTML offers the <pre>
tag for this purpose, XML lacks a direct equivalent. Despite trying
<code xml:space="preserve">
, the browser still strips out the whitespace upon rendering due to it not being recognized as a text-only node. Is there a solution to ensure proper display in browsers (for subsequent PDF printing), or should I consider switching to LaTeX for producing aesthetically pleasing reports?