You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
length(ctx.preserve_space)>0&&pop!(ctx.preserve_space) # pop the previous context
361
+
returnRaw(data) # RawDocument
362
+
end
363
+
j =length(ctx.preserve_space) ==0||!(ctx.preserve_space[end]) ? k : j
315
364
c =Char(o.data[j])
365
+
d =Char(data[findprev(==(UInt8('<')), data, j)+1])
316
366
i = j -1
317
367
next_type = type
318
-
if c !=='>'# text
368
+
if c !=='>'|| type === RawElementClose && d ==='/'&&length(ctx.preserve_space) >0&& (ctx.preserve_space[end]) # text or empty whitespace
319
369
type = RawText
320
-
i =findprev(==(UInt8('>')), data, j) +1
321
-
i =findnext(!isspace, data, i) # "lstrip"
322
-
elseif c ==='>'
323
-
c2 =Char(o.data[j -1])
324
-
if c2 ==='-'
325
-
type = RawComment
326
-
i =findprev(Vector{UInt8}("<--"), data, j)[1]
327
-
elseif c2 ===']'
328
-
type = RawCData
329
-
i =findprev(Vector{UInt8}("<![CData["), data, j)[1]
330
-
elseif c2 ==='?'
331
-
i =findprev(Vector{UInt8}("<?"), data, j)[1]
332
-
ifget_name(data, i +2)[1] =="xml"
333
-
type = RawDeclaration
370
+
i=findprev(==(UInt8('>')), data, j) +1
371
+
i =length(ctx.preserve_space) ==0||!(ctx.preserve_space[end]) ?findprev(!isspace, data, i) : i # If preserving whitespace, retain leading and trailing whitespace
372
+
else
373
+
j=k
374
+
i=k-1
375
+
if c ==='>'
376
+
c2 =Char(o.data[j -1])
377
+
if c2 ==='-'
378
+
type = RawComment
379
+
i =findprev(Vector{UInt8}("<--"), data, j)[1]
380
+
elseif c2 ===']'
381
+
type = RawCData
382
+
i =findprev(Vector{UInt8}("<![CData["), data, j)[1]
383
+
elseif c2 ==='?'
384
+
i =findprev(Vector{UInt8}("<?"), data, j)[1]
385
+
ifget_name(data, i +2)[1] =="xml"
386
+
type = RawDeclaration
387
+
else
388
+
type = RawProcessingInstruction
389
+
end
334
390
else
335
-
type = RawProcessingInstruction
336
-
end
391
+
i =findprev(==(UInt8('<')), data, j)
392
+
char =Char(data[i+1])
393
+
if char ==='/'
394
+
type = RawElementClose
395
+
elseif char ==='!'
396
+
type = DTD
397
+
elseifisletter(char) || char ==='_'
398
+
type =Char(o.data[j -2]) ==='/'? RawElementSelfClosed : RawElementOpen
399
+
else
400
+
error("Should be unreachable. Unexpected data: <$char ... $c3$c2$c1>.")
401
+
end
402
+
end
337
403
else
338
-
i =findprev(==(UInt8('<')), data, j)
339
-
char =Char(data[i+1])
340
-
if char ==='/'
341
-
type = RawElementClose
342
-
elseif char ==='!'
343
-
type = DTD
344
-
elseifisletter(char) || char ==='_'
345
-
type =Char(o.data[j -2]) ==='/'? RawElementSelfClosed : RawElementOpen
346
-
else
347
-
error("Should be unreachable. Unexpected data: <$char ... $c3$c2$c1>.")
348
-
end
404
+
error("Unreachable reached in XML.prev")
349
405
end
350
-
else
351
-
error("Unreachable reached in XML.prev")
352
406
end
353
407
if type !== RawElementOpen && next_type === RawElementClose
354
408
depth +=1
355
409
elseif type == RawElementOpen && next_type !== RawElementClose
0 commit comments