LMConsolidator // Fix the procedure for fixing the pragma header.
This commit is contained in:
parent
a2f5606579
commit
87ad7dccbb
|
@ -104,6 +104,7 @@ public extension vChewingLM {
|
||||||
strProcessed.regReplace(pattern: #"(\n | \n)"#, replaceWith: "\n")
|
strProcessed.regReplace(pattern: #"(\n | \n)"#, replaceWith: "\n")
|
||||||
// CR & FF to LF, 且去除重複行
|
// CR & FF to LF, 且去除重複行
|
||||||
strProcessed.regReplace(pattern: #"(\f+|\r+|\n+)+"#, replaceWith: "\n")
|
strProcessed.regReplace(pattern: #"(\f+|\r+|\n+)+"#, replaceWith: "\n")
|
||||||
|
strProcessed.regReplace(pattern: "^\(kPragmaHeader)$", replaceWith: "")
|
||||||
if strProcessed.prefix(1) == " " { // 去除檔案開頭空格
|
if strProcessed.prefix(1) == " " { // 去除檔案開頭空格
|
||||||
strProcessed.removeFirst()
|
strProcessed.removeFirst()
|
||||||
}
|
}
|
||||||
|
@ -111,8 +112,6 @@ public extension vChewingLM {
|
||||||
strProcessed.removeLast()
|
strProcessed.removeLast()
|
||||||
}
|
}
|
||||||
|
|
||||||
strProcessed = kPragmaHeader + "\n" + strProcessed // Add Pragma Header
|
|
||||||
|
|
||||||
// Step 3: Deduplication.
|
// Step 3: Deduplication.
|
||||||
let arrData = strProcessed.split(separator: "\n")
|
let arrData = strProcessed.split(separator: "\n")
|
||||||
// 下面兩行的 reversed 是首尾顛倒,免得破壞最新的 override 資訊。
|
// 下面兩行的 reversed 是首尾顛倒,免得破壞最新的 override 資訊。
|
||||||
|
@ -121,6 +120,9 @@ public extension vChewingLM {
|
||||||
|
|
||||||
// Step 4: Remove duplicated newlines at the end of the file.
|
// Step 4: Remove duplicated newlines at the end of the file.
|
||||||
strProcessed.regReplace(pattern: #"\n+"#, replaceWith: "\n")
|
strProcessed.regReplace(pattern: #"\n+"#, replaceWith: "\n")
|
||||||
|
|
||||||
|
// Step 5: Add pragma header back.
|
||||||
|
strProcessed = kPragmaHeader + "\n" + strProcessed // Add Pragma Header
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 統整給定的檔案的格式。
|
/// 統整給定的檔案的格式。
|
||||||
|
|
Loading…
Reference in New Issue