Browse files

Revert "forcing utf-8 as pygments input"

This reverts commit fad119d.
  • Loading branch information...
1 parent a484731 commit 75ff9cf40ac17332d9e791c2e578832e473348bd @sergiolopes sergiolopes committed Oct 22, 2012
View
4 src/main/java/br/com/caelum/tubaina/parser/html/desktop/SyntaxHighlighter.java
@@ -43,10 +43,12 @@ public String highlight(String code, String language, boolean numbered, List<Int
addLineHighlightOption(lines, options);
+ String encoding = System.getProperty("file.encoding");
+
ArrayList<String> commands = new ArrayList<String>();
commands.add("pygmentize");
commands.add("-O");
- commands.add("encoding=UTF-8,outencoding=UTF-8" + options);
+ commands.add("encoding=" + encoding + ",outencoding=UTF-8" + options);
if (output.equals(LATEX_OUTPUT)) {
commands.add("-P");
commands.add("verboptions=numbersep=5pt");
View
9 src/test/java/br/com/caelum/tubaina/parser/html/desktop/SyntaxHighlighterTest.java
@@ -18,21 +18,20 @@
private CommandExecutor executor;
private SyntaxHighlighter highlighter;
private CodeCache codeCache;
- private String encoding;
@Before
public void setUp() {
this.sampleCode = "public class Foo {\n" + "public int Bar(){\n" + "return 0;\n" + "}\n" + "}";
this.executor = mock(CommandExecutor.class);
this.codeCache = mock(CodeCache.class);
this.highlighter = new SyntaxHighlighter(executor, SyntaxHighlighter.HTML_OUTPUT, false, codeCache);
- this.encoding = "UTF-8";
}
@Test
public void shouldCallPygmentsWithJavaLexer() throws Exception {
String code = "public class Foo {\n" + "public int Bar(){\n" + "return 0;\n" + "}\n" + "}";
highlighter.highlight(code, "java", false);
+ String encoding = System.getProperty("file.encoding");
List<String> arguments = Arrays.asList("pygmentize", "-O", "encoding=" + encoding
+ ",outencoding=UTF-8", "-f", "html", "-l", "java");
verify(executor).execute(eq(arguments), eq(sampleCode));
@@ -41,16 +40,21 @@ public void shouldCallPygmentsWithJavaLexer() throws Exception {
@Test
public void shouldCallPygmentsWithNumberedLinesOption() throws Exception {
highlighter.highlight(sampleCode, "java", true);
+ String encoding = System.getProperty("file.encoding");
List<String> arguments = Arrays.asList("pygmentize", "-O", "encoding=" + encoding
+ ",outencoding=UTF-8,linenos=inline", "-f", "html", "-l", "java");
verify(executor).execute(eq(arguments), eq(sampleCode));
}
@Test
public void shouldCallPygmentsWithHlLines() throws Exception {
+
List<Integer> lines = Arrays.asList(1, 2, 5);
+
highlighter.highlight(sampleCode, "java", false, lines);
+ String encoding = System.getProperty("file.encoding");
+
List<String> arguments = Arrays.asList("pygmentize", "-O", "encoding=" + encoding
+ ",outencoding=UTF-8,hl_lines=1 2 5", "-f", "html", "-l", "java");
@@ -61,6 +65,7 @@ public void shouldCallPygmentsWithHlLines() throws Exception {
public void shouldCallPygmentsWithLatexOutput() throws Exception {
this.highlighter = new SyntaxHighlighter(executor, SyntaxHighlighter.LATEX_OUTPUT, false, codeCache);
highlighter.highlight(sampleCode, "java", false);
+ String encoding = System.getProperty("file.encoding");
List<String> arguments = Arrays.asList("pygmentize", "-O", "encoding=" + encoding
+ ",outencoding=UTF-8", "-P", "verboptions=numbersep=5pt", "-f", "latex", "-l", "java");
verify(executor).execute(eq(arguments), eq(sampleCode));

0 comments on commit 75ff9cf

Please sign in to comment.