Skip to content

Commit

Permalink
Keep unknown commands intact
Browse files Browse the repository at this point in the history
This seems to be a more desirable behavior (see issue#8).
  • Loading branch information
tomtung committed Feb 24, 2018
1 parent a3610c3 commit 6879cbb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ object LaTeX2Unicode {
builder.result()
}

val block: Parser[String] = P(name.flatMap(s => nameToParser.getOrElse(s, PassWithEmptyString)))
val block: Parser[String] = {
val knownCommandBlock = name.filter(nameToParser.contains).flatMap(nameToParser)
val unknownCommand = name
P(knownCommandBlock | unknownCommand)
}
}

private val block: Parser[String] = P(spacesBlock | literalCharsBlock | bracketBlock | command.block)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,9 @@ class LaTeX2UnicodeTest extends FunSuite {
LaTeX2Unicode.parse("\\frac\n\n{}{}") shouldBe a[Failure]
}

test("Unknown commands") {
val str = "\\this \\is \\a \\test"
LaTeX2Unicode.convert(str) shouldBe str
}

}

0 comments on commit 6879cbb

Please sign in to comment.