Skip to content

Commit

Permalink
[fix] [KifParser] コメント内の「KEY:VALUE」形式をヘッダーとして読み込んで消してしまうのを修正する
Browse files Browse the repository at this point in the history
  • Loading branch information
akicho8 committed Sep 7, 2024
1 parent 7e1fa39 commit d5a5aee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion components/models/kif_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { KanjiNumber } from "./kanji_number.js"
////////////////////////////////////////////////////////////////////////////////

const REGEXP = {
header: "(?<key>.*):\s*(?<value>.*)", // key:val
header: "^(?!\\*)(?<key>.*):\s*(?<value>.*)", // key:val
board: "\\|(?<board>.*)\\|", // | 香 桂 銀 金 玉 金 銀 桂 香|九
direct_location: "(?<direct_location>^[上下先後]手番)", // 上手番
latest_triangle: "^手数=.*(?<latest_triangle>[▲△])", // 手数=24 △5四歩 まで (TODO: 最終手を活用する)
Expand Down
4 changes: 4 additions & 0 deletions test/kif_parser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ describe("KifParser", () => {
expect(KifParser.parse("key3:").header["key3"]).toEqual("")
})

it("コメント内の「KEY:VALUE」形式をヘッダーとして読み込まないこと", () => {
expect(KifParser.parse("手数----指手---------消費時間--\n*KEY:VALUE").header).toEqual({})
})

it("コメント", () => {
expect(KifParser.parse("*a\n*b").comment_lines_hash).toEqual({ '0': [ 'a', 'b' ] })
})
Expand Down

0 comments on commit d5a5aee

Please sign in to comment.