Connect++
0.5.0
A fast, readable connection prover for first-order logic.
Loading...
Searching...
No Matches
LaTeXUtilities.cpp
1
/*
2
3
Copyright © 2023-24 Sean Holden. All rights reserved.
4
5
*/
6
/*
7
8
This file is part of Connect++.
9
10
Connect++ is free software: you can redistribute it and/or modify it
11
under the terms of the GNU General Public License as published by the
12
Free Software Foundation, either version 3 of the License, or (at your
13
option) any later version.
14
15
Connect++ is distributed in the hope that it will be useful, but WITHOUT
16
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18
more details.
19
20
You should have received a copy of the GNU General Public License along
21
with Connect++. If not, see <https://www.gnu.org/licenses/>.
22
23
*/
24
25
#include "LaTeXUtilities.hpp"
26
27
//-----------------------------------------------------------------
28
string
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
//-----------------------------------------------------------------
54
string
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
}
source
utilities
LaTeXUtilities.cpp
Generated by
1.10.0