applesauce-content 0.7.0 → 0.8.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 +28 -5
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.js +1 -0
- package/dist/helpers/regexp.js +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -1
- package/dist/text/gallery.js +4 -2
- package/dist/text/index.d.ts +1 -0
- package/dist/text/index.js +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,9 +1,32 @@
|
|
|
1
|
-
# applesauce-
|
|
1
|
+
# applesauce-content
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
applesauce package for parsing text note content
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Example
|
|
6
6
|
|
|
7
|
-
```
|
|
8
|
-
|
|
7
|
+
```ts
|
|
8
|
+
import { getParsedTextContent } from "applesauce-content/text";
|
|
9
|
+
|
|
10
|
+
const stringContent = `
|
|
11
|
+
hello nostr!
|
|
12
|
+
nostr:npub180cvv07tjdrrgpa0j7j7tmnyl2yr6yr7l8j4s3evf6u64th6gkwsyjh6w6
|
|
13
|
+
`;
|
|
14
|
+
const ats = getParsedTextContent(stringContent);
|
|
15
|
+
|
|
16
|
+
console.log(ats);
|
|
17
|
+
/*
|
|
18
|
+
{
|
|
19
|
+
type: 'root',
|
|
20
|
+
event: undefined,
|
|
21
|
+
children: [
|
|
22
|
+
{ type: 'text', value: 'hello nostr!' },
|
|
23
|
+
{ type: 'text', value: '\n' },
|
|
24
|
+
{
|
|
25
|
+
type: 'mention',
|
|
26
|
+
decoded: [Object],
|
|
27
|
+
encoded: 'npub180cvv07tjdrrgpa0j7j7tmnyl2yr6yr7l8j4s3evf6u64th6gkwsyjh6w6'
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
*/
|
|
9
32
|
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./regexp.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./regexp.js";
|
package/dist/helpers/regexp.js
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/text/gallery.js
CHANGED
|
@@ -3,7 +3,7 @@ import { convertToUrl, getURLFilename, IMAGE_EXT } from "applesauce-core/helpers
|
|
|
3
3
|
export function galleries(types = IMAGE_EXT) {
|
|
4
4
|
return (tree) => {
|
|
5
5
|
let links = [];
|
|
6
|
-
const commit = (
|
|
6
|
+
const commit = (index) => {
|
|
7
7
|
// only create a gallery if there are more than a single image
|
|
8
8
|
if (links.length > 1) {
|
|
9
9
|
const start = tree.children.indexOf(links[0]);
|
|
@@ -16,7 +16,7 @@ export function galleries(types = IMAGE_EXT) {
|
|
|
16
16
|
}
|
|
17
17
|
else {
|
|
18
18
|
links = [];
|
|
19
|
-
return
|
|
19
|
+
return index;
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
for (let i = 0; i < tree.children.length; i++) {
|
|
@@ -42,5 +42,7 @@ export function galleries(types = IMAGE_EXT) {
|
|
|
42
42
|
i = commit(i);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
+
// Do one finally commit, just in case a link is the last element in the list
|
|
46
|
+
commit(tree.children.length);
|
|
45
47
|
};
|
|
46
48
|
}
|
package/dist/text/index.d.ts
CHANGED
package/dist/text/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "applesauce-content",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Unified plugins for processing event content",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@types/hast": "^3.0.4",
|
|
41
41
|
"@types/mdast": "^4.0.4",
|
|
42
42
|
"@types/unist": "^3.0.3",
|
|
43
|
-
"applesauce-core": "^0.
|
|
43
|
+
"applesauce-core": "^0.8.0",
|
|
44
44
|
"linkifyjs": "^4.1.3",
|
|
45
45
|
"mdast-util-find-and-replace": "^3.0.1",
|
|
46
46
|
"nostr-tools": "^2.7.2",
|