Skip to content

Commit 7659232

Browse files
committed
fix(control): 中文排版输出
1 parent fb6d231 commit 7659232

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

laravel/app/Http/Controllers/Bus/NewApiController.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,26 @@ public function newBusLine(Request $request)
7575

7676
public function output(Request $request)
7777
{
78-
$chineseTypesetting = new ChineseTypesetting();
78+
$input = $request->input('input');
79+
$output = '';
80+
if ($input) {
81+
$chineseTypesetting = new ChineseTypesetting();
82+
$arrays = explode("\n", $input);
7983

80-
// 使用指定方法来纠正排版(推荐此用法)
81-
$text = '<p class="class-name" style="color: #FFFFFF;"> Hello世界。\n option</p>';
82-
$out = $chineseTypesetting->correct($text, ['insertSpace', 'removeClass', 'removeIndent']);
83-
// output: <p style="color: #FFFFFF;">Hello 世界。</p>
84+
$newArr = [];
85+
foreach ($arrays as $key => $item) {
86+
// 使用指定方法来纠正排版(推荐此用法)
87+
$newArr[] = $chineseTypesetting->correct($item, ['insertSpace', 'removeClass', 'removeIndent']);
88+
}
89+
$output = implode("\n", $newArr);
90+
}
91+
92+
return $this->out(200, ['output' => $output]);
8493

8594
// 使用全部方法来纠正排版(不推荐此用法)
86-
$text = '<p class="class-name" style="color: #FFFFFF;"> Hello世界。</p>';
87-
$out1 = $chineseTypesetting->correct($text);
95+
// $text = '<p class="class-name" style="color: #FFFFFF;"> Hello世界。</p>';
96+
// $out1 = $chineseTypesetting->correct($text);
8897
// output: <p>Hello 世界。</p>
89-
var_dump($out);
90-
var_dump($out1);
9198
}
9299

93100
}

0 commit comments

Comments
 (0)