Skip to content

Commit

Permalink
Fix sections with spaces to not be interpreted as optargs
Browse files Browse the repository at this point in the history
  • Loading branch information
APN-Pucky committed Mar 29, 2021
1 parent 2579604 commit 7f5e62c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
11 changes: 0 additions & 11 deletions src/main/java/TeXCalc/latex/command/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,7 @@ public Command(String name)
public String to(String s) {
// TODO Auto-generated method stub
String w = "";
if(s.contains(" ")) {
String[] args = s.split(" ");
if(!args[args.length-1].trim().equals(""))
w += "["+ args[args.length-1] + "]";
for(int i =0; i < args.length-1;++i) {
//if(!args[i].trim().equals(""))
w += "{" + args[i] + "}";
}
}
else {
w = "{" + s + "}";
}
return "\\" + name + w + "\n";
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/TeXCalc/latex/command/Image.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import TeXCalc.latex.wrap.Wrapper;

public class Image extends Command{
public class Image extends OptCommand{
public Image() {
super("includegraphics");
}
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/TeXCalc/latex/command/OptCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package TeXCalc.latex.command;

public class OptCommand extends Command {

public OptCommand(String name) {
super(name);
}

@Override
public String to(String s) {
// TODO Auto-generated method stub
String w = "";
if(s.contains(" ")) {
String[] args = s.split(" ");
if(!args[args.length-1].trim().equals(""))
w += "["+ args[args.length-1] + "]";
for(int i =0; i < args.length-1;++i) {
//if(!args[i].trim().equals(""))
w += "{" + args[i] + "}";
}
}
else {
w = "{" + s + "}";
}
return "\\" + name + w + "\n";
}

}

0 comments on commit 7f5e62c

Please sign in to comment.