1. 링크 새창에서 띄우도록 수정하기
Textile 포매터에 link 기능은 편리하긴 한데 링크가 현재창에서 열리는 문제가 있어 무조건 새창에서 띄우게끔 수정해 보았습니다.
수정할 파일 위치는 /plugins/FM_Textile/classTextile.php 입니다.
fLink() 함수에서 <a> 태그에 target=”_blank” 추가
fImage() 함수에서 <a> 태그에 target=”_blank” 추가
이렇게 하시면 늘 새창에서 뜨게 됩니다.
2. 리스트 출력 버그 수정
BS만 그런가요? 이상하게 리스트가 깨져서 나오네요.
* Test
* Test2
* Test3
이렇게 입력하면
- Test
- Test2
- Test3
요렇게 빈 라인 하나가 꼭 들어가네요. 그래서 수정했습니다.
fList() 함수 시작부를 보면
$text = explode("\n", $m[0]);
foreach($text as $line) {
$nextline = next($text);
이렇게 되어 있는데요.
여기에서 next()의 반환값이 이상하더라구요. 그래서 아래처럼 바꾸었습니다.
$text = explode("\n", $m[0]);
$text2 = $text;
foreach($text as $line) {
$nextline = next($text2);
다음 라인을 찾기 위한 변수를 별도로 만들었습니다.
제대로 나오는군요.
3. 줄바꿈 기능 추가
글을 적다보면... 특히 표 안에서 줄바꿈이 필요한데 왜 줄바꿈을 하면 표가 깨지도록 만들었는지...
어떤 표현식이든 Block Modifier를 제외하고는 한 라인에 넣어야 되게 되어 있네요.
그래서 줄바꿈 기능을 추가했습니다.
TextileThis() 함수에서 return 문 전에 추가했습니다.
$text = str_replace("<br />", "<br />\n", $text);
$text = str_replace("\
", "<br />\n", $text);
return $text;
이렇게 해 두고 본문에서 \하고 스페이스를 입력하면
\n 변경됩니다.
이제 표에서도 줄바꿈이 되요!
4. 표 스타일 기본값 적용
표가 그냥 그리면 선이 하나두 안나와서 대략 보기 안좋네요.
그래서 또다시 수정했습니다.
function fTable($matches)
{
$tatts = $this->pba($matches[1], 'table');
$bstableStyle = '';
if (strlen($tatts) < 1)
$bstableStyle = "\t<style>\n\ttable {border-collapse: collapse}\n\tth {background-color: #ddd; border: 1px solid}\n\ttd {border: 1px solid; padding: 3px}\n\t</style>\n\n";
foreach(preg_split("/\|$/m", $matches[2], -1, PREG_SPLIT_NO_EMPTY) as $row) {
if (preg_match("/^($this->a$this->c\. )(.*)/m", ltrim($row), $rmtch)) {
$ratts = $this->pba($rmtch[1], 'tr');
$row = $rmtch[2];
} else $ratts = '';
$cells = array();
foreach(explode("|", $row) as $cell) {
$ctyp = "d";
if (preg_match("/^_/", $cell)) $ctyp = "h";
if (preg_match("/^(_?$this->s$this->a$this->c\. )(.*)/", $cell, $cmtch)) {
$catts = $this->pba($cmtch[1], 'td');
$cell = $cmtch[2];
} else $catts = '';
$cell = $this->graf($this->span($cell));
if (trim($cell) != '')
$cells[] = "\t\t\t<t$ctyp$catts>$cell</t$ctyp>";
}
$rows[] = "\t\t<tr$ratts>\n" . join("\n", $cells) . ($cells ? "\n" : "") . "\t\t</tr>";
unset($cells, $catts);
}
return $bstableStyle."\t<table$tatts>\n" . join("\n", $rows) . "\n\t</table>\n\n";
}
명시적으로 테이블의 스타일을 정하지 않으면 미리 정한 bstableStyle이 적용되도록 하였습니다.
최종 수정본 파일을 올립니다.

by BSPFP
classTextile.php