Skip to content

Commit

Permalink
fix regex to also match when has \n at the end
Browse files Browse the repository at this point in the history
  • Loading branch information
renatocaliari committed May 3, 2022
1 parent d7b19e2 commit 89ff93c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import '@logseq/libs';

const quickReferenceRegEx = /^(\#*? ?)Quick References$/;
const quickReferenceRegEx = /^^(\#*? ?)Quick References(\\n)?/;

async function insertQuickReference(e, idxReference) {
let foundBlockQuickReference = false;
let foundReference = false;
let pageContentsBlocks = await logseq.Editor.getPageBlocksTree('Contents');
let quickReference = '';

console.log('pageContentsBlocks:', pageContentsBlocks);
let blockQuickReference = pageContentsBlocks.find((b) => quickReferenceRegEx.test(b.content));

if (blockQuickReference) {
Expand Down

0 comments on commit 89ff93c

Please sign in to comment.