Forum Feature requests

PrinceXML TextMate e-Texteditor bundle ?

laurentsj
Could we please have a bundle allowing us to use PrinceXML as our main word-processor ? with Textmate and e-Texteditor ?

You could provide all of your examples's styling, plus the ability to edit our owns.


You might have seen Oliver Taylor's TM Screenwriting.
<a>http://ollieman.net/screenbundle/</a>

inside his bundle, there is a nifty command "export to PrinceXML"

Couldn't we have a "princeXML" TM bundle ?, with several similar commands containning different templates, so you can use TM as your main word processor.

Ben Johnson has also mentioned Textmate with PrinceXML, but i got confused following his workflow.
<a>http://www.unfitforprint.com/articles/2005/12/23/markdown2pdf-with-prince-xml-and-textmate</a>
mikeday
This sounds like a great idea, but we don't have much experience with TextMate ourselves. Are there any knowledgeable TextMate users out there who could put something like this together? We could provide assistance if there are any technical difficulties on the Prince side of things
laurentsj
Well, real nice of you to offer some help.
Let's think of one example; This snippets output one of the Textmate Bundle called "http://ollieman.net/screenbundle/" straight to PrinceXml pdf.

Any chance you could replace the css so that it fits a correspondence letter, with letterhead, footer, etc ?

# first figure out a name for the result
NAME="${TM_FILENAME:-untitled}"
BASENAME="${NAME%.*}"
DST="/tmp/$BASENAME"

# everything we output within { … } is written to the HTML file via redirection (see line with the })
{
# first output HTML header
cat <<HEAD
<DOCTYPE>
<html>
<head>
	<meta>
	<title>$BASENAME</title>
	<style>

	/* ---------- PRINTED STYLES ---------- */
	
		/* all page margins are maximum */
		@page {
			size: 8.5in 11in;
			margin-top:${SPLAY_PAGE_TOP:-1in};
			margin-right:${SPLAY_PAGE_RIGHT:-1in};
			margin-bottom:${SPLAY_PAGE_BOTTOM:-.5in};
			margin-left:${SPLAY_PAGE_LEFT:-1.5in};
		}
		/* This makes the page-counter start on the first page of the screenplay (vs. the prince demo-page) */
		div#screenplay {
			counter-reset: page 1;
			page: screenplay;
		}
		@page screenplay {
			/* Page Numbers */
			@top-right-corner {
				font: 12pt 'courier';
				content: counter(page)'.';
				vertical-align: bottom;
				padding-bottom: 1em;
			}
			/* Define Header */
			@top-left { 
				content: '$SPLAY_HEADER';
				font: italic 10pt Georgia;
				color: #888;
				vertical-align: bottom;
				padding-bottom: 1.3em;
			}
			/* Define Footer */
			@bottom-left { 
				content: '$SPLAY_FOOTER';
				font: italic 10pt Georgia;
				color: #888;
				vertical-align:top;
				padding-top:0;
			}
		}
		/* removes the header and page-numbers from the first page */
		@page screenplay:first {
			@top-right-corner { content: normal; }
			@top-left { content: normal; }
		}
		p {
			orphans: 2;
			widows: 2;
		}
		dl {
			page-break-inside:avoid;
		}
		dt, h2 {
			page-break-after: avoid;
		}
		dd.parenthetical {
			orphans: 3;
			widows: 3;
			page-break-before: avoid;
			page-break-after: avoid;
		}
		h3, h4, h5, h6 {
			prince-bookmark-level: none;
		}
		div.page-break {
			page-break-after:always;
		}
		
		

		/* ---------- COMMON LAYOUT ---------- */
		
		
		
		body {
			font-family: 'Courier', monospace;
			font-size: 12pt;
			line-height: ${SPLAY_LINEHEIGHT:-12.4pt};
		}
		#screenplay {
			width: 6in;
			margin:0 auto;
		}
		p.center {
			text-align:center;
			margin-left:0;
			width:100%;
		}
		p {
			margin-top:12pt;
			margin-bottom:12pt;
			margin-left:${SPLAY_ACT_INDENT:-0};
			width:${SPLAY_ACT_WIDTH:-auto};
		}
		/* characters */
		dt {
			font-weight:normal;
			margin-top:1em;
			margin-left:${SPLAY_CHAR_INDENT:-2in};
			width:${SPLAY_CHAR_WIDTH:-4in};
		}
		dd.parenthetical {
			margin-left:${SPLAY_PAR_INDENT:-1.6in};
			text-indent:-.1in;
			width: ${SPLAY_PAR_WIDTH:-2in};
		}
		dd {
			margin:0;
			margin-left: ${SPLAY_DIAL_INDENT:-1in};
			width: ${SPLAY_DIAL_WIDTH:-3.5in};
			line-height: ${SPLAY_DIAL_LINEHEIGHT:-inherit};
		}
		h1,h2,h3,h4,h5,h6 {
			font-weight: normal;
			font-size: 12pt;
			margin-top: 1em;
			text-transform:uppercase;
		}
		h2 {
			width: ${SPLAY_SLUG_WIDTH:-inherit};
			margin-top: ${SPLAY_SLUG_TOP_MARGIN:-24pt};
			margin-bottom: ${SPLAY_SLUG_BOTTOM_MARGIN:-12pt};
			margin-left: ${SPLAY_SLUG_INDENT:-0};
			font-weight: ${SPLAY_SLUG_BOLD:-normal};
			text-decoration:${SPLAY_SLUG_ULINE:-none};
		}
		h3 {
			margin-left: ${SPLAY_TRANS_INDENT:-4in};
			width: ${SPLAY_TRANS_WIDTH:-2in};
			margin-top: ${SPLAY_TRANS_TOP_MARGIN:-12pt};
			margin-bottom: ${SPLAY_TRANS_BOTTOM_MARGIN:-12pt};
		}
		h4 {
			margin-top: ${SPLAY_TRANS_TOP_MARGIN:-12pt};
			margin-bottom: ${SPLAY_TRANS_BOTTOM_MARGIN:-12pt};
		}
		span.underline {
			text-decoration:underline;
		}
	</style>
