MCPcopy Index your code
hub / github.com/ether/etherpad / processNextChars

Function processNextChars

src/node/utils/ExportTxt.ts:80–179  ·  view source on GitHub ↗
(numChars: number)

Source from the content-addressed store, hash-verified

78 let idx = 0;
79
80 const processNextChars = (numChars: number) => {
81 if (numChars <= 0) {
82 return;
83 }
84
85 const ops = deserializeOps(subattribution(attribs, idx, idx + numChars));
86 idx += numChars;
87
88 for (const o of ops) {
89 let propChanged = false;
90
91 for (const a of attributes.decodeAttribString(o.attribs)) {
92 if (a in anumMap) {
93 const i = anumMap[a] as number; // i = 0 => bold, etc.
94
95 if (!propVals[i]) {
96 propVals[i] = ENTER;
97 propChanged = true;
98 } else {
99 propVals[i] = STAY;
100 }
101 }
102 }
103
104 for (let i = 0; i < propVals.length; i++) {
105 if (propVals[i] === true) {
106 propVals[i] = LEAVE;
107 propChanged = true;
108 } else if (propVals[i] === STAY) {
109 // set it back
110 propVals[i] = true;
111 }
112 }
113
114 // now each member of propVal is in {false,LEAVE,ENTER,true}
115 // according to what happens at start of span
116 if (propChanged) {
117 // leaving bold (e.g.) also leaves italics, etc.
118 let left = false;
119
120 for (let i = 0; i < propVals.length; i++) {
121 const v = propVals[i];
122
123 if (!left) {
124 if (v === LEAVE) {
125 left = true;
126 }
127 } else if (v === true) {
128 // tag will be closed and re-opened
129 propVals[i] = STAY;
130 }
131 }
132
133 const tags2close = [];
134
135 for (let i = propVals.length - 1; i >= 0; i--) {
136 if (propVals[i] === LEAVE) {
137 // emitCloseTag(i);

Callers 1

getLineTXTFunction · 0.70

Calls 3

subattributionFunction · 0.90
pushMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected