@quartz-community/remark-obsidian 2.2.3 → 2.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -16985,7 +16985,7 @@ function remarkObsidian(userOpts) {
16985
16985
  }
16986
16986
  return fragment;
16987
16987
  };
16988
- return (tree, file) => {
16988
+ const finish = (tree, file) => {
16989
16989
  const source = String(file);
16990
16990
  const marked = source.charCodeAt(0) === 65279;
16991
16991
  const text3 = marked ? source.slice(1) : source;
@@ -16993,6 +16993,28 @@ function remarkObsidian(userOpts) {
16993
16993
  if (opts.callouts) calloutMarkerTransform(tree, text3);
16994
16994
  if (marked && opts.bomOffsets) countByteOrderMark(tree);
16995
16995
  };
16996
+ let finishing = false;
16997
+ const finished = /* @__PURE__ */ new WeakSet();
16998
+ const finishOnce = (tree, file) => {
16999
+ finishing = true;
17000
+ try {
17001
+ finish(tree, file);
17002
+ } finally {
17003
+ finishing = false;
17004
+ }
17005
+ finished.add(tree);
17006
+ };
17007
+ const parser = self.parser;
17008
+ if (parser) {
17009
+ self.parser = (document, file) => {
17010
+ const tree = parser(document, file);
17011
+ if (!finishing) finishOnce(tree, file);
17012
+ return tree;
17013
+ };
17014
+ }
17015
+ return (tree, file) => {
17016
+ if (!finished.has(tree)) finishOnce(tree, file);
17017
+ };
16996
17018
  }
16997
17019
  export {
16998
17020
  COMMENT_ELEMENT,