obsidian-lineage icon indicating copy to clipboard operation
obsidian-lineage copied to clipboard

A question about empty line

Open KuiyueRO opened this issue 8 months ago • 1 comments

I noticed that there is code like this in main.js, I would like to ask why empty lines should be replaced with &nbsp·.

thanks

// src/view/actions/markdown-preview-action.ts
var markdownPreviewAction = (element2, nodeId) => {
  const plugin = getPlugin();
  const view = getView();
  const store = view.documentStore;
  const render = (content) => {
    if (view && element2) {
      element2.empty();
      if (content.length > 0 && !/^> /.test(content)) {
        content = content.replace(/^$/gm, " ");
      }
      import_obsidian3.MarkdownRenderer.render(
        plugin.app,
        content,
        element2,
        store.getValue().file.path,
        view
      );
    }
  };
  const $content = contentStore(view, nodeId);
  const unsub = $content.subscribe((content) => {
    render(content);
  });
  return {
    destroy: () => {
      unsub();
    }
  };
};

KuiyueRO avatar May 25 '24 16:05 KuiyueRO