aboutsummaryrefslogtreecommitdiff
path: root/src/rehype/admonition-title-to-heading-before-toc.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/rehype/admonition-title-to-heading-before-toc.js')
-rw-r--r--src/rehype/admonition-title-to-heading-before-toc.js49
1 files changed, 0 insertions, 49 deletions
diff --git a/src/rehype/admonition-title-to-heading-before-toc.js b/src/rehype/admonition-title-to-heading-before-toc.js
deleted file mode 100644
index 2770610d..00000000
--- a/src/rehype/admonition-title-to-heading-before-toc.js
+++ /dev/null
@@ -1,49 +0,0 @@
-import {visit} from 'unist-util-visit';
-import {u} from 'unist-builder'
-
-function createHeadingNode(depth, text) {
- return {
- type: 'heading',
- depth: depth,
- children: [{ type: 'text', value: text }],
- };
-}
-
-const plugin = (options) => {
- const transformer = async (ast) => {
- let hId = null;
- let hContent = null;
- let offset = 0;
- visit(ast, 'element', (node, index, parent) => {
- if(node && node.tagName == "admonition") {
- let headingNode = u('heading', { depth: 4 }, [
- u('text', 'New Heading')
- ]);
- parent.children.splice(index + offset, 0, {type: 'element', tagName: 'h4', children:[{type: 'text', value: 'テスト'}]});
- offset++;
- // if (/^h[3-6]$/.test(node.tagName) && node.properties && node.properties.id) {
- // h3~h6のタグを見つけたら
- /*
- hId = node.properties.id;
- hContent = node.children && node.children[0] ? node.children[0].value : '';
- // h3~h6タグの隣にあるdivタグを探す
- const nextNode = parent.children[index + 1];
- if (nextNode && nextNode.tagName === 'admonition') {
- // 該当のdiv要素を見つけたらHタグの内容とline-5の#以降の文字列が一致した場合
- const contentAfterHash = nextNode.properties.title ? nextNode.properties.title.replace(/^#+/, '').trim() : '';
-
- if (contentAfterHash === hContent.trim()) {
- // Hタグのidを取得しそれをdivのidに設定
- nextNode.properties.id = hId;
- // Hタグを削除
- parent.children.splice(index, 1);
- }
- }*/
-// }
- }
- });
- };
- return transformer;
-};
-
-export default plugin; \ No newline at end of file