uniorg-rehype
Advanced tools
Comparing version 0.3.1 to 0.4.0
@@ -63,2 +63,3 @@ "use strict"; | ||
function toHast(node) { | ||
var _a; | ||
if (Array.isArray(node)) { | ||
@@ -77,3 +78,4 @@ return (node | ||
return { type: 'root', children: toHast(org.children) }; | ||
case 'headline': { | ||
case 'section': { | ||
const headline = org.children[0]; | ||
// TODO: support other options that prevent export: | ||
@@ -85,4 +87,8 @@ // - org-export-exclude-tags | ||
// - #+SELECTED_TAGS: | ||
if (org.commented || org.tags.includes('noexport')) | ||
if (headline.commented || headline.tags.includes('noexport')) { | ||
return null; | ||
} | ||
return toHast(org.children); | ||
} | ||
case 'headline': { | ||
const intersperse = (items, sep) => items.flatMap((e) => [sep, e]).slice(1); | ||
@@ -107,9 +113,4 @@ const todo = org.todoKeyword | ||
: null; | ||
return [ | ||
h(org, `h${org.level}`, {}, [todo, priority, toHast(org.title), tags].filter((x) => x)), | ||
...toHast(org.children), | ||
]; | ||
return h(org, `h${org.level}`, {}, [todo, priority, toHast(org.children), tags].filter((x) => x)); | ||
} | ||
case 'section': | ||
return toHast(org.children); | ||
case 'plain-list': | ||
@@ -125,7 +126,7 @@ if (org.listType === 'unordered') { | ||
} | ||
case 'item': | ||
if (org.tag !== null) { | ||
case 'list-item': | ||
if (((_a = org.children[0]) === null || _a === void 0 ? void 0 : _a.type) === 'list-item-tag') { | ||
return [ | ||
h(org, 'dt', {}, toHast(org.tag)), | ||
h(org, 'dd', {}, toHast(org.children)), | ||
h(org, 'dt', {}, toHast(org.children[0].children)), | ||
h(org, 'dd', {}, toHast(org.children.slice(1))), | ||
]; | ||
@@ -132,0 +133,0 @@ } |
@@ -192,3 +192,4 @@ "use strict"; | ||
.use(() => (node) => { | ||
const headline = node.children[0]; | ||
// org-data > section > headline | ||
const headline = node.children[0].children[0]; | ||
headline.data = { hProperties: { id: 'my-custom-id' } }; | ||
@@ -195,0 +196,0 @@ }) |
{ | ||
"name": "uniorg-rehype", | ||
"version": "0.3.1", | ||
"version": "0.4.0", | ||
"description": "uniorg plugin to transform to rehype", | ||
@@ -48,4 +48,4 @@ "keywords": [ | ||
"unified": "^9.2.0", | ||
"uniorg": "^0.3.0", | ||
"uniorg-parse": "^0.3.1" | ||
"uniorg": "^0.4.0", | ||
"uniorg-parse": "^0.4.0" | ||
}, | ||
@@ -56,3 +56,3 @@ "dependencies": { | ||
}, | ||
"gitHead": "9606f8482e4fd9229e80cafe4d40c9e0ce840a9e" | ||
"gitHead": "1b493e95f00096108fbd2f3e56c739ba0458483d" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
71528
507