From 80a80e7ff354edb999038e88127e809048d9572d Mon Sep 17 00:00:00 2001 From: Martin Gieseking Date: Wed, 5 Jul 2023 10:37:25 +0200 Subject: [PATCH] added special 'dvisvgm:message' --- doc/dvisvgm.1 | 14 ++++++++++++-- doc/dvisvgm.txt.in | 6 +++++- src/DvisvgmSpecialHandler.cpp | 12 +++++++++++- src/DvisvgmSpecialHandler.hpp | 1 + 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/doc/dvisvgm.1 b/doc/dvisvgm.1 index a71477d2..95d062c8 100644 --- a/doc/dvisvgm.1 +++ b/doc/dvisvgm.1 @@ -2,12 +2,12 @@ .\" Title: dvisvgm .\" Author: Martin Gieseking .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 2023-06-19 +.\" Date: 2023-07-05 .\" Manual: dvisvgm Manual .\" Source: dvisvgm 3.1 .\" Language: English .\" -.TH "DVISVGM" "1" "2023\-06\-19" "dvisvgm 3\&.1" "dvisvgm Manual" +.TH "DVISVGM" "1" "2023\-07\-05" "dvisvgm 3\&.1" "dvisvgm Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -1423,6 +1423,16 @@ allows for applying the current transformation matrix to the bounding box\&. This variant of the bbox special assigns an absolute (final) bounding box to the resulting SVG\&. After executing this command, dvisvgm doesn\(cqt further alter the bounding box coordinates, except this special is called again later\&. The points (\fIx1\fR,\fIy1\fR) and (\fIx2\fR,\fIy2\fR) denote the absolute coordinates of two diagonal corners of the rectangle\&. As with the relative special variant described above, the optional modifier \fBtransform\fR allows for applying the current transformation matrix to the bounding box\&. +.RE +.PP +\fBdvisvgm:message\fR \fImsg\fR +.RS 4 +Prints the given text +\fImsg\fR +to the console\&. It may also contain the macros +\fI{?\&...}\fR +mentioned above (see +\fBdvisvgm:raw\fR)\&. .sp The following TeX snippet adds two raw SVG elements to the output and updates the bounding box accordingly: .sp diff --git a/doc/dvisvgm.txt.in b/doc/dvisvgm.txt.in index e0cdbba2..5b31c8d0 100644 --- a/doc/dvisvgm.txt.in +++ b/doc/dvisvgm.txt.in @@ -22,7 +22,7 @@ Martin Gieseking <@PACKAGE_BUGREPORT@> :man source: dvisvgm :man version: @VERSION@ :man manual: dvisvgm Manual -:revdate: 2023-06-19 10:59 +0200 +:revdate: 2023-07-05 10:37 +0200 Name ---- @@ -880,6 +880,10 @@ dvisvgm offers its own small set of specials. The following list gives a brief o The points ('x1','y1') and ('x2','y2') denote the absolute coordinates of two diagonal corners of the rectangle. As with the relative special variant described above, the optional modifier +transform+ allows for applying the current transformation matrix to the bounding box. + + *dvisvgm:message* 'msg';; + Prints the given text 'msg' to the console. It may also contain the macros '{?...}' mentioned above + (see *dvisvgm:raw*). + The following TeX snippet adds two raw SVG elements to the output and updates the bounding box accordingly: + diff --git a/src/DvisvgmSpecialHandler.cpp b/src/DvisvgmSpecialHandler.cpp index e33d2fb6..0a840385 100644 --- a/src/DvisvgmSpecialHandler.cpp +++ b/src/DvisvgmSpecialHandler.cpp @@ -26,6 +26,7 @@ #include "InputBuffer.hpp" #include "InputReader.hpp" #include "Length.hpp" +#include "Message.hpp" #include "SpecialActions.hpp" #include "SVGTree.hpp" #include "utility.hpp" @@ -181,7 +182,8 @@ bool DvisvgmSpecialHandler::process (const string &prefix, istream &is, SpecialA {"rawput", &DvisvgmSpecialHandler::processRawPut}, {"bbox", &DvisvgmSpecialHandler::processBBox}, {"img", &DvisvgmSpecialHandler::processImg}, - {"currentcolor", &DvisvgmSpecialHandler::processCurrentColor} + {"currentcolor", &DvisvgmSpecialHandler::processCurrentColor}, + {"message", &DvisvgmSpecialHandler::processMessage} }; StreamInputReader ir(is); const string cmdstr = ir.getWord(); @@ -469,6 +471,14 @@ void DvisvgmSpecialHandler::processCurrentColor (InputReader &ir, SpecialActions } +void DvisvgmSpecialHandler::processMessage (InputReader &ir, SpecialActions &actions) { + string message = ir.getLine(); + evaluate_expressions(message, actions); + expand_constants(message, actions); + Message::mstream() << message << "\n"; +} + + void DvisvgmSpecialHandler::dviPreprocessingFinished () { string id; if (_currentMacro != _macros.end()) diff --git a/src/DvisvgmSpecialHandler.hpp b/src/DvisvgmSpecialHandler.hpp index 5c8bbe5b..7edecb12 100644 --- a/src/DvisvgmSpecialHandler.hpp +++ b/src/DvisvgmSpecialHandler.hpp @@ -94,6 +94,7 @@ class DvisvgmSpecialHandler : public SpecialHandler { void processBBox (InputReader &ir, SpecialActions &actions); void processImg (InputReader &ir, SpecialActions &actions); void processCurrentColor (InputReader &ir, SpecialActions &actions); + void processMessage (InputReader &ir, SpecialActions &actions); void dviPreprocessingFinished () override; void dviBeginPage (unsigned pageno, SpecialActions &actions) override; void dviEndPage (unsigned pageno, SpecialActions &actions) override;