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 CHANGED
@@ -1,9 +1,32 @@
1
- # applesauce-channel
1
+ # applesauce-content
2
2
 
3
- Helper methods an queries for [NIP-28](https://github.com/nostr-protocol/nips/blob/master/28.md) Public Channels
3
+ applesauce package for parsing text note content
4
4
 
5
- ## Install
5
+ ## Example
6
6
 
7
- ```bash
8
- npm install applesauce-core applesauce-channel
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";
@@ -9,7 +9,7 @@ export const Expressions = {
9
9
  return /:([a-zA-Z0-9_-]+):/gi;
10
10
  },
11
11
  get hashtag() {
12
- return /(?:^|[^\p{L}])#([\p{L}\p{N}\p{M}]+)/gu;
12
+ return /(?<=^|[^\p{L}#])#([\p{L}\p{N}\p{M}]+)/gu;
13
13
  },
14
14
  };
15
15
  export default Expressions;
package/dist/index.d.ts CHANGED
@@ -1 +1,4 @@
1
- export * from "./text/index.js";
1
+ export * as Text from "./text/index.js";
2
+ export * as Nast from "./nast/index.js";
3
+ export * as Markdown from "./markdown/index.js";
4
+ export * as Helpers from "./helpers/index.js";
package/dist/index.js CHANGED
@@ -1 +1,4 @@
1
- export * from "./text/index.js";
1
+ export * as Text from "./text/index.js";
2
+ export * as Nast from "./nast/index.js";
3
+ export * as Markdown from "./markdown/index.js";
4
+ export * as Helpers from "./helpers/index.js";
@@ -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 = (i) => {
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 i;
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
  }
@@ -4,3 +4,4 @@ export * from "./cashu.js";
4
4
  export * from "./emoji.js";
5
5
  export * from "./parser.js";
6
6
  export * from "./hashtag.js";
7
+ export * from "./gallery.js";
@@ -4,3 +4,4 @@ export * from "./cashu.js";
4
4
  export * from "./emoji.js";
5
5
  export * from "./parser.js";
6
6
  export * from "./hashtag.js";
7
+ export * from "./gallery.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "applesauce-content",
3
- "version": "0.7.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.7.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",