Skip to content

Commit

Permalink
Desktop, Mobile: Fixes #1870: Support non-alphabetical characters in …
Browse files Browse the repository at this point in the history
…note link anchors
  • Loading branch information
laurent22 committed Sep 12, 2019
1 parent 5db7502 commit 0379523
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 2 deletions.
13 changes: 13 additions & 0 deletions ElectronClient/app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ElectronClient/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
"tcp-port-used": "^0.1.2",
"uglifycss": "0.0.29",
"url-parse": "^1.4.3",
"uslug": "^1.0.4",
"uuid": "^3.2.1",
"valid-url": "^1.0.9",
"xml2js": "^0.4.19"
Expand Down
5 changes: 4 additions & 1 deletion ReactNativeClient/lib/renderers/MdToHtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const rules = {
};
const setupLinkify = require('./MdToHtml/setupLinkify');
const hljs = require('highlight.js');
const uslug = require('uslug');
const markdownItAnchor = require('markdown-it-anchor');
// The keys must match the corresponding entry in Setting.js
const plugins = {
Expand Down Expand Up @@ -142,7 +143,9 @@ class MdToHtml {
if (Setting.value('markdown.plugin.fountain')) markdownIt.use(rules.fountain(context, ruleOptions));
markdownIt.use(rules.highlight_keywords(context, ruleOptions));
markdownIt.use(rules.code_inline(context, ruleOptions));
markdownIt.use(markdownItAnchor);
markdownIt.use(markdownItAnchor, {
slugify: s => uslug(s),
});

for (let key in plugins) {
if (Setting.value('markdown.plugin.' + key)) markdownIt.use(plugins[key].module, plugins[key].options);
Expand Down
7 changes: 6 additions & 1 deletion ReactNativeClient/lib/urlUtils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { rtrimSlashes } = require('lib/path-utils');
const { urlDecode } = require('lib/string-utils');

const urlUtils = {};

Expand Down Expand Up @@ -55,7 +56,11 @@ urlUtils.parseResourceUrl = function(url) {
};

if (splitted.length) output.itemId = splitted[0];
if (splitted.length >= 2) output.hash = splitted[1];

// In general we want the hash to be decoded so that non-alphabetical languages
// appear as-is without being encoded with %.
// Fixes https://github.com/laurent22/joplin/issues/1870
if (splitted.length >= 2) output.hash = urlDecode(splitted[1]);

return output;
};
Expand Down
13 changes: 13 additions & 0 deletions ReactNativeClient/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ReactNativeClient/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"timers": "^0.1.1",
"url": "^0.11.0",
"url-parse": "^1.4.7",
"uslug": "^1.0.4",
"uuid": "^3.0.1",
"valid-url": "^1.0.9",
"word-wrap": "^1.2.3",
Expand Down

0 comments on commit 0379523

Please sign in to comment.