我需要在排版期间有效地检测输入流中的 URL。
URL 检测器将成为排版流程的一部分。它应该一次接受一个字符作为输入,并且一次应该输出一个字符以及该字符所属的 URL。它可以为前瞻缓冲文本以执行此操作。
例如,如果输入流是"Hello http://foo.com World"
,则输出应该是:
"H": ""
"e": ""
"l": ""
"l": ""
"o": ""
" ": ""
"h": "http://foo.com"
"t": "http://foo.com"
"t": "http://foo.com"
"p": "http://foo.com"
":": "http://foo.com"
"/": "http://foo.com"
"/": "http://foo.com"
"f": "http://foo.com"
"o": "http://foo.com"
"o": "http://foo.com"
".": "http://foo.com"
"c": "http://foo.com"
"o": "http://foo.com"
"m": "http://foo.com"
" ": ""
"W": ""
"o": ""
"r": ""
"l": ""
"d": ""
可以根据需要让 Ragel 流式传输输入和输出吗?
顺便说一句,这里有一个 (Java) ragel URL 解析器,我正在考虑将其用作起点。