Skip to content

Commit

Permalink
Merge pull request #7 from Hinaser/v0.0.4
Browse files Browse the repository at this point in the history
v0.0.4
  • Loading branch information
Hinaser authored Jan 13, 2021
2 parents 548a10d + e33a284 commit 98611fe
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 6 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## [0.0.4] - Jan 13, 2021
### Added
- Now compatible with IntelliJ 2020.3

### Fixed
- Fixed an issue where emoji was not rendered properly.

### Changed
- Options of this plugin are not searchable in Settings dialog for now
because of [this issue](https://youtrack.jetbrains.com/issue/KTIJ-782)

## [0.0.3] - Aug 25, 2020
### Fixed
- Fixed an issue where GfmA panel not showing current markdown when markdown text edited before the panel opened.
Expand All @@ -10,5 +21,6 @@
### Fixed
- Fixed an issue where offline parser did not properly parse and render some gfm syntax.

[0.0.4]: https://github.com/Hinaser/gfm-advanced/releases/tag/v0.0.4
[0.0.3]: https://github.com/Hinaser/gfm-advanced/releases/tag/v0.0.3
[0.0.2]: https://github.com/Hinaser/gfm-advanced/releases/tag/v0.0.2
10 changes: 8 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
apply plugin: 'org.jetbrains.changelog'

group 'com.github.hinaser'
version '0.0.3'
version '0.0.4'

repositories {
mavenCentral()
Expand All @@ -27,10 +27,12 @@ dependencies {
// For debugging purpose, I recommend to also download correspond source file here.
// https://github.com/JetBrains/intellij-community/tags
intellij {
version '202.6397.94'
version '203.5981.155'
}
patchPluginXml {
changeNotes({ changelog.getLatest().toHTML() })
sinceBuild '202.6109'
untilBuild '203.*'
}
publishPlugin {
token = System.getenv("ORG_GRADLE_PROJECT_intellijPublishToken")
Expand All @@ -45,4 +47,8 @@ changelog {
keepUnreleasedSection = true
unreleasedTerm = "[Unreleased]"
groups = ["Added", "Changed", "Deprecated", "Removed", "Fixed", "Security"]
}

buildSearchableOptions {
enabled = false
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ public void onMarkdownParseDone(String html) {
String showActiveParser = settings.isShowActiveParser() ? "true" : "false";
String isFallbackToOfflineParser = settings.isFallingBackToOfflineParser() ? "true" : "false";

String escapedHtml = html
.replaceAll("[\"]", "\\\\\"")
.replaceAll("[\n]", "\\\\n");
// Escape emojis, quotations, new lines
// @See https://github.com/Hinaser/gfm-advanced/issues/5
String escapedHtml = getEscapedHtmlString(html);

String javascript = ""
+ "window.reloadHtml = function(){\n"
Expand Down Expand Up @@ -95,6 +95,30 @@ public void onMarkdownParseDone(String html) {
}
}

public String getEscapedHtmlString(String html){
html = html.replaceAll("\"", "\\\\\"").replaceAll("\n", "\\\\n");

StringBuilder escapedHtml = new StringBuilder();
for(int i=0; i<html.length(); i++){
int cp = html.codePointAt(i);

// Handle emoji or character represented by surrogate pair.
if(cp > 65535){
StringBuilder sb = new StringBuilder();
sb.append("&#");
sb.append(cp);
sb.append(";");
escapedHtml.append(sb);
i++; // It seems low surrogate value is included in `html.codePointAt(high_surrogate_index)`, so skip it.
}
else{
escapedHtml.appendCodePoint(cp);
}
}

return escapedHtml.toString();
}

@Override
public void onMarkdownParseFailed(String errorMessage, String stackTrace) {
ErrorTemplate template = ErrorTemplate.getInstance();
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<name>GfmA</name>
<vendor email="[email protected]" url="https://github.com/Hinaser">Hinaser</vendor>

<idea-version since-build="202.6109" />
<idea-version since-build="202.6109" until-build="203.*" />

<description><![CDATA[
<p>Yet another GitHub Flavored Markdown Preview plugin for intellij platform</p>
Expand Down

0 comments on commit 98611fe

Please sign in to comment.