Skip to content

Commit

Permalink
fix evernote extension for 2024.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
pilotmoon committed May 14, 2024
1 parent ce81606 commit ee30194
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 178 deletions.
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,24 @@
"@joplin/turndown-plugin-gfm": "^1.0.43",
"@popclip/helpers": "file:lib/@popclip/helpers",
"@popclip/test": "file:lib/@popclip/test",
"@popclip/types": "^1.4586.0",
"@tryfabric/martian": "^1.2.4",
"@types/crypto-js": "^4.1.1",
"@types/voca": "^1.4.1",
"axios": "1.6.8",
"browserify": "^17.0.0",
"case-anything": "^2.1.10",
"core-js": "^3.22.7",
"crypto-js": "^4.1.1",
"evernote": "^2.0.5",
"html-entities": "^2.3.3",
"linkedom": "0.18.0",
"mathjs": "^10.0.0",
"rot13-cipher": "1.0.0",
"sanitize-html": "2.13.0",
"slackify-markdown": "^4.3.1",
"superagent": "^6.1.0",
"turndown": "7.1.3",
"turndown-plugin-gfm": "^1.0.2",
"typescript": "5.4.5",
"voca": "^1.4.0",
Expand Down
11 changes: 4 additions & 7 deletions source/Evernote.popclipext/Config.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
{
"popclip version": 3895,
"popclip version": 4586,
"identifier": "com.pilotmoon.popclip.extension.evernote",
"name": "Evernote",
"icon": "evernote-logo.svg",
"capture html": true,
"module": "main.bundle.js.lzfse",
"entitlements": [
"network"
],
"entitlements": ["network"],
"app": {
"name": "Evernote",
"link": "https://evernote.com/"
},
"description": "Send the selected text to Evernote.",
"note": "Updated 15 Sep 2022 with fix."
}
"description": "Send the selected text to Evernote."
}
24 changes: 7 additions & 17 deletions source/Evernote.popclipext/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,13 @@ Icon from [svgrepo](https://www.svgrepo.com/svg/24585/evernote) (CC0).

### Requirements

* PopClip 2022.5
* An Evernote account
- PopClip 2024.5 or later
- An Evernote account

## Changelog

### 15 Sep 2022

* Fix bug with build, extension not working.

### 5 May 2022

* Rewritten to send the to the Evernote servers directly using the Evernote API.

### 30 Jun 2014

* Updated to support HTML content.

### 8 Nov 2012

* Initial release using AppleScript.
- 14 May 2024: Fix for PopClip 2024.5.
- 15 Sep 2022: Fix bug with build, extension not working.
- 5 May 2022: Rewritten to send the to the Evernote servers directly using the Evernote API.
- 30 Jun 2014: Updated to support HTML content.
- 8 Nov 2012: Initial release using AppleScript.
4 changes: 2 additions & 2 deletions source/Evernote.popclipext/build
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
npx tsc
module=main
npx browserify --external sanitize-html --external htmlparser2 --external dom-serializer --standalone foo $module.js > $module.bundle.js
lzfse -encode -i $module.bundle.js > $module.bundle.js.lzfse
rm $module.bundle.js
lzfse -encode -i $module.bundle.js > $module.bundle.js.lzfse
rm *.js
36 changes: 0 additions & 36 deletions source/Evernote.popclipext/enml.js

This file was deleted.

39 changes: 20 additions & 19 deletions source/Evernote.popclipext/enml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,30 @@
// with a couple of extra tags and a restriction on which tags can attributes can be used.
// The allowed list of tags and attributes is given in enml.json.
// https://dev.evernote.com/doc/articles/enml.php
import * as sanitizeHtml from 'sanitize-html'
import { parseDocument } from 'htmlparser2'
import render from 'dom-serializer'
import { allowedTags, allowedAttributes } from './enml.json'
import sanitizeHtml from "sanitize-html";
import { parseDocument } from "htmlparser2";
import render from "dom-serializer";
import { allowedTags, allowedAttributes } from "./enml.json";

// clean HTML by removing disallowed tags and attributes
export const cleanHtml = (dirty: string): string => {
return sanitizeHtml(dirty, {
allowedTags: allowedTags,
allowedAttributes: allowedAttributes,
exclusiveFilter: function (frame) {
return frame.tag === 'a' && frame.text.trim().length === 0 // also remove empty links (usually anchors)
}
})
}
return sanitizeHtml(dirty, {
allowedTags: allowedTags,
allowedAttributes: allowedAttributes,
exclusiveFilter: function (frame) {
return frame.tag === "a" && frame.text.trim().length === 0; // also remove empty links (usually anchors)
},
});
};
// render given HTML string as XHTML
export const renderXhtml = (html: string): string => {
const document = parseDocument(html)
return render(document, { xmlMode: true })
}
const document = parseDocument(html);
return render(document, { xmlMode: true });
};
// render given HTML string as ENML
export const renderEnml = (html: string): string => {
const prefix = '<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">\n<en-note>'
const suffix = '</en-note>'
return prefix + renderXhtml(cleanHtml(html)) + suffix
}
const prefix =
'<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">\n<en-note>';
const suffix = "</en-note>";
return prefix + renderXhtml(cleanHtml(html)) + suffix;
};
Binary file modified source/Evernote.popclipext/main.bundle.js.lzfse
Binary file not shown.
65 changes: 0 additions & 65 deletions source/Evernote.popclipext/main.js

This file was deleted.

54 changes: 22 additions & 32 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,23 @@
{
"compilerOptions": {
"strict": true,
"noImplicitAny": false,
// note es2018 requires macOS 10.14
// once we drop support for high sierra this can be bumped for cleaner js code
// (note es2018 is required for async generators)
"target": "es2017",
"lib": [
"es2021"
],
// we can specify esnext lib due to polyfills in popclip
"module": "commonjs",
"esModuleInterop": false,
"moduleResolution": "node",
"resolveJsonModule": true,
"baseUrl": "./lib",
},
"include": [
"./popclip.d.ts",
"./lib",
"./extras",
"./source",
"./source-contrib",
"./scratch"
],
"exclude": ["/Applications/PopClip.app/Contents/Resources/popclip.d.ts"],
"ts-standard": {
"ignore": [
"**/*.js"
]
}
}
"compilerOptions": {
"strict": true,
"noImplicitAny": false,
"target": "es2018",
"lib": ["es2023"],
"skipLibCheck": true,
"module": "commonjs",
"esModuleInterop": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"baseUrl": "./lib"
},
"include": [
"./node_modules/@popclip/types/popclip.d.ts",
"./node_modules/@popclip/types/extra/shims.d.ts",
"./lib",
"./extras",
"./source",
"./source-contrib"
],
"exclude": ["/Applications/PopClip.app/Contents/Resources/popclip.d.ts"]
}

0 comments on commit ee30194

Please sign in to comment.