@digipair/skill-markdown-manager 0.120.0
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/README.md +7 -0
- package/dist/index.cjs.js +42 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +40 -0
- package/dist/schema.fr.json +56 -0
- package/dist/schema.json +56 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/lib/skill-markdown-manager.d.ts +3 -0
- package/dist/src/lib/skill-markdown-manager.d.ts.map +1 -0
- package/package.json +33 -0
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-unused-vars */ let MarkdownManagerService = class MarkdownManagerService {
|
|
4
|
+
async splitMdIntoSections(params, _pinsSettingsList, _context) {
|
|
5
|
+
const { md } = params;
|
|
6
|
+
const lines = md.split(/\r?\n/);
|
|
7
|
+
const sections = [];
|
|
8
|
+
let currentPath = []; // hierarchical title path
|
|
9
|
+
let currentBuffer = []; // raw markdown lines
|
|
10
|
+
let firstSectionStarted = false;
|
|
11
|
+
const flush = ()=>{
|
|
12
|
+
if (currentPath.length === 0) return;
|
|
13
|
+
const sectionContent = currentBuffer.join("\n").trim();
|
|
14
|
+
sections.push({
|
|
15
|
+
title: currentPath.join(" >> "),
|
|
16
|
+
content: sectionContent
|
|
17
|
+
});
|
|
18
|
+
currentBuffer = [];
|
|
19
|
+
};
|
|
20
|
+
for (const line of lines){
|
|
21
|
+
const titleMatch = /^(#+)\s+(.*)$/.exec(line);
|
|
22
|
+
if (titleMatch) {
|
|
23
|
+
const level = titleMatch[1].length;
|
|
24
|
+
const title = titleMatch[2].trim();
|
|
25
|
+
// close previous section
|
|
26
|
+
if (firstSectionStarted) flush();
|
|
27
|
+
firstSectionStarted = true;
|
|
28
|
+
// update hierarchy depth
|
|
29
|
+
currentPath = currentPath.slice(0, level - 1);
|
|
30
|
+
currentPath[level - 1] = title;
|
|
31
|
+
} else {
|
|
32
|
+
if (firstSectionStarted) currentBuffer.push(line);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// flush last section
|
|
36
|
+
flush();
|
|
37
|
+
return sections;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const splitMdIntoSections = (params, pinsSettingsList, context)=>new MarkdownManagerService().splitMdIntoSections(params, pinsSettingsList, context);
|
|
41
|
+
|
|
42
|
+
exports.splitMdIntoSections = splitMdIntoSections;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/index";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-unused-vars */ let MarkdownManagerService = class MarkdownManagerService {
|
|
2
|
+
async splitMdIntoSections(params, _pinsSettingsList, _context) {
|
|
3
|
+
const { md } = params;
|
|
4
|
+
const lines = md.split(/\r?\n/);
|
|
5
|
+
const sections = [];
|
|
6
|
+
let currentPath = []; // hierarchical title path
|
|
7
|
+
let currentBuffer = []; // raw markdown lines
|
|
8
|
+
let firstSectionStarted = false;
|
|
9
|
+
const flush = ()=>{
|
|
10
|
+
if (currentPath.length === 0) return;
|
|
11
|
+
const sectionContent = currentBuffer.join("\n").trim();
|
|
12
|
+
sections.push({
|
|
13
|
+
title: currentPath.join(" >> "),
|
|
14
|
+
content: sectionContent
|
|
15
|
+
});
|
|
16
|
+
currentBuffer = [];
|
|
17
|
+
};
|
|
18
|
+
for (const line of lines){
|
|
19
|
+
const titleMatch = /^(#+)\s+(.*)$/.exec(line);
|
|
20
|
+
if (titleMatch) {
|
|
21
|
+
const level = titleMatch[1].length;
|
|
22
|
+
const title = titleMatch[2].trim();
|
|
23
|
+
// close previous section
|
|
24
|
+
if (firstSectionStarted) flush();
|
|
25
|
+
firstSectionStarted = true;
|
|
26
|
+
// update hierarchy depth
|
|
27
|
+
currentPath = currentPath.slice(0, level - 1);
|
|
28
|
+
currentPath[level - 1] = title;
|
|
29
|
+
} else {
|
|
30
|
+
if (firstSectionStarted) currentBuffer.push(line);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// flush last section
|
|
34
|
+
flush();
|
|
35
|
+
return sections;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const splitMdIntoSections = (params, pinsSettingsList, context)=>new MarkdownManagerService().splitMdIntoSections(params, pinsSettingsList, context);
|
|
39
|
+
|
|
40
|
+
export { splitMdIntoSections };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"openapi": "3.0.0",
|
|
3
|
+
"info": {
|
|
4
|
+
"title": "@digipair/skill-markdown-manager",
|
|
5
|
+
"summary": "Gestionnaire Markdown",
|
|
6
|
+
"description": "Traiter des markdown, découpage, ...",
|
|
7
|
+
"version": "0.1.0",
|
|
8
|
+
"x-icon": "đź“„"
|
|
9
|
+
},
|
|
10
|
+
"paths": {
|
|
11
|
+
"/splitMdIntoSections": {
|
|
12
|
+
"post": {
|
|
13
|
+
"tags": [
|
|
14
|
+
"service"
|
|
15
|
+
],
|
|
16
|
+
"summary": "Découpe le markdown en sections par rapport aux titres, source docx",
|
|
17
|
+
"parameters": [
|
|
18
|
+
{
|
|
19
|
+
"name": "md",
|
|
20
|
+
"summary": "Md",
|
|
21
|
+
"required": true,
|
|
22
|
+
"description": "Markdown à découper en sections",
|
|
23
|
+
"schema": {
|
|
24
|
+
"type": "string"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"x-events": [],
|
|
29
|
+
"responses": {
|
|
30
|
+
"200": {
|
|
31
|
+
"description": "Markdown découpé en sections",
|
|
32
|
+
"content": {
|
|
33
|
+
"application/json": {
|
|
34
|
+
"schema": {
|
|
35
|
+
"type": "array",
|
|
36
|
+
"items": {
|
|
37
|
+
"type": "object",
|
|
38
|
+
"properties": {
|
|
39
|
+
"title": {"type": "string"},
|
|
40
|
+
"content": {"type": "string"}
|
|
41
|
+
},
|
|
42
|
+
"required": ["title", "content"]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"components": {
|
|
53
|
+
"schemas": {}
|
|
54
|
+
},
|
|
55
|
+
"x-scene-blocks": {}
|
|
56
|
+
}
|
package/dist/schema.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"openapi": "3.0.0",
|
|
3
|
+
"info": {
|
|
4
|
+
"title": "@digipair/skill-markdown-manager",
|
|
5
|
+
"summary": "Markdown manager",
|
|
6
|
+
"description": "This skill allows processing on Markdown.",
|
|
7
|
+
"version": "0.1.0",
|
|
8
|
+
"x-icon": "đź“„"
|
|
9
|
+
},
|
|
10
|
+
"paths": {
|
|
11
|
+
"/splitMdIntoSections": {
|
|
12
|
+
"post": {
|
|
13
|
+
"tags": [
|
|
14
|
+
"service"
|
|
15
|
+
],
|
|
16
|
+
"summary": "split markdown into sections using its headings, source docx",
|
|
17
|
+
"parameters": [
|
|
18
|
+
{
|
|
19
|
+
"name": "md",
|
|
20
|
+
"summary": "Md",
|
|
21
|
+
"required": true,
|
|
22
|
+
"description": "Markdown to split into sections",
|
|
23
|
+
"schema": {
|
|
24
|
+
"type": "string"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"x-events": [],
|
|
29
|
+
"responses": {
|
|
30
|
+
"200": {
|
|
31
|
+
"description": "Markdown split into sections",
|
|
32
|
+
"content": {
|
|
33
|
+
"application/json": {
|
|
34
|
+
"schema": {
|
|
35
|
+
"type": "array",
|
|
36
|
+
"items": {
|
|
37
|
+
"type": "object",
|
|
38
|
+
"properties": {
|
|
39
|
+
"title": {"type": "string"},
|
|
40
|
+
"content": {"type": "string"}
|
|
41
|
+
},
|
|
42
|
+
"required": ["title", "content"]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"components": {
|
|
53
|
+
"schemas": {}
|
|
54
|
+
},
|
|
55
|
+
"x-scene-blocks": {}
|
|
56
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-markdown-manager.d.ts","sourceRoot":"","sources":["../../../src/lib/skill-markdown-manager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAmDhD,eAAO,MAAM,mBAAmB,GAAI,QAAQ,GAAG,EAAE,kBAAkB,YAAY,EAAE,EAAE,SAAS,GAAG,iBACV,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@digipair/skill-markdown-manager",
|
|
3
|
+
"version": "0.120.0",
|
|
4
|
+
"main": "./dist/index.cjs.js",
|
|
5
|
+
"module": "./dist/index.esm.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"digipair",
|
|
9
|
+
"service",
|
|
10
|
+
"tool"
|
|
11
|
+
],
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.esm.js",
|
|
16
|
+
"default": "./dist/index.cjs.js"
|
|
17
|
+
},
|
|
18
|
+
"./index.esm.js": "./dist/index.esm.js",
|
|
19
|
+
"./index.cjs.js": "./dist/index.cjs.js",
|
|
20
|
+
"./package.json": "./package.json",
|
|
21
|
+
"./schema.json": "./dist/schema.json",
|
|
22
|
+
"./schema.fr.json": "./dist/schema.fr.json"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"README.md",
|
|
27
|
+
"package.json"
|
|
28
|
+
],
|
|
29
|
+
"nx": {
|
|
30
|
+
"name": "skill-markdown-manager"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {}
|
|
33
|
+
}
|