Connect++ 0.5.0
A fast, readable connection prover for first-order logic.
Loading...
Searching...
No Matches
LaTeXUtilities.cpp
1/*
2
3Copyright © 2023-24 Sean Holden. All rights reserved.
4
5*/
6/*
7
8This file is part of Connect++.
9
10Connect++ is free software: you can redistribute it and/or modify it
11under the terms of the GNU General Public License as published by the
12Free Software Foundation, either version 3 of the License, or (at your
13option) any later version.
14
15Connect++ is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18more details.
19
20You should have received a copy of the GNU General Public License along
21with Connect++. If not, see <https://www.gnu.org/licenses/>.
22
23*/
24
25#include "LaTeXUtilities.hpp"
26
27//-----------------------------------------------------------------
28string latex_escape_characters(const string& s) {
29 string result;
30 for (char c : s) {
31 switch (c) {
32 case '_':
33 result += "\\_";
34 break;
35 case '%':
36 result += "\\%";
37 break;
38 case '$':
39 result += "\\$";
40 break;
41 case '#':
42 result += "\\#";
43 break;
44 case '&':
45 result += "\\&";
46 break;
47 default:
48 result += c;
49 }
50 }
51 return result;
52}
53//-----------------------------------------------------------------
54string latex_truncate_to_length(const string& s) {
55 string s2 = s.substr(0, params::latex_truncation_length);
56 if (s2.size() < s.size())
57 s2 += "\\ldots";
58 return s2;
59}