Monday, November 08, 2010 at 12:03 AM.
system.verbs.builtins.html.data.processMacrosCallback
on dosc (s) { <<runs a macro, for the html suite
local (adrPageTable = html.getPageTableAddress ());
if html.getPref ("processMacros", adrPageTable) { <<new pref in 4.1
local (toolTableAdr, nilTable);
if defined (adrPageTable^.tools) {
toolTableAdr = adrPageTable^.tools}
else { <<'with' wants a table
new (tableType, @nilTable);
toolTableAdr = @nilTable};
try {
local (macroResult);
with adrPageTable^, html.data.standardMacros, user.html.macros, toolTableAdr^ {
macroResult = string (evaluate (s))};
if (macroResult beginsWith '"') and (macroResult endsWith '"') {
if html.getPref ("expandGlossaryItems", adrPageTable) {
macroResult = string.mid (macroResult, 2, sizeOf (macroResult) - 2);
macroResult = html.refGlossary (macroResult)}};
return (macroResult)}
else {
local (errorString = html.cleanForExport (tryError, adrPageTable));
if html.getPref ("logMacroErrors", adrPageTable) {
local (adroutline = @user.html.macroErrors);
if not defined (adroutline^) {
new (outlineType, adroutline)};
local (oldtarget = target.get ());
edit (adroutline);
target.set (adroutline);
op.firstSummit ();
local (adr = adrPageTable^.adrObject);
local (linetext = op.getLineText ());
local (message = "Error rendering \"" + adr + "\" at " + string.timeString ());
if linetext == "" {
op.setLineText (message)}
else {
op.insert (message, up)};
op.insert (errorString, right);
op.insert ("Macro string: {" + s + "}", down); // PBS: add the macro string
try {target.set (oldtarget)}};
scriptError (errorString)}}
else {
return ("{" + s + "}")}};
on refg (name) { <<turn a glossary entry name into a string for insertion into HTML text
local (adrPageTable = html.getPageTableAddress ());
if html.getPref ("expandGlossaryItems", adrPageTable) {
return (html.refGlossary (name))}
else {
scriptError ("glossary expansion off")}} <<tell macroprocessor to ignore
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.