Skip to content

Commit 8ac8aa4

Browse files
committed
allow using percentual numbers for images dimensions
1 parent 755cff6 commit 8ac8aa4

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

src/latexdocvisitor.cpp

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,32 @@ static const char *getSectionName(int level)
5252
return secLabels[std::min(maxLevels-1,l)];
5353
}
5454

55+
static void insertDimension(TextStream &t, QCString dimension, const char *percentString)
56+
{
57+
// dimensions for latex images can be procentual, in this case they need some extra
58+
// handling as the % symbol is used for comments
59+
int i = dimension.find('%');
60+
if (i > 0)
61+
{
62+
QCString value = dimension.left(i).stripWhiteSpace();
63+
int number = 0;
64+
if (sscanf(value.data(),"%d",&number) != 0)
65+
{
66+
t << (double)number / 100;
67+
t << "\\text";
68+
t << percentString;
69+
}
70+
else
71+
{
72+
t << dimension;
73+
}
74+
}
75+
else
76+
{
77+
t << dimension;
78+
}
79+
}
80+
5581
static void visitPreStart(TextStream &t, bool hasCaption, QCString name, QCString width, QCString height, bool inlineImage = FALSE)
5682
{
5783
if (inlineImage)
@@ -78,15 +104,17 @@ static void visitPreStart(TextStream &t, bool hasCaption, QCString name, QCStri
78104
}
79105
if (!width.isEmpty())
80106
{
81-
t << "width=" << width;
107+
t << "width=";
108+
insertDimension(t, width, "width");
82109
}
83110
if (!width.isEmpty() && !height.isEmpty())
84111
{
85112
t << ",";
86113
}
87114
if (!height.isEmpty())
88115
{
89-
t << "height=" << height;
116+
t << "height=";
117+
insertDimension(t, height, "height");
90118
}
91119
if (width.isEmpty() && height.isEmpty())
92120
{

0 commit comments

Comments
 (0)