@iebh/reflib 2.3.3 → 2.3.6

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.
@@ -1,37 +1,38 @@
1
1
  {
2
- // Use IntelliSense to learn about possible attributes.
3
- // Hover to view descriptions of existing attributes.
4
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
- "version": "0.2.0",
6
- "configurations": [
7
- {
8
- "type": "node",
9
- "request": "launch",
10
- "name": "Run npm test:browser",
11
- "runtimeExecutable": "/home/connor/.nvm/versions/node/v20.12.2/bin/npm",
12
- "runtimeArgs": [
13
- "run",
14
- "test:browser"
15
- ],
16
- "console": "integratedTerminal"
17
- },
18
- {
19
- "name": "Launch Chrome against localhost",
20
- "type": "chrome",
21
- "request": "launch",
22
- "url": "http://localhost:3000",
23
- "webRoot": "${workspaceFolder}/test/browser"
24
- },
25
- {
26
- "name": "Attach to Vite Server",
27
- "type": "node",
28
- "request": "attach",
29
- "port": 9229,
30
- "address": "localhost",
31
- "restart": true,
32
- "skipFiles": [
33
- "<node_internals>/**"
34
- ]
35
- }
36
- ]
2
+ "version": "0.2.0",
3
+ "configurations": [
4
+ {
5
+ "type": "node",
6
+ "request": "launch",
7
+ "name": "Debug Vite Server",
8
+ "runtimeExecutable": "/home/connor/.nvm/versions/node/v20.12.2/bin/npm",
9
+ "runtimeArgs": ["run", "dev"],
10
+ "cwd": "${workspaceFolder}/test/browser",
11
+ "console": "integratedTerminal",
12
+ "env": {
13
+ "VITE_DEV_SERVER_URL": "http://localhost:3000"
14
+ }
15
+ },
16
+ {
17
+ "name": "Debug in Chrome",
18
+ "type": "chrome",
19
+ "request": "launch",
20
+ "url": "http://localhost:3000",
21
+ "webRoot": "${workspaceFolder}",
22
+ "sourceMaps": true,
23
+ "sourceMapPathOverrides": {
24
+ "/__vite-root/*": "${webRoot}/*",
25
+ "/@fs/*": "*",
26
+ "/@vite-root/*": "${webRoot}/*",
27
+ "/src/*": "${webRoot}/src/*",
28
+ "/modules/*": "${webRoot}/modules/*"
29
+ }
30
+ }
31
+ ],
32
+ "compounds": [
33
+ {
34
+ "name": "Debug Vite + Chrome",
35
+ "configurations": ["Debug Vite Server", "Debug in Chrome"]
36
+ }
37
+ ]
37
38
  }
@@ -1,4 +1,3 @@
1
- import camelCase from '../../shared/camelCase.js';
2
1
  import Emitter from '../../shared/emitter.js';
3
2
  import CacxParser from '@iebh/cacx';
4
3
 
@@ -7,20 +6,21 @@ export class WritableStream {
7
6
  this.emitter = Emitter();
8
7
  this.parser = new CacxParser({
9
8
  collect: false,
9
+ reAttrSegment: /(?<key>[a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*(?<escape>["'])(?<val>.*?)\k<escape>)?/ig,
10
10
  onTagOpen: (node) => {
11
- const name = camelCase(node.tag);
11
+ const name = node.tag;
12
12
  const attrs = node.attrs || {};
13
13
  this.emitter.emit('opentag', name, attrs);
14
14
  },
15
15
  onTagClose: (node) => {
16
- const name = camelCase(node.tag);
16
+ const name = node.tag;
17
+ // Emit text event before closing the tag
18
+ if (node.text && node.text.trim()) {
19
+ this.emitter.emit('text', node.text.trim());
20
+ }
17
21
  this.emitter.emit('closetag', name);
18
22
  },
19
- onAttr: (key, val/*, options*/) => {
20
- // This method is called for each attribute, so we don't need to do anything here
21
- return { [key]: val };
22
- },
23
- flattenText: true,
23
+ flattenText: false,
24
24
  keyText: 'text',
25
25
  keyAttrs: 'attrs',
26
26
  });
@@ -34,23 +34,18 @@ export class WritableStream {
34
34
 
35
35
  write(data) {
36
36
  this.parser.append(data).exec();
37
-
38
- // Emit text events for any text nodes
39
- const currentNode = this.parser.stack.at(-1);
40
- if (currentNode && currentNode.text) {
41
- const text = currentNode.text.trim();
42
- if (text) {
43
- this.emitter.emit('text', text);
44
- }
45
- // Clear the text to avoid emitting it multiple times
46
- currentNode.text = '';
47
- }
48
37
  }
49
38
 
50
39
  end() {
51
40
  // Process any remaining data
52
41
  this.parser.exec();
53
42
 
43
+ // Emit text event for the last node if it has text
44
+ const lastNode = this.parser.stack.at(-1);
45
+ if (lastNode && lastNode.text && lastNode.text.trim()) {
46
+ this.emitter.emit('text', lastNode.text.trim());
47
+ }
48
+
54
49
  // Emit end event
55
50
  this.emitter.emit('end');
56
51
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iebh/reflib",
3
- "version": "2.3.3",
3
+ "version": "2.3.6",
4
4
  "description": "Reference / Citation reference library utilities",
5
5
  "scripts": {
6
6
  "lint": "eslint lib modules shared test",
@@ -53,7 +53,7 @@
53
53
  "vite-plugin-replace": "^0.1.1"
54
54
  },
55
55
  "dependencies": {
56
- "@iebh/cacx": "^1.0.0",
56
+ "@iebh/cacx": "^1.0.2",
57
57
  "htmlparser2": "^9.0.0",
58
58
  "JSONStream": "^1.3.5",
59
59
  "mitt": "^3.0.1"