1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-27 23:28:38 +02:00

Removed cache package dependency and implemented one more suitable for React Native

This commit is contained in:
Laurent Cozic
2020-10-15 18:40:13 +01:00
parent efa346fea4
commit eec32cf70a
18 changed files with 172 additions and 40 deletions

View File

@ -2,7 +2,7 @@ const MarkdownIt = require('markdown-it');
const md5 = require('md5');
const noteStyle = require('./noteStyle');
const { fileExtension } = require('./pathUtils');
const memoryCache = require('memory-cache');
const InMemoryCache = require('lib/InMemoryCache').default;
// /!\/!\ Note: the order of rules is important!! /!\/!\
const rules = {
@ -44,6 +44,9 @@ function slugify(s) {
return nodeSlug(s);
}
// Share across all instances of MdToHtml
const inMemoryCache = new InMemoryCache(20);
class MdToHtml {
constructor(options = null) {
if (!options) options = {};
@ -57,7 +60,7 @@ class MdToHtml {
this.cachedHighlightedCode_ = {};
this.ResourceModel_ = options.ResourceModel;
this.pluginOptions_ = options.pluginOptions ? options.pluginOptions : {};
this.contextCache_ = new memoryCache.Cache();
this.contextCache_ = inMemoryCache;
this.tempDir_ = options.tempDir;
this.fsDriver_ = {