Postprocessing for files before CHM assembly

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
AZJIO
Addict
Addict
Posts: 2143
Joined: Sun May 14, 2017 1:48 am

Postprocessing for files before CHM assembly

Post by AZJIO »

Is there a way to add the execution of a file (*.exe) before building CHM? One could write code that imports the function references in the examples. You can import html code that will add a "Copy example" button. You can import html code which will add support for external css file and you can change background color, font etc.

html

Code: Select all

<script language="javascript" src="../external.js" type="text/javascript"></script>
external.js

Code: Select all

/* Insert stylesheet in HTML if source is a compiled CHM file */

function fnInsertExternalStyleSheet(filename) {
	var path = unescape(location.pathname);
	var i = path.lastIndexOf("\\"), j = 0, doc_type = "";
	if( path.indexOf("::") != -1 ) { // it is a CHM file
		doc_type = "CHM";
		if( path.charAt(0) == "@" ) { // this is a @MSITStore: .. chop this off
			j = path.indexOf(":") + 1;
		} // else this is an ms-its: .. path starts at the beginning of string
	}
	path = path.substring(j, i+1);
	if (doc_type == "CHM") {
		document.writeln("<link rel=\"stylesheet\" href=\"file://" + path + filename + "\" type=\"text/css\">");
		//alert("This is a CHM file\n<link rel=\"stylesheet\" href=\"file://" + path + filename + "\" type=\"text/css\">");
	}
}

/* Set e.g. filename.css as parameter to use as a external CSS file */
fnInsertExternalStyleSheet("style.css")
html

Code: Select all

<a href="javascript:ClipBoard(copytext);"><IMG NAME="botton" title="Copy to clipboard" style='margin: 5px 4px 4px 10px;' src='../images/copy.gif'" border="0" align='right'></a><p id="copytext" class="codebox">
copy.js

Code: Select all

function ClipBoard(NumBlok) {
	var input = document.createElement('textarea');
	if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) // IE (4+) only
		input.innerText = NumBlok.innerText;
	else
		input.innerHTML = NumBlok.innerText;
	document.body.appendChild(input);
	input.select();
	document.execCommand('copy');
	document.body.removeChild(input);
}
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2137
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Re: Postprocessing for files before CHM assembly

Post by Andre »

This sounds like an extension of the existing PB DocMaker tool would be needed...

So this request is up for Fred (or making the PB DocMaker ready for PB community, like the PB IDE) 8)
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
Post Reply