Skip to content

Commit 5d3dbd6

Browse files
committed
Add Remarkable singletons configuration to enable customization
1 parent 0a8059c commit 5d3dbd6

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/markdown-to-draft.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ const DefaultBlockStyles = {
101101
code: 'CODE'
102102
};
103103

104+
// Remarkable blocks that stands alone.
105+
const DefaultRemarkableSingletons = [
106+
'hr',
107+
'fence',
108+
]
109+
104110
// Key generator for entityMap items
105111
var idCounter = -1;
106112
function generateUniqueKey() {
@@ -229,6 +235,7 @@ function markdownToDraft(string, options = {}) {
229235
const BlockTypes = Object.assign({}, DefaultBlockTypes, options.blockTypes || {});
230236
const BlockEntities = Object.assign({}, DefaultBlockEntities, options.blockEntities || {});
231237
const BlockStyles = Object.assign({}, DefaultBlockStyles, options.blockStyles || {});
238+
const RemarkableSingletons = DefaultRemarkableSingletons.concat(options.remarkableSingletons)
232239

233240
parsedData.forEach(function (item) {
234241
// Because of how remarkable's data is formatted, we need to cache what kind of list we're currently dealing with
@@ -254,7 +261,7 @@ function markdownToDraft(string, options = {}) {
254261

255262
// The entity map is a master object separate from the block so just add any entities created for this block to the master object
256263
Object.assign(entityMap, blockEntities);
257-
} else if ((itemType.indexOf('_open') !== -1 || itemType === 'fence' || itemType === 'hr') && BlockTypes[itemType]) {
264+
} else if ((itemType.indexOf('_open') !== -1 || RemarkableSingletons.includes[itemType]) && BlockTypes[itemType]) {
258265
var depth = 0;
259266
var block;
260267

0 commit comments

Comments
 (0)