On 5/2/24 20:51, Ralf Hemmecke wrote:

Another solution might be to add some ioHook to the "output" function.
I haven't actually looked into that.


I believe this is the correct path to go.

The documentation of "output$OutputPackage" explicitly says this
function displays its argument to ``algebra output'' stream.

So for the book, although we explicitly have
  )set out algebra off
This section and other places (e.g. section 2.5.1) still use
this "output" to do some basic IO to the algebra stream.

So in the patch I added ioHook for "mathprint2",
support the new ioHook in htex2input.awk and spool2tex.awk.

And I added a new file tex2tex.awk to combine adjacent blocks
which are both "AlgebraOutput" block or "MessageOutput".
(I think it can't be done cleanly in the same spool2tex.awk file.)

Also the change to REGSET.htex is to prevent long irrelevant output.

- Qian

--
You received this message because you are subscribed to the Google Groups "FriCAS - 
computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to fricas-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/c31318b4-5f01-4711-b458-1c672fd4a43b%40gmail.com.
diff --git a/src/algebra/out.spad b/src/algebra/out.spad
index 3ef0cb44..cc053346 100644
--- a/src/algebra/out.spad
+++ b/src/algebra/out.spad
@@ -30,14 +30,13 @@ OutputPackage : with
     == add
         --ExpressionPackage()
         E      ==> OutputForm
-        putout ==> mathprint$Lisp
 
         s : String
         e : OutputForm
         l : List Any
 
         output e ==
-            mathprint(e)$Lisp
+            mathprint2(e)$Lisp
             void()
         output s ==
             output(s pretend E)
diff --git a/src/doc/Makefile.in b/src/doc/Makefile.in
index 83d317f2..0742b38f 100644
--- a/src/doc/Makefile.in
+++ b/src/doc/Makefile.in
@@ -134,7 +134,7 @@ HTEX2HT       = ${AWK} -f ${srcdir}/ht.awk
 HTEX2SECMENU  = ${AWK} -f ${srcdir}/secmenu.awk
 UGSYSCMD2HELP = ${AWK} -f ${srcdir}/syscmd.awk
 HTEX2INPUT    = ${AWK} -f ${srcdir}/htex2input.awk
-SPOOL2TEX     = ${AWK} -f ${srcdir}/spool2tex.awk
+SPOOL2TEX     = ${AWK} -f ${srcdir}/spool2tex.awk | ${AWK} -f ${srcdir}/tex2tex.awk
 UGEXAMPLES    = ${AWK} -f ${srcdir}/ugexamples.awk
 
 ###################################################################
diff --git a/src/doc/fricas.sty b/src/doc/fricas.sty
index 1f063a30..d22faeb4 100644
--- a/src/doc/fricas.sty
+++ b/src/doc/fricas.sty
@@ -267,6 +267,9 @@
 \lstnewenvironment{MessageOutput}%
   {\lstset{backgroundcolor=\color{bgmessagecolor}}}%
   {}
+\lstnewenvironment{AlgebraOutput}%
+  {\lstset{backgroundcolor=\color{bgalgebracolor}}}%
+  {}
 
 %% This one does not reset the line numbers. Does have horizontal rules.
 \lstnewenvironment{xmpLinesNoReset}%
@@ -403,6 +406,7 @@ Uni-var-iate-Poly-nomial
 % color settings
 \definecolor{bgspadinputcolor}{rgb}{0.95,1,0.95} % (green)  spad input boxes
 \definecolor{bgmessagecolor}{rgb}{1,0.95,0.95}   % (rose)   output messages
+\definecolor{bgalgebracolor}{rgb}{0.95,0.95,1}   % (blue)   algebra output
 \definecolor{bgcode}{rgb}{1,1,0.7}               % (yellow) spad source code
-\backgroundColor{bgmathoutput}[rgb]{0.95,0.95,1} % (gray)   spad output
+\backgroundColor{bgmathoutput}[rgb]{0.95,0.95,1} % (blue)   spad output
 \backgroundColor{bgresulttype}[rgb]{0.98,0.98,1} % (gray)   result type
diff --git a/src/doc/htex/REGSET.htex b/src/doc/htex/REGSET.htex
index f14e00ae..81de311a 100644
--- a/src/doc/htex/REGSET.htex
+++ b/src/doc/htex/REGSET.htex
@@ -378,7 +378,7 @@ Define a polynomial system.
 \begin{texonly}
 \typeout{--rhx: Warning: Remove semicolon in input --> output too long}
 \end{texonly}
-\xtc{
+\noOutputXtc{
 Let us try the information option.
 N.B. The timing should be between 1 and 10 minutes, depending on your machine.
 }{
diff --git a/src/doc/htex2input.awk b/src/doc/htex2input.awk
index 60f36221..bfe75a35 100644
--- a/src/doc/htex2input.awk
+++ b/src/doc/htex2input.awk
@@ -2,7 +2,16 @@ BEGIN {
     print ")set message autoload off"
     print "-- \\begin{inputonly}"
     print ")set break resume"
-    print ")lisp (setf |$ioHook| (lambda (x &optional args) (cond ((eq x '|startKeyedMsg|) (SAY \"-- \\\\begin{MessageOutput}\")) ((eq x '|endOfKeyedMsg|) (SAY \"-- \\\\end{MessageOutput}\")) ((eq x '|startSysCmd|) (SAY \"-- \\\\begin{SysCmdOutput}\")) ((eq x '|endSysCmd|) (SAY \"-- \\\\end{SysCmdOutput}\")) ((eq x '|startPatternMsg|) (SAY \"-- \\\\begin{MessageOutput}\")) ((eq x '|endPatternMsg|) (SAY \"-- \\\\end{MessageOutput}\")))))"
+    print ")lisp (setf |$ioHook| \
+(lambda (x &optional args) \
+  (cond ((eq x '|startKeyedMsg|) (SAY \"-- \\\\begin{MessageOutput}\")) \
+        ((eq x '|endOfKeyedMsg|) (SAY \"-- \\\\end{MessageOutput}\")) \
+        ((eq x '|startSysCmd|) (SAY \"-- \\\\begin{SysCmdOutput}\")) \
+        ((eq x '|endSysCmd|) (SAY \"-- \\\\end{SysCmdOutput}\")) \
+        ((eq x '|startPatternMsg|) (SAY \"-- \\\\begin{MessageOutput}\")) \
+        ((eq x '|endPatternMsg|) (SAY \"-- \\\\end{MessageOutput}\")) \
+        ((eq x '|startAlgebraOutput|) (SAY \"-- \\\\begin{AlgebraOutput}\")) \
+        ((eq x '|endOfAlgebraOutput|) (SAY \"-- \\\\end{AlgebraOutput}\")))))"
     print "setDefault!((label: String): OutputBox +-> vconcat([box \"-- \\begin{TeXOutput}\",defaultPrologue(label)$FormatLaTeX],1,-1)$OutputBox, (label: String): OutputBox +-> vconcat([defaultEpilogue(label)$FormatLaTeX, box \"-- \\end{TeXOutput}\"],1,-1)$OutputBox)$Formatter(FormatLaTeX);"
     print "setFormats!([Formatter(FormatLaTeX)] pretend List(OutputFormatterCategory))$FormattedOutput;"
     print ")set output formatted on"
diff --git a/src/doc/spool2tex.awk b/src/doc/spool2tex.awk
index a459cdd9..bd389fd3 100644
--- a/src/doc/spool2tex.awk
+++ b/src/doc/spool2tex.awk
@@ -6,6 +6,8 @@
 ## .. \end{MessageOutput}
 ## -- \begin{SysCmdOutput}
 ## .. \end{SysCmdOutput}
+## -- \begin{AlgebraOutput}
+## .. \end{AlgebraOutput}
 # Lines inside these environments are treated in a special way.
 # These environments appear inside lines that start with
 ## -- \begin{xtc}
@@ -99,6 +101,12 @@ inxtc==0 {
     next
 }
 
+/^-- \\begin{AlgebraOutput}/ {
+    printf("%s\n",substr($0,4))
+    inAlgebraOutput=1
+    next
+}
+
 /^-- \\end{MessageOutput}/ {
     if(inSysCmdOutput==1) {next}
     printf("%s\n",substr($0,4))
@@ -112,7 +120,13 @@ inxtc==0 {
     next
 }
 
-(inMessageOutput==1 || inSysCmdOutput==1) {
+/^-- \\end{AlgebraOutput}/ {
+    printf("%s\n",substr($0,4))
+    inAlgebraOutput=0
+    next
+}
+
+(inMessageOutput==1 || inSysCmdOutput==1 || inAlgebraOutput==1) {
     print $0
     next
 }
diff --git a/src/doc/tex2tex.awk b/src/doc/tex2tex.awk
new file mode 100644
index 00000000..a2a9f745
--- /dev/null
+++ b/src/doc/tex2tex.awk
@@ -0,0 +1,23 @@
+# This file does some post prcoessings for the tex file.
+
+#
+/^\\end{AlgebraOutput}$/ {
+    getline
+    if (/^\\begin{AlgebraOutput}$/) {next}
+    print "\\end{AlgebraOutput}"
+    print $0
+    next
+}
+
+/^\\end{MessageOutput}$/ {
+    getline
+    if (/^\\begin{MessageOutput}$/) {next}
+    print "\\end{MessageOutput}"
+    print $0
+    next
+}
+
+## default cases
+        {
+    print $0
+}
diff --git a/src/interp/i-output.boot b/src/interp/i-output.boot
index 95065bc5..b72c7010 100644
--- a/src/interp/i-output.boot
+++ b/src/interp/i-output.boot
@@ -355,6 +355,11 @@ mathprint x ==
    x := outputTran2 x
    maprin x
 
+mathprint2 x ==
+  ioHook("startAlgebraOutput")
+  mathprint x
+  ioHook("endOfAlgebraOutput")
+
 sayMath u ==
   for x in u repeat acc:= concat(acc,linearFormatName x)
   sayALGEBRA acc

Reply via email to