parsav  Diff

Differences From Artifact [e99ea3e622]:

To Artifact [ad4d039b1c]:


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
...
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
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]))

................................................................................
				goto skip
			end
		end

		::fallback::styled:push(here,1) -- :/
		i = i + 1
	::skip::end end
	md:free()

	-- we make two passes: the first detects and transforms inline elements,
	-- the second carries out block-level organization

	var html: lib.str.acc html:init(styled.sz)
	var s = state {
		segt = segt.none;
		bqlvl = 0;
		curpos = md.ptr;
		blockstart = nil;
	}
	while s.curpos < md.ptr + md.ct do
		s.curpos = s.curpos + 1
	end 

		html:free() -- JUST FOR NOW
	return styled:finalize()
end

return m







|



|

|







 







|




|










|




52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
...
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
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(pool: &lib.mem.pool, 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(pool,input,false)

	var styled: lib.str.acc styled:pool(pool,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]))

................................................................................
				goto skip
			end
		end

		::fallback::styled:push(here,1) -- :/
		i = i + 1
	::skip::end end
	--md:free()

	-- we make two passes: the first detects and transforms inline elements,
	-- the second carries out block-level organization

	var html: lib.str.acc html:pool(pool,styled.sz)
	var s = state {
		segt = segt.none;
		bqlvl = 0;
		curpos = md.ptr;
		blockstart = nil;
	}
	while s.curpos < md.ptr + md.ct do
		s.curpos = s.curpos + 1
	end 

		--html:free() -- JUST FOR NOW
	return styled:finalize()
end

return m