Skip to content

Commit

Permalink
Fix CONTROL + P not printing and better input sanitisation
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeOnuke committed Nov 14, 2021
1 parent 1386fe0 commit 8365ec5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [ main ]

env:
VERSION: 2.0.0
VERSION: 2.1.0

jobs:
build-windows:
Expand All @@ -29,7 +29,7 @@ jobs:
- run: mkdir jpackage-temp && cp target/lmark.jar jpackage-temp

- name: jpackage
run : jpackage --type msi --name lmark --input jpackage-temp/ --main-jar lmark.jar --main-class com.lukeonuke.lmark.LMark --verbose --dest staging/app --description "lmark, the opensource markdown editor" --copyright "lukeonuke MIT 2021" --icon src/main/resources/icon.ico --vendor "LukeOnuke and contributors" --win-shortcut --win-menu --file-associations jpackage-configuration/FAmarkdown.properties
run : jpackage --type msi --name lmark --input jpackage-temp/ --main-jar lmark.jar --main-class com.lukeonuke.lmark.LMark --verbose --dest staging/app --description "lmark, the opensource markdown editor" --copyright "lukeonuke MIT 2021" --icon src/main/resources/icon.ico --vendor "LukeOnuke and contributors" --win-shortcut --win-menu --file-associations jpackage-configuration/FAmarkdown.properties --version 2.1.0
- uses: actions/upload-artifact@v1
with:
name: WindowsPackage
Expand All @@ -53,7 +53,7 @@ jobs:
- run: mkdir jpackage-temp && cp target/lmark.jar jpackage-temp

- name: jpackage
run : jpackage --name lmark --input jpackage-temp --main-jar lmark.jar --main-class com.lukeonuke.lmark.LMark --verbose --dest staging/app --description "lmark, the opensource markdown editor" --copyright "lukeonuke MIT 2021" --icon src/main/resources/icon.ico --linux-shortcut --vendor "LukeOnuke and contributors" --file-associations jpackage-configuration/FAmarkdown.properties
run : jpackage --name lmark --input jpackage-temp --main-jar lmark.jar --main-class com.lukeonuke.lmark.LMark --verbose --dest staging/app --description "lmark, the opensource markdown editor" --copyright "lukeonuke MIT 2021" --icon src/main/resources/icon.ico --linux-shortcut --vendor "LukeOnuke and contributors" --file-associations jpackage-configuration/FAmarkdown.properties --version 2.1.0
- uses: actions/upload-artifact@v1
with:
name: LinuxPackage
Expand All @@ -77,7 +77,7 @@ jobs:
- run: mkdir jpackage-temp && cp target/lmark.jar jpackage-temp

- name: jpackage
run : jpackage --name lmark --input jpackage-temp --main-jar lmark.jar --main-class com.lukeonuke.lmark.LMark --verbose --dest staging/app --description "lmark, the opensource markdown editor" --copyright "lukeonuke MIT 2021" --icon src/main/resources/icon.ico --vendor "LukeOnuke and contributors" --file-associations jpackage-configuration/FAmarkdown.properties
run : jpackage --name lmark --input jpackage-temp --main-jar lmark.jar --main-class com.lukeonuke.lmark.LMark --verbose --dest staging/app --description "lmark, the opensource markdown editor" --copyright "lukeonuke MIT 2021" --icon src/main/resources/icon.ico --vendor "LukeOnuke and contributors" --file-associations jpackage-configuration/FAmarkdown.properties --version 2.1.0

- uses: actions/upload-artifact@v1
with:
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/lukeonuke/lmark/gui/MainAppWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public void show() {
edit.setText("");
edit.textProperty().addListener((observableValue, s, t1) -> {
markdown.setMDContents(edit.getText());
if(edit.getCaretPosition() == edit.getLength() - 1) markdown.scrollTo(1D);
if (!s.equals("")) tampered = true;
updateTitle();

Expand Down Expand Up @@ -492,6 +493,10 @@ public void show() {
if (keyEvent.isControlDown() && keyEvent.getCode().equals(KeyCode.T)) {
titleFormat(edit);
}

if(keyEvent.isControlDown() && keyEvent.getCode().equals(KeyCode.P)){
print(markdown);
}
});

registry.registerRegistryChangeEvent(ApplicationConstants.PROPERTIES_AUTOSAVE_ENABLED, autosaveEvent -> {
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/com/lukeonuke/lmark/gui/elements/Markdown.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.events.Event;
import org.w3c.dom.events.EventListener;
import org.w3c.dom.events.EventTarget;
import org.w3c.dom.html.HTMLAnchorElement;

import java.io.File;
import java.io.IOException;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -43,7 +42,7 @@ public class Markdown {
private static final Parser parser;
private double scrollY;
private String contents;
private static MutableDataSet options = new MutableDataSet();
private final static MutableDataSet options = new MutableDataSet();
final ThemeManager themeManager = ThemeManager.getInstance();

static {
Expand Down Expand Up @@ -178,8 +177,12 @@ private void scroll(double y) {
}

private String filter(String string) {
return string.replace("<strong>", "<b>")
.replace("</strong>", "</b>");
org.jsoup.nodes.Document document = Jsoup.parse(string.replace("<strong>", "<b>")
.replace("</strong>", "</b>"));
document.getElementsByTag("code").textNodes().forEach(textNode -> {
textNode.text(textNode.text().replace("&lt;", "<"));
});
return document.html();
}

/**
Expand All @@ -206,6 +209,7 @@ public String getPDFReadyDocument() {
return document.html();
}


/**
* Implements a bridge between the javascript on the web view and the java:tm: on ere
* https://stackoverflow.com/questions/35985601/calling-a-java-method-from-a-javafx-webview
Expand Down

0 comments on commit 8365ec5

Please sign in to comment.