aboutsummaryrefslogtreecommitdiff
path: root/src/interp
diff options
context:
space:
mode:
authoralfredoport <doyenatccny@gmail.com>2008-03-16 20:08:29 +0000
committeralfredoport <doyenatccny@gmail.com>2008-03-16 20:08:29 +0000
commitd9b9f67266bcb24e7bec1a26afaf062b376d450e (patch)
treeeacaab35984aba4428bb306858974bcebed48ff0 /src/interp
parent64a98e2f75407a020ed217227ad0e6e6a3730800 (diff)
downloadopen-axiom-d9b9f67266bcb24e7bec1a26afaf062b376d450e.tar.gz
Add support for MathML output
Diffstat (limited to 'src/interp')
-rw-r--r--src/interp/i-output.boot12
-rw-r--r--src/interp/setvars.boot109
-rw-r--r--src/interp/setvart.boot51
3 files changed, 171 insertions, 1 deletions
diff --git a/src/interp/i-output.boot b/src/interp/i-output.boot
index f08cf82f..2f45ce54 100644
--- a/src/interp/i-output.boot
+++ b/src/interp/i-output.boot
@@ -1377,11 +1377,22 @@ texFormat1 expr ==
FORCE_-OUTPUT $texOutputStream
NIL
+mathmlFormat expr ==
+ mml := '(MathMLFormat)
+ mmlrep := '(String)
+ formatFn := getFunctionFromDomain("coerce",mml,[$OutputForm])
+ displayFn := getFunctionFromDomain("display",mml,[mmlrep])
+ SPADCALL(SPADCALL(expr,formatFn),displayFn)
+ TERPRI $mathmlOutputStream
+ FORCE_-OUTPUT $mathmlOutputStream
+ NIL
+
output(expr,domain) ==
if isWrapped expr then expr := unwrap expr
isMapExpr expr =>
if $formulaFormat then formulaFormat expr
if $texFormat then texFormat expr
+ if $mathmlFormat then mathmlFormat expr
if $algebraFormat then mathprintWithNumber expr
categoryForm? domain or domain in '((Mode) (Domain) (Type)) =>
if $algebraFormat then
@@ -1398,6 +1409,7 @@ output(expr,domain) ==
if $algebraFormat then
mathprintWithNumber x
if $texFormat then texFormat x
+ if $mathmlFormat then mathmlFormat x
(FUNCTIONP(opOf domain)) and
(printfun := compiledLookup("<<",'(TextWriter TextWriter $), evalDomain domain))
and (textwrit := compiledLookup("print", '($), TextWriter())) =>
diff --git a/src/interp/setvars.boot b/src/interp/setvars.boot
index c32d85d9..f0836086 100644
--- a/src/interp/setvars.boot
+++ b/src/interp/setvars.boot
@@ -1238,6 +1238,115 @@ describeSetOutputFortran() ==
'"The current setting is: ",'%b,setOutputFortran "%display%",'%d)
+-- See the section mathml in setvart.boot.pamphlet
+--
+-- ----------------------- The mathml Option ------------------------
+--
+-- Description: create output in MathML style
+--
+-- )set output mathml is used to tell AXIOM to turn MathML-style output
+-- printing on and off, and where to place the output. By default,
+-- the destination for the output is the screen but printing is
+-- turned off.
+--
+-- Syntax: )set output mathml <arg>
+-- where arg can be one of
+-- on turn MathML printing on
+-- off turn MathML printing off (default state)
+-- console send MathML output to screen (default state)
+-- fp<.fe> send MathML output to file with file prefix fp
+-- and file extension .fe. If not given,
+-- .fe defaults to .stex.
+--
+-- If you wish to send the output to a file, you must issue
+-- this command twice: once with on and once with the file name.
+-- For example, to send MathML output to the file polymer.stex,
+-- issue the two commands
+--
+-- )set output mathml on
+-- )set output mathml polymer
+--
+-- The output is placed in the directory from which you invoked
+-- OpenAxiom or the one you set with the )cd system command.
+-- The current setting is: Off:CONSOLE
+
+setOutputMathml arg ==
+
+ arg = "%initialize%" =>
+ $mathmlOutputStream :=
+ DEFIOSTREAM('((MODE . OUTPUT) (DEVICE . CONSOLE)),255,0)
+ $mathmlOutputFile := '"CONSOLE"
+ $mathmlFormat := NIL
+
+ arg = "%display%" =>
+ if $mathmlFormat then label := '"On:" else label := '"Off:"
+ STRCONC(label,$mathmlOutputFile)
+
+ (null arg) or (arg = "%describe%") or (first arg = '_?) =>
+ describeSetOutputMathml()
+
+ -- try to figure out what the argument is
+
+ if arg is [fn] and
+ fn in '(Y N YE YES NO O ON OF OFF CONSOLE y n ye yes no o on of off console)
+ then 'ok
+ else arg := [fn,'smml]
+
+ arg is [fn] =>
+ UPCASE(fn) in '(Y N YE O OF) =>
+ sayKeyedMsg("S2IV0002",'(MathML mathml))
+ UPCASE(fn) in '(NO OFF) => $mathmlFormat := NIL
+ UPCASE(fn) in '(YES ON) => $mathmlFormat := true
+ UPCASE(fn) = 'CONSOLE =>
+ SHUT $mathmlOutputStream
+ $mathmlOutputStream :=
+ DEFIOSTREAM('((MODE . OUTPUT) (DEVICE . CONSOLE)),255,0)
+ $mathmlOutputFile := '"CONSOLE"
+
+ (arg is [fn,ft]) or (arg is [fn,ft,fm]) => -- aha, a file
+ if (ptype := pathnameType fn) then
+ fn := STRCONC(pathnameDirectory fn,pathnameName fn)
+ ft := ptype
+ if null fm then fm := 'A
+ filename := $FILEP(fn,ft,fm)
+ null filename =>
+ sayKeyedMsg("S2IV0003",[fn,ft,fm])
+ (testStream := MAKE_-OUTSTREAM(filename,255,0)) =>
+ SHUT $mathmlOutputStream
+ $mathmlOutputStream := testStream
+ $mathmlOutputFile := object2String filename
+ sayKeyedMsg("S2IV0004",['"MathML",$mathmlOutputFile])
+ sayKeyedMsg("S2IV0003",[fn,ft,fm])
+
+ sayKeyedMsg("S2IV0005",NIL)
+ describeSetOutputMathml()
+
+describeSetOutputMathml() ==
+ sayBrightly LIST ('%b,'")set output mathml",'%d,_
+ '"is used to tell AXIOM to turn MathML-style output",'%l,_
+ '"printing on and off, and where to place the output. By default, the",'%l,_
+ '"destination for the output is the screen but printing is turned off.",'%l,_ '
+ '%l,_
+ '"Syntax: )set output mathml <arg>",'%l,_
+ '" where arg can be one of",'%l,_
+ '" on turn MathML printing on",'%l,_
+ '" off turn MathML printing off (default state)",'%l,_
+ '" console send MathML output to screen (default state)",'%l,_
+ '" fp<.fe> send MathML output to file with file prefix fp and file",'%l,_
+ '" extension .fe. If not given, .fe defaults to .stex.",'%l,
+ '%l,_
+ '"If you wish to send the output to a file, you must issue this command",'%l,_
+ '"twice: once with",'%b,'"on",'%d,'"and once with the file name. For example, to send",'%l,_
+ '"MathML output to the file",'%b,'"polymer.smml,",'%d,'"issue the two commands",'%l,_
+ '%l,_
+ '" )set output mathml on",'%l,_
+ '" )set output mathml polymer",'%l,_
+ '%l,_
+ '"The output is placed in the directory from which you invoked OpenAxiom or",'%l,_
+ '"the one you set with the )cd system command.",'%l,_
+ '"The current setting is: ",'%b,setOutputMathml "%display%",'%d)
+
+
-- See the subsection output openmath in setvart.boot
--
-- ------------------ The openmath Option ------------------------
diff --git a/src/interp/setvart.boot b/src/interp/setvart.boot
index e2c3ca28..310fe79d 100644
--- a/src/interp/setvart.boot
+++ b/src/interp/setvart.boot
@@ -1136,7 +1136,8 @@ $setOptions := '(
-- length line length of output displays 77
-- scripts show subscripts,... linearly off
-- showeditor view output of )show in editor off
--- tex create output in TeX style Off:CONSOLE
+-- tex create output in TeX style Off:CONSOLE
+-- mathml create output in MathML style Off:CONSOLE
(output
"view and set some output options"
interpreter
@@ -1502,6 +1503,54 @@ $setOptions := '(
NIL)
))
+-- ----------------------- The mathml Option ------------------------
+--
+-- Description: create output in MathML style
+--
+-- )set output mathml is used to tell OpenAxiom to turn MathML-style output
+-- printing on and off, and where to place the output. By default,
+-- the destination for the output is the screen but printing is
+-- turned off.
+--
+-- Syntax: )set output mathml <arg>
+-- where arg can be one of
+-- on turn MathML printing on
+-- off turn MathML printing off (default state)
+-- console send MathML output to screen (default state)
+-- fp<.fe> send MathML output to file with file prefix fp
+-- and file extension .fe. If not given,
+-- .fe defaults to .smml.
+--
+-- If you wish to send the output to a file, you must issue
+-- this command twice: once with on and once with the file name.
+-- For example, to send MathML output to the file polymer.smml,
+-- issue the two commands
+--
+-- )set output mathml on
+-- )set output mathml polymer
+--
+-- The output is placed in the directory from which you invoked
+-- OpenAxiom or the one you set with the )cd system command.
+-- The current setting is: Off:CONSOLE
+
+ (mathml
+ "create output in MathML style"
+ interpreter
+ FUNCTION
+ setOutputMathml
+ (("create output in MathML format"
+ LITERALS
+ $mathmlFormat
+ (off on)
+ off)
+ (break $mathmlFormat)
+ ("where MathML output goes (enter {\em console} or a pathname)"
+ FILENAME
+ $mathmlOutputFile
+ chkOutputFileName
+ "console"))
+ NIL)
+
-- ----------------------- The quit Option -----------------------
--
-- Description: protected or unprotected quit