parsav  Diff

Differences From Artifact [926ec15b69]:

To Artifact [e99ea3e622]:


48
49
50
51
52
53
54
55
56
57
58
59

60
61
62
63
64
65
66
67
68


69
70
71
72
73
74
75
		do return l+i end
	::nexti::end
end

local terra scanline_wordend(l: rawstring, max: intptr, n: rawstring, nc: intptr)
	var sl = scanline(l,max,n,nc)
	if sl == nil then return nil else sl = sl + nc end
	if sl >= l+max or isws(@sl) then return sl-nc end
	return nil
end

terra m.html(input: pstr, firstline: bool)

	if input.ct == 0 then input.ct = lib.str.sz(input.ptr) end

	var md = lib.html.sanitize(input,false)

	var styled: lib.str.acc styled:init(md.ct)

	do var i = 0 while i < md.ct do
		var wordstart = (i == 0 or isws(md.ptr[i-1]))
		var wordend = (i == md.ct - 1 or isws(md.ptr[i+1]))



		var here = md.ptr + i
		var rem = md.ct - i
		if @here == @'[' then
			var sep = scanline(here,rem, '](', 2)
			var term = scanline(sep+2,rem - ((sep+2)-here), ')', 1)
			if sep ~= nil and term ~= nil then







|




>







|
|
>
>







48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
		do return l+i end
	::nexti::end
end

local terra scanline_wordend(l: rawstring, max: intptr, n: rawstring, nc: intptr)
	var sl = scanline(l,max,n,nc)
	if sl == nil then return nil else sl = sl + nc end
	if sl >= l+max or not isws(@(sl-1)) then return sl-nc end
	return nil
end

terra m.html(input: pstr, firstline: bool)
	if input.ptr == nil then return pstr.null() end
	if input.ct == 0 then input.ct = lib.str.sz(input.ptr) end

	var md = lib.html.sanitize(input,false)

	var styled: lib.str.acc styled:init(md.ct)

	do var i = 0 while i < md.ct do
		--var wordstart = (i == 0 or isws(md.ptr[i-1]))
		--var wordend = (i == md.ct - 1 or isws(md.ptr[i+1]))
		var wordstart = (i + 1 < md.ct and not isws(md.ptr[i+1]))
		var wordend = (i == md.ct - 1 or not isws(md.ptr[i-1]))

		var here = md.ptr + i
		var rem = md.ct - i
		if @here == @'[' then
			var sep = scanline(here,rem, '](', 2)
			var term = scanline(sep+2,rem - ((sep+2)-here), ')', 1)
			if sep ~= nil and term ~= nil then