Skip to content

Commit

Permalink
added special 'dvisvgm:message'
Browse files Browse the repository at this point in the history
  • Loading branch information
mgieseki committed Jul 5, 2023
1 parent 416f2bd commit 80a80e7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
14 changes: 12 additions & 2 deletions doc/dvisvgm.1
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
.\" Title: dvisvgm
.\" Author: Martin Gieseking <[email protected]>
.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
.\" 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
.\" -----------------------------------------------------------------
Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion doc/dvisvgm.txt.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
----
Expand Down Expand Up @@ -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:
+
Expand Down
12 changes: 11 additions & 1 deletion src/DvisvgmSpecialHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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())
Expand Down
1 change: 1 addition & 0 deletions src/DvisvgmSpecialHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 80a80e7

Please sign in to comment.