| 340 |
ch : string; |
ch : string; |
| 341 |
db : boolean; |
db : boolean; |
| 342 |
len : integer; |
len : integer; |
| 343 |
|
rink : string; |
| 344 |
begin |
begin |
| 345 |
//s に本文を全部入れる |
//s に本文を全部入れる |
| 346 |
s := Body; |
s := Body; |
| 358 |
while Length(s) > 2 do begin |
while Length(s) > 2 do begin |
| 359 |
pmin := Length(s) + 1; |
pmin := Length(s) + 1; |
| 360 |
i := Length(token); |
i := Length(token); |
| 361 |
for j := 0 to Length(token) - 1 do begin |
for j := 0 to 5 do begin |
| 362 |
pos := AnsiPos(token[j], s); |
pos := AnsiPos(token[j], s); |
| 363 |
if pos <> 0 then begin |
if pos <> 0 then begin |
| 364 |
if pos < pmin then begin |
if pos < pmin then begin |
| 387 |
end else if (pos <> 0) then begin |
end else if (pos <> 0) then begin |
| 388 |
pmin := pos; |
pmin := pos; |
| 389 |
end; |
end; |
| 390 |
Result := Result + Copy(s, 1, pmin + 3); |
rink := Copy(s, 1, pmin + 3); |
| 391 |
|
Result := Result + rink; |
| 392 |
Delete(s, 1, pmin + 3); |
Delete(s, 1, pmin + 3); |
| 393 |
|
|
| 394 |
|
pmin := Length(rink); |
| 395 |
|
i := Length(token); |
| 396 |
|
for j := 0 to 3 do begin |
| 397 |
|
pos := AnsiPos(token[j], rink); |
| 398 |
|
if pos <> 0 then begin |
| 399 |
|
if pos < pmin then begin |
| 400 |
|
//どれでヒットしたか保存 |
| 401 |
|
i := j; |
| 402 |
|
//最小値を更新 |
| 403 |
|
pmin := pos; |
| 404 |
|
end; |
| 405 |
|
end; |
| 406 |
|
end; |
| 407 |
|
// レスアンカーが含まれていたら,が続く限りアンカーとして扱う |
| 408 |
|
if i <= 3 then begin |
| 409 |
|
cm := false; |
| 410 |
|
j := 1 ; |
| 411 |
|
if (s[j] = ',') or (ZenToHan(Copy(s, j ,2)) = ',') then begin |
| 412 |
|
cm := true; |
| 413 |
|
db := false; |
| 414 |
|
sw := false; |
| 415 |
|
Inc(j); |
| 416 |
|
No := ''; |
| 417 |
|
len := Length(s); |
| 418 |
|
while cm do begin |
| 419 |
|
while (j <= len) do begin |
| 420 |
|
if (ByteType(s, j) = mbSingleByte) then begin |
| 421 |
|
//1byte文字 |
| 422 |
|
ch := s[j]; |
| 423 |
|
Inc(j); |
| 424 |
|
db := false; |
| 425 |
|
end else begin |
| 426 |
|
//2byte文字 |
| 427 |
|
ch := ZenToHan(Copy(s, j, 2)); |
| 428 |
|
Inc(j, 2); |
| 429 |
|
db := true; |
| 430 |
|
end; |
| 431 |
|
if System.Pos(ch, SN) > 0 then begin |
| 432 |
|
No := No + ch; |
| 433 |
|
end else if (ch = '-') then begin |
| 434 |
|
if sw then break; |
| 435 |
|
if No = '' then cm := false; |
| 436 |
|
No := No + ch; |
| 437 |
|
sw := true; |
| 438 |
|
end else begin |
| 439 |
|
break; |
| 440 |
|
end; |
| 441 |
|
end; |
| 442 |
|
//終端まで行っての終了かチェック |
| 443 |
|
if j <= len then begin |
| 444 |
|
if db then j := j - 2 |
| 445 |
|
else j := j - 1; |
| 446 |
|
end; |
| 447 |
|
//何も数字が見つからないとき |
| 448 |
|
if No = '' then begin |
| 449 |
|
Result := Result + Copy(s, 1, j - 1); |
| 450 |
|
end else begin |
| 451 |
|
separateNumber(st, et, No, '-'); |
| 452 |
|
|
| 453 |
|
if not DatToHTML then begin |
| 454 |
|
Result := Result + Format(FORMAT_LINK, |
| 455 |
|
[ParamBBS, Bbs, ParamKey, Key, ParamStart, st, ParamTo, et, ParamNoFirst, ParamTrue]); |
| 456 |
|
end else begin |
| 457 |
|
Result := Result + Format('<a href="#%s">', [st]); |
| 458 |
|
end; |
| 459 |
|
Result := Result + Copy(s, 1, j - 1) + '</a>'; |
| 460 |
|
end; |
| 461 |
|
Delete(s, 1, j - 1); |
| 462 |
|
|
| 463 |
|
if (s[j] = ',') or (ZenToHan(Copy(s, j ,2)) = ',') then begin |
| 464 |
|
cm := true; |
| 465 |
|
Inc(j); |
| 466 |
|
No := ''; |
| 467 |
|
len := Length(s); |
| 468 |
|
end else begin |
| 469 |
|
cm := false; |
| 470 |
|
end; |
| 471 |
|
end; |
| 472 |
|
end; |
| 473 |
|
end; |
| 474 |
end else begin |
end else begin |
| 475 |
//何かしら見つかったパターン |
//何かしら見つかったパターン |
| 476 |
j := Length(token[i]) + 1; |
j := Length(token[i]) + 1; |
| 497 |
end else if (ch = '-') then begin |
end else if (ch = '-') then begin |
| 498 |
if sw then break; |
if sw then break; |
| 499 |
if No = '' then break; |
if No = '' then break; |
| 500 |
|
No := No + ch; |
| 501 |
sw := true; |
sw := true; |
| 502 |
end else begin |
end else begin |
| 503 |
break; |
break; |