Skip to content
This repository has been archived by the owner on May 20, 2021. It is now read-only.

Commit

Permalink
Merge pull request #104 from ShyykoSerhiy/dev
Browse files Browse the repository at this point in the history
v0.1.9
  • Loading branch information
ShyykoSerhiy committed Feb 1, 2016
2 parents 67988c5 + 65ecfdd commit 0206007
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import com.github.shyykoserhiy.gfm.template.TemplateManager;

import java.io.File;
import java.io.FileWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;

public abstract class AbstractMarkdownParser {
private ThrottlePoolExecutor connectionsThreadPool = new ThrottlePoolExecutor(500);
Expand Down Expand Up @@ -46,9 +48,9 @@ protected void fireSuccess(String html) throws IOException {
if (useFileAsSuccessResponse) {
String responseText = templateManager.getMarkdownHtml(filename, html);
File file = File.createTempFile("markdown", ".html"); //todo get rid of files (Fix Lobo to accept Strings?)
FileWriter fileWriter = new FileWriter(file);
fileWriter.write(responseText);
fileWriter.close();
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(file), Charset.forName("UTF-8"));
writer.write(responseText);
writer.close();
requestDoneListener.onRequestDone(file);
} else {
requestDoneListener.onRequestDone(filename, html);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;

public class JnaMarkdownParser extends AbstractMarkdownParser {
private static boolean jnaInitialized;
Expand Down Expand Up @@ -65,7 +66,7 @@ public GfmWorker getWorker(String filename, String markdown, boolean useFileAsSu

private MarkdownJna.Buffer markdownToHtml(String markdown) throws PlatformNotSupported {
initializeJna();
return markdownJna.markdownToHtml(markdown, markdown.getBytes().length);
return markdownJna.markdownToHtml(markdown, markdown.getBytes(Charset.forName("UTF-8")).length);
}

private class GfmWorker extends AbstractMarkdownParser.GfmWorker {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.sun.jna.Pointer;
import com.sun.jna.Structure;

import java.io.UnsupportedEncodingException;
import java.util.Arrays;
import java.util.List;

Expand All @@ -29,7 +30,13 @@ public String toString() {
throw new OutOfMemoryError("String exceeds maximum length: " + len);
}
byte[] data = this.data.getByteArray(0, (int) len);
return new String(data);
String text;
try {
text = new String(data, System.getProperty("jna.encoding", "utf8"));
} catch (UnsupportedEncodingException e) {
text = new String(data);
}
return text;
}
return data.getString(0, false);
}
Expand Down
17 changes: 16 additions & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<idea-plugin version="2">
<id>com.github.shyykoserhiy.gfm</id>
<name>gfm</name>
<version>0.1.8</version>
<version>0.1.9</version>
<vendor email="[email protected]" url="https://github.com/shyykoserhiy/gfm-plugin">Shyyko Serhiy</vendor>

<description><![CDATA[
Expand All @@ -19,6 +19,21 @@

<change-notes><![CDATA[
<p>
<b>0.1.9</b>
<ul>
<li>
Fixed <a href="https://github.com/ShyykoSerhiy/gfm-plugin/issues/103">Gfm does not retain encoding in Windows, garbles non-ASCII text</a>
</li>
<li>
Fixed <a href="https://github.com/ShyykoSerhiy/gfm-plugin/issues/102">Chinese garbled on Windows platform</a>
</li>
<li>
Fixed <a href="https://github.com/ShyykoSerhiy/gfm-plugin/issues/68">German umlauts (ä,ö,ü,ß)</a>
</li>
<li>
Fixed <a href="https://github.com/ShyykoSerhiy/gfm-plugin/issues/64">Cyrillic support</a>
</li>
</ul>
<b>0.1.8</b>
<ul>
<li>
Expand Down

0 comments on commit 0206007

Please sign in to comment.