</head>
<body>

<div>
HEAD
# then HTML body (converted from document)
perl -0777 -pe '

# escape ampersands
s/&/&amp;/g;

# Comments
s/\/\*/</g>/g;

# Underline
s/\B\*(\S[^\*\n]+\S)\*\B/<u>$1</u>/g;

# Page Breaks
s/={50}/<div></div>/mg;

# Left-transitions
s/^(\w+(?:\s\w+)?\s(?i:to|up|in|out|black)(?i:\son)?([\.\:][ ]*)?$)/<h4>$1</h4>/mg;

# well-formed sluglines
s/^(EXT|INT|I\/E|int|ext|i\/e)\.?\s.*/<h2>$&</h2>/mg;

# Arbitary Sluglines
s/^[^a-z\t\<\n]+$/<h2>$&</h2>/mg;

# Right Transitions
s/^(\t{10})([^\t].*)$/<h3>$2</h3>/mg;

# Centered Text
s/^(\t{5})([^\t\n].*)$/<p>$2</p>/mg;

# Centered Text Line Breaks
s/</p>(\n\t{5})<p>(.*)/<br>$1$2/mg;

# Characters
s/^\t{4}([^\t\n][^\n]*)$/<dl><dt>$1</dt>/mg;

# Parenthetical
s/(^\t{3})(\(.*\))[ \t]*$/<dd>$2</dd>/mg;

# Dialogue
s/^(\t{2})([^\t\n][^\n]*)$/<dd>$2</dd></dl>/mg;

# Clean Dialogue followed by Parenthetical
s/(</dd>)</dl>(\n<dd)/$1$2/mg;

# Clean up Dialogue that ends in a parenthetical
s/</dd>[ \t]*\n([^<][^d])/</dd></dl>\n$1/mg;

# Action Paragraphs
s/^([^\n\t\< ].*)\n/<p>$1</p>\n/mg;

# Line-Breaks
s/</p>\n<p>/<br>\n/mg;

# Empty Line Breaks
s/^[ ]{3}/<br>/mg;

'

# and finally HTML footer
cat <<'TAIL'

</div><end>
</body>
</html>
TAIL
} >"$DST.html"

# process the file via prince
/Users/lolo/lib/prince/bin/prince "$DST.html" ~/Desktop/"$BASENAME".pdf

# Display a message
cat <<DONE
<div><h1>DONE</h1><p>If there is no error message above this, the file should be on your <b>desktop</b>.</p></div>
DONE