Hansimov commited on
Commit
20f256e
1 Parent(s): f1bcc11

:zap: [Enhance] Prettify footnote number formats

Browse files
Files changed (1) hide show
  1. networks/stream_jsonizer.js +1 -6
networks/stream_jsonizer.js CHANGED
@@ -6,7 +6,6 @@ export function stringify_stream_bytes(bytes) {
6
 
7
  export function jsonize_stream_data(data) {
8
  var json_chunks = [];
9
- var buffer = ""
10
  data = data
11
  .replace(/^data:\s*/gm, "")
12
  .replace(/\[DONE\]/gm, "")
@@ -19,9 +18,7 @@ export function jsonize_stream_data(data) {
19
  // TODO: Single line broken into multiple chunks
20
  let json_chunk = JSON.parse(line.trim());
21
  json_chunks.push(json_chunk);
22
- buffer = ""
23
  } catch {
24
- buffer += line;
25
  console.log(`Failed to parse: ${line}`);
26
  }
27
  });
@@ -29,7 +26,5 @@ export function jsonize_stream_data(data) {
29
  }
30
 
31
  export function transform_footnote(text) {
32
- return text
33
- .replace(/\[\^(\d+)\^\]\[\d+\]/g, "[$1]")
34
- .replace(/\[(\d+)\]:\s*(.*)\s*""/g, "[$1] $2 \n");
35
  }
 
6
 
7
  export function jsonize_stream_data(data) {
8
  var json_chunks = [];
 
9
  data = data
10
  .replace(/^data:\s*/gm, "")
11
  .replace(/\[DONE\]/gm, "")
 
18
  // TODO: Single line broken into multiple chunks
19
  let json_chunk = JSON.parse(line.trim());
20
  json_chunks.push(json_chunk);
 
21
  } catch {
 
22
  console.log(`Failed to parse: ${line}`);
23
  }
24
  });
 
26
  }
27
 
28
  export function transform_footnote(text) {
29
+ return text.replace(/([\[\(])\^(\d+)\^([\]\)])/g, "<sup>$1$2$3</sup>");
 
 
30
  }