@remigius42/morg 0.9.1 → 0.9.2
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.
|
@@ -295,13 +295,17 @@ function writeOrgBlock(block, vanilla = false) {
|
|
|
295
295
|
function writeOutline({ page, blocks }, writeBlock) {
|
|
296
296
|
return [...page, ...blocks.map(writeBlock)].join("\n").concat("\n");
|
|
297
297
|
}
|
|
298
|
-
// a
|
|
299
|
-
|
|
298
|
+
// a table or a rule, which Logseq reads on a headline's line
|
|
299
|
+
const TITLE_ELEMENT_RE = /^(\||-{5,}\s*$)/;
|
|
300
|
+
// a block's title is a headline's, inline text but for a table or a
|
|
301
|
+
// rule; converted with the lines below it, it must not read as a list,
|
|
300
302
|
// a headline or a fixed-width line, so an escape the core drops keeps
|
|
301
303
|
// it text (ADR 0006)
|
|
302
304
|
function inlineTitle(block) {
|
|
303
305
|
const [title = "", ...rest] = block.content;
|
|
304
|
-
return !block.metaFirst &&
|
|
306
|
+
return !block.metaFirst &&
|
|
307
|
+
!TITLE_ELEMENT_RE.test(title) &&
|
|
308
|
+
readsAsLineSyntax(title)
|
|
305
309
|
? [`${ZERO_WIDTH_SPACE}${title}`, ...rest]
|
|
306
310
|
: block.content;
|
|
307
311
|
}
|
|
@@ -421,13 +425,15 @@ function writeVanillaMarkdownOutline({ page, blocks }, context) {
|
|
|
421
425
|
export function orgOutlineToMarkdown(org, convert, presets, context) {
|
|
422
426
|
const { page, blocks } = readOrgOutline(org, context.side === "output");
|
|
423
427
|
const vanilla = context.side === "input";
|
|
428
|
+
// read as Logseq org, a block's title is inline text (ADR 0006)
|
|
429
|
+
const inline = context.side !== "output";
|
|
424
430
|
const pageLines = vanilla ? (presets.vanillaPage?.(page) ?? page) : page;
|
|
425
431
|
const convertCarried = (fragment, preset) => convert(fragment, preset, vanilla ? presets.vanillaInline : undefined);
|
|
426
432
|
const outline = {
|
|
427
433
|
page: convertPage(pageLines, convertCarried, presets.page),
|
|
428
434
|
blocks: blocks.map(block => ({
|
|
429
435
|
...block,
|
|
430
|
-
content: convertContent(withBracedScripts(
|
|
436
|
+
content: convertContent(withBracedScripts(inline ? inlineTitle(block) : block.content), convertCarried, presets.block)
|
|
431
437
|
}))
|
|
432
438
|
};
|
|
433
439
|
return vanilla
|
|
@@ -461,7 +467,7 @@ export function markdownOutlineToOrg(markdown, convert, presets, context) {
|
|
|
461
467
|
...block,
|
|
462
468
|
content: convertMarkdownContent(block.content, convertCarried, presets.block).filter(line => line !== BRACED_SCRIPTS_LINE)
|
|
463
469
|
};
|
|
464
|
-
return
|
|
470
|
+
return context.side === "input" ? converted : dropTitleEscape(converted);
|
|
465
471
|
})
|
|
466
472
|
}, block => writeOrgBlock(block, context.side === "input"));
|
|
467
473
|
}
|