import { testLawtextToStd } from "../testHelper"; import { $appdx, $appdxFig, $appdxFormat, $appdxNote, $appdxStyle, $appdxTable, appdxItemToLines } from "./$appdxItem"; describe("Test $appdx and appdxItemToLines", () => { it("Success case", () => { /* eslint-disable no-irregular-whitespace */ const lawtextWithMarker = `\ :appdx:付録第一(第二十六条、第四十五条、第四十六条の五関係)  :arith-formula: # 別表第二 外国旅行の旅費(第三十五条―第三十七条、第三十九条、第四十条、第四十一条関係) `; const expectedErrorMessages: string[] = []; const expectedRendered = `\ # 付録第一(第二十六条、第四十五条、第四十六条の五関係) :arith-formula: `.replace(/\r?\n/g, "\r\n"); const expectedValue = { tag: "Appdx", attr: {}, children: [ { tag: "ArithFormulaNum", attr: {}, children: ["付録第一"], }, { tag: "RelatedArticleNum", attr: {}, children: ["(第二十六条、第四十五条、第四十六条の五関係)"], }, { tag: "ArithFormula", attr: {}, children: [ { tag: "Fig", attr: { src: "./pict/001.jpg" }, children: [], }, ], }, ], }; testLawtextToStd( lawtextWithMarker, expectedRendered, expectedValue, expectedErrorMessages, (vlines, env) => { const result = $appdx.match(0, vlines, env); // console.log(JSON.stringify(vlines, null, 2)); // if (result.ok) console.log(JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__parsed.json", JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__expected.json", JSON.stringify(expectedValue, undefined, 2)); return result; }, el => { const lines = appdxItemToLines(el, []); // console.log(JSON.stringify(lines, null, 2)); return lines; }, ); }); it("Success case", () => { /* eslint-disable no-irregular-whitespace */ const lawtextWithMarker = `\ :appdx:別記付録第一(第二十六条、第四十五条、第四十六条の五関係)  :arith-formula: # 別表第二 外国旅行の旅費(第三十五条―第三十七条、第三十九条、第四十条、第四十一条関係) `; const expectedErrorMessages: string[] = []; const expectedRendered = `\ :appdx:別記付録第一(第二十六条、第四十五条、第四十六条の五関係) :arith-formula: `.replace(/\r?\n/g, "\r\n"); const expectedValue = { tag: "Appdx", attr: {}, children: [ { tag: "ArithFormulaNum", attr: {}, children: ["別記付録第一"], }, { tag: "RelatedArticleNum", attr: {}, children: ["(第二十六条、第四十五条、第四十六条の五関係)"], }, { tag: "ArithFormula", attr: {}, children: [ { tag: "Fig", attr: { src: "./pict/001.jpg" }, children: [], }, ], }, ], }; testLawtextToStd( lawtextWithMarker, expectedRendered, expectedValue, expectedErrorMessages, (vlines, env) => { const result = $appdx.match(0, vlines, env); // console.log(JSON.stringify(vlines, null, 2)); // if (result.ok) console.log(JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__parsed.json", JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__expected.json", JSON.stringify(expectedValue, undefined, 2)); return result; }, el => { const lines = appdxItemToLines(el, []); // console.log(JSON.stringify(lines, null, 2)); return lines; }, ); }); it("Success case", () => { /* eslint-disable no-irregular-whitespace */ const lawtextWithMarker = `\ # 付録第一(第二十六条、第四十五条、第四十六条の五関係)  :arith-formula: # 別表第二 外国旅行の旅費(第三十五条―第三十七条、第三十九条、第四十条、第四十一条関係) `; const expectedErrorMessages: string[] = []; const expectedRendered = `\ # 付録第一(第二十六条、第四十五条、第四十六条の五関係) :arith-formula: `.replace(/\r?\n/g, "\r\n"); const expectedValue = { tag: "Appdx", attr: {}, children: [ { tag: "ArithFormulaNum", attr: {}, children: ["付録第一"], }, { tag: "RelatedArticleNum", attr: {}, children: ["(第二十六条、第四十五条、第四十六条の五関係)"], }, { tag: "ArithFormula", attr: {}, children: [ { tag: "Fig", attr: { src: "./pict/001.jpg" }, children: [], }, ], }, ], }; testLawtextToStd( lawtextWithMarker, expectedRendered, expectedValue, expectedErrorMessages, (vlines, env) => { const result = $appdx.match(0, vlines, env); // console.log(JSON.stringify(vlines, null, 2)); // if (result.ok) console.log(JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__parsed.json", JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__expected.json", JSON.stringify(expectedValue, undefined, 2)); return result; }, el => { const lines = appdxItemToLines(el, []); // console.log(JSON.stringify(lines, null, 2)); return lines; }, ); }); it("Success case", () => { /* eslint-disable no-irregular-whitespace */ const lawtextWithMarker = `\ # 付録第一(第二十六条、第四十五条、第四十六条の五関係)  :arith-formula: 備考 備考文 # 別表第二 外国旅行の旅費(第三十五条―第三十七条、第三十九条、第四十条、第四十一条関係) `; const expectedErrorMessages: string[] = []; const expectedRendered = `\ # 付録第一(第二十六条、第四十五条、第四十六条の五関係) :arith-formula: 備考 備考文 `.replace(/\r?\n/g, "\r\n"); const expectedValue = { tag: "Appdx", attr: {}, children: [ { tag: "ArithFormulaNum", attr: {}, children: ["付録第一"], }, { tag: "RelatedArticleNum", attr: {}, children: ["(第二十六条、第四十五条、第四十六条の五関係)"], }, { tag: "ArithFormula", attr: {}, children: [ { tag: "Fig", attr: { src: "./pict/001.jpg" }, children: [], }, ], }, { tag: "Remarks", attr: {}, children: [ { tag: "RemarksLabel", attr: {}, children: ["備考"], }, { tag: "Sentence", attr: {}, children: ["備考文"], }, ], }, ], }; testLawtextToStd( lawtextWithMarker, expectedRendered, expectedValue, expectedErrorMessages, (vlines, env) => { const result = $appdx.match(0, vlines, env); // console.log(JSON.stringify(vlines, null, 2)); // if (result.ok) console.log(JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__parsed.json", JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__expected.json", JSON.stringify(expectedValue, undefined, 2)); return result; }, el => { const lines = appdxItemToLines(el, []); // console.log(JSON.stringify(lines, null, 2)); return lines; }, ); }); it("Success case", () => { /* eslint-disable no-irregular-whitespace */ const lawtextWithMarker = `\ # 付録第一(第二十六条、第四十五条、第四十六条の五関係)  # 別表第二 外国旅行の旅費(第三十五条―第三十七条、第三十九条、第四十条、第四十一条関係) `; const expectedErrorMessages: string[] = []; const expectedRendered = `\ # 付録第一(第二十六条、第四十五条、第四十六条の五関係) `.replace(/\r?\n/g, "\r\n"); const expectedValue = { tag: "Appdx", attr: {}, children: [ { tag: "ArithFormulaNum", attr: {}, children: ["付録第一"], }, { tag: "RelatedArticleNum", attr: {}, children: ["(第二十六条、第四十五条、第四十六条の五関係)"], }, ], }; testLawtextToStd( lawtextWithMarker, expectedRendered, expectedValue, expectedErrorMessages, (vlines, env) => { const result = $appdx.match(0, vlines, env); // console.log(JSON.stringify(vlines, null, 2)); // if (result.ok) console.log(JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__parsed.json", JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__expected.json", JSON.stringify(expectedValue, undefined, 2)); return result; }, el => { const lines = appdxItemToLines(el, []); // console.log(JSON.stringify(lines, null, 2)); return lines; }, ); }); it("Success case", () => { /* eslint-disable no-irregular-whitespace */ const lawtextWithMarker = `\ :appdx: # 別表第二 外国旅行の旅費(第三十五条―第三十七条、第三十九条、第四十条、第四十一条関係) `; const expectedErrorMessages: string[] = []; const expectedRendered = `\ :appdx: `.replace(/\r?\n/g, "\r\n"); const expectedValue = { tag: "Appdx", attr: {}, children: [], }; testLawtextToStd( lawtextWithMarker, expectedRendered, expectedValue, expectedErrorMessages, (vlines, env) => { const result = $appdx.match(0, vlines, env); // console.log(JSON.stringify(vlines, null, 2)); // if (result.ok) console.log(JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__parsed.json", JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__expected.json", JSON.stringify(expectedValue, undefined, 2)); return result; }, el => { const lines = appdxItemToLines(el, []); // console.log(JSON.stringify(lines, null, 2)); return lines; }, ); }); it("Success with errors case", () => { /* eslint-disable no-irregular-whitespace */ const lawtextWithMarker = `\ :appdx:付録第一(第二十六条、第四十五条、第四十六条の五関係)  !第二条 この法律において、次の各号に掲げる用語の意義は、当該各号に定めるところによる。 ! :arith-formula: # 別表第二 外国旅行の旅費(第三十五条―第三十七条、第三十九条、第四十条、第四十一条関係) `; const expectedErrorMessages: string[] = ["$appdxChildrenBlock: この部分をパースできませんでした。"]; const expectedRendered = `\ # 付録第一(第二十六条、第四十五条、第四十六条の五関係) :arith-formula: `.replace(/\r?\n/g, "\r\n"); const expectedValue = { tag: "Appdx", attr: {}, children: [ { tag: "ArithFormulaNum", attr: {}, children: ["付録第一"], }, { tag: "RelatedArticleNum", attr: {}, children: ["(第二十六条、第四十五条、第四十六条の五関係)"], }, { tag: "ArithFormula", attr: {}, children: [ { tag: "Fig", attr: { src: "./pict/001.jpg" }, children: [], }, ], }, ], }; testLawtextToStd( lawtextWithMarker, expectedRendered, expectedValue, expectedErrorMessages, (vlines, env) => { const result = $appdx.match(0, vlines, env); // console.log(JSON.stringify(vlines, null, 2)); // if (result.ok) console.log(JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__parsed.json", JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__expected.json", JSON.stringify(expectedValue, undefined, 2)); return result; }, el => { const lines = appdxItemToLines(el, []); // console.log(JSON.stringify(lines, null, 2)); return lines; }, ); }); }); describe("Test $appdxTable and appdxItemToLines", () => { it("Success case", () => { /* eslint-disable no-irregular-whitespace */ const lawtextWithMarker = `\ :appdx-table:別表第二(第十九条、第二十一条関係)  * - 情報照会者 - 事務 # 別表第二 外国旅行の旅費(第三十五条―第三十七条、第三十九条、第四十条、第四十一条関係) `; const expectedErrorMessages: string[] = []; const expectedRendered = `\ # 別表第二(第十九条、第二十一条関係) * - 情報照会者 - 事務 `.replace(/\r?\n/g, "\r\n"); const expectedValue = { tag: "AppdxTable", attr: {}, children: [ { tag: "AppdxTableTitle", attr: {}, children: ["別表第二"], }, { tag: "RelatedArticleNum", attr: {}, children: ["(第十九条、第二十一条関係)"], }, { tag: "TableStruct", attr: {}, children: [ { tag: "Table", attr: {}, children: [ { tag: "TableRow", attr: {}, children: [ { tag: "TableColumn", attr: {}, children: [ { tag: "Sentence", attr: {}, children: ["情報照会者"] } ] }, { tag: "TableColumn", attr: {}, children: [ { tag: "Sentence", attr: {}, children: ["事務"] } ] } ] }, ] }, ], }, ], }; testLawtextToStd( lawtextWithMarker, expectedRendered, expectedValue, expectedErrorMessages, (vlines, env) => { const result = $appdxTable.match(0, vlines, env); // console.log(JSON.stringify(vlines, null, 2)); // if (result.ok) console.log(JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__parsed.json", JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__expected.json", JSON.stringify(expectedValue, undefined, 2)); return result; }, el => { const lines = appdxItemToLines(el, []); // console.log(JSON.stringify(lines, null, 2)); return lines; }, ); }); it("Success case", () => { /* eslint-disable no-irregular-whitespace */ const lawtextWithMarker = `\ :appdx-table:別表第二(第十九条、第二十一条関係)  :table-struct: * - 情報照会者1 - 事務1 :table-struct: * - 情報照会者2 - 事務2 # 別表第二 外国旅行の旅費(第三十五条―第三十七条、第三十九条、第四十条、第四十一条関係) `; const expectedErrorMessages: string[] = []; const expectedRendered = `\ # 別表第二(第十九条、第二十一条関係) :table-struct: * - 情報照会者1 - 事務1 :table-struct: * - 情報照会者2 - 事務2 `.replace(/\r?\n/g, "\r\n"); const expectedValue = { tag: "AppdxTable", attr: {}, children: [ { tag: "AppdxTableTitle", attr: {}, children: ["別表第二"], }, { tag: "RelatedArticleNum", attr: {}, children: ["(第十九条、第二十一条関係)"], }, { tag: "TableStruct", attr: {}, children: [ { tag: "Table", attr: {}, children: [ { tag: "TableRow", attr: {}, children: [ { tag: "TableColumn", attr: {}, children: [ { tag: "Sentence", attr: {}, children: ["情報照会者1"] } ] }, { tag: "TableColumn", attr: {}, children: [ { tag: "Sentence", attr: {}, children: ["事務1"] } ] } ] }, ] }, ], }, { tag: "TableStruct", attr: {}, children: [ { tag: "Table", attr: {}, children: [ { tag: "TableRow", attr: {}, children: [ { tag: "TableColumn", attr: {}, children: [ { tag: "Sentence", attr: {}, children: ["情報照会者2"] } ] }, { tag: "TableColumn", attr: {}, children: [ { tag: "Sentence", attr: {}, children: ["事務2"] } ] } ] }, ] }, ], }, ], }; testLawtextToStd( lawtextWithMarker, expectedRendered, expectedValue, expectedErrorMessages, (vlines, env) => { const result = $appdxTable.match(0, vlines, env); // console.log(JSON.stringify(vlines, null, 2)); // if (result.ok) console.log(JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__parsed.json", JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__expected.json", JSON.stringify(expectedValue, undefined, 2)); return result; }, el => { const lines = appdxItemToLines(el, []); // console.log(JSON.stringify(lines, null, 2)); return lines; }, ); }); it("Success case", () => { /* eslint-disable no-irregular-whitespace */ const lawtextWithMarker = `\ :appdx-table:付録別表第二(第十九条、第二十一条関係)  * - 情報照会者 - 事務 # 別表第二 外国旅行の旅費(第三十五条―第三十七条、第三十九条、第四十条、第四十一条関係) `; const expectedErrorMessages: string[] = []; const expectedRendered = `\ :appdx-table:付録別表第二(第十九条、第二十一条関係) * - 情報照会者 - 事務 `.replace(/\r?\n/g, "\r\n"); const expectedValue = { tag: "AppdxTable", attr: {}, children: [ { tag: "AppdxTableTitle", attr: {}, children: ["付録別表第二"], }, { tag: "RelatedArticleNum", attr: {}, children: ["(第十九条、第二十一条関係)"], }, { tag: "TableStruct", attr: {}, children: [ { tag: "Table", attr: {}, children: [ { tag: "TableRow", attr: {}, children: [ { tag: "TableColumn", attr: {}, children: [ { tag: "Sentence", attr: {}, children: ["情報照会者"] } ] }, { tag: "TableColumn", attr: {}, children: [ { tag: "Sentence", attr: {}, children: ["事務"] } ] } ] }, ] }, ], }, ], }; testLawtextToStd( lawtextWithMarker, expectedRendered, expectedValue, expectedErrorMessages, (vlines, env) => { const result = $appdxTable.match(0, vlines, env); // console.log(JSON.stringify(vlines, null, 2)); // if (result.ok) console.log(JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__parsed.json", JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__expected.json", JSON.stringify(expectedValue, undefined, 2)); return result; }, el => { const lines = appdxItemToLines(el, []); // console.log(JSON.stringify(lines, null, 2)); return lines; }, ); }); it("Success case", () => { /* eslint-disable no-irregular-whitespace */ const lawtextWithMarker = `\ # 別表第二(第十九条、第二十一条関係) * - 情報照会者 - 事務 # 別表第二 外国旅行の旅費(第三十五条―第三十七条、第三十九条、第四十条、第四十一条関係) `; const expectedErrorMessages: string[] = []; const expectedRendered = `\ # 別表第二(第十九条、第二十一条関係) * - 情報照会者 - 事務 `.replace(/\r?\n/g, "\r\n"); const expectedValue = { tag: "AppdxTable", attr: {}, children: [ { tag: "AppdxTableTitle", attr: {}, children: ["別表第二"], }, { tag: "RelatedArticleNum", attr: {}, children: ["(第十九条、第二十一条関係)"], }, { tag: "TableStruct", attr: {}, children: [ { tag: "Table", attr: {}, children: [ { tag: "TableRow", attr: {}, children: [ { tag: "TableColumn", attr: {}, children: [ { tag: "Sentence", attr: {}, children: ["情報照会者"] } ] }, { tag: "TableColumn", attr: {}, children: [ { tag: "Sentence", attr: {}, children: ["事務"] } ] } ] }, ] }, ], }, ], }; testLawtextToStd( lawtextWithMarker, expectedRendered, expectedValue, expectedErrorMessages, (vlines, env) => { const result = $appdxTable.match(0, vlines, env); // console.log(JSON.stringify(vlines, null, 2)); // if (result.ok) console.log(JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__parsed.json", JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__expected.json", JSON.stringify(expectedValue, undefined, 2)); return result; }, el => { const lines = appdxItemToLines(el, []); // console.log(JSON.stringify(lines, null, 2)); return lines; }, ); }); it("Success case", () => { /* eslint-disable no-irregular-whitespace */ const lawtextWithMarker = `\ # 別表第二(第十九条、第二十一条関係) * - 情報照会者 - 事務 備考 備考文 # 別表第二 外国旅行の旅費(第三十五条―第三十七条、第三十九条、第四十条、第四十一条関係) `; const expectedErrorMessages: string[] = []; const expectedRendered = `\ # 別表第二(第十九条、第二十一条関係) * - 情報照会者 - 事務 備考 備考文 `.replace(/\r?\n/g, "\r\n"); const expectedValue = { tag: "AppdxTable", attr: {}, children: [ { tag: "AppdxTableTitle", attr: {}, children: ["別表第二"], }, { tag: "RelatedArticleNum", attr: {}, children: ["(第十九条、第二十一条関係)"], }, { tag: "TableStruct", attr: {}, children: [ { tag: "Table", attr: {}, children: [ { tag: "TableRow", attr: {}, children: [ { tag: "TableColumn", attr: {}, children: [ { tag: "Sentence", attr: {}, children: ["情報照会者"] } ] }, { tag: "TableColumn", attr: {}, children: [ { tag: "Sentence", attr: {}, children: ["事務"] } ] } ] }, ] }, ], }, { tag: "Remarks", attr: {}, children: [ { tag: "RemarksLabel", attr: {}, children: ["備考"], }, { tag: "Sentence", attr: {}, children: ["備考文"], }, ], }, ], }; testLawtextToStd( lawtextWithMarker, expectedRendered, expectedValue, expectedErrorMessages, (vlines, env) => { const result = $appdxTable.match(0, vlines, env); // console.log(JSON.stringify(vlines, null, 2)); // if (result.ok) console.log(JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__parsed.json", JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__expected.json", JSON.stringify(expectedValue, undefined, 2)); return result; }, el => { const lines = appdxItemToLines(el, []); // console.log(JSON.stringify(lines, null, 2)); return lines; }, ); }); it("Success case", () => { /* eslint-disable no-irregular-whitespace */ const lawtextWithMarker = `\ # 別表第二〔第6条・第8条〕 :anonym-item:接続会計財務諸表様式 :style-struct:様式第1 # 別表第二 外国旅行の旅費(第三十五条―第三十七条、第三十九条、第四十条、第四十一条関係) `; const expectedErrorMessages: string[] = []; const expectedRendered = `\ # 別表第二〔第6条・第8条〕 :anonym-item:接続会計財務諸表様式 :style-struct:様式第1 `.replace(/\r?\n/g, "\r\n"); const expectedValue = { tag: "AppdxTable", attr: {}, children: [ { tag: "AppdxTableTitle", attr: {}, children: ["別表第二〔第6条・第8条〕"] }, { tag: "Item", attr: {}, children: [ { tag: "ItemTitle", attr: {}, children: [] }, { tag: "ItemSentence", attr: {}, children: [ { tag: "Sentence", attr: {}, children: ["接続会計財務諸表様式"] } ] }, { tag: "StyleStruct", attr: {}, children: [ { tag: "StyleStructTitle", attr: {}, children: ["様式第1"] }, { tag: "Style", attr: {}, children: [ { tag: "Fig", attr: { src: "./pict/H09F04001000091-001.pdf" }, children: [] } ] } ] } ] } ] }; testLawtextToStd( lawtextWithMarker, expectedRendered, expectedValue, expectedErrorMessages, (vlines, env) => { const result = $appdxTable.match(0, vlines, env); // console.log(JSON.stringify(vlines, null, 2)); // if (result.ok) console.log(JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__parsed.json", JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__expected.json", JSON.stringify(expectedValue, undefined, 2)); return result; }, el => { const lines = appdxItemToLines(el, []); // console.log(JSON.stringify(lines, null, 2)); return lines; }, ); }); it("Success case", () => { /* eslint-disable no-irregular-whitespace */ const lawtextWithMarker = `\ # 別表(第一条、第三十四条関係) # 一 アラビアゴム # 二 アラビアゴム末 # 三 亜硫酸水素ナトリウム # 四 エチレンジアミン # 五 エーテル(麻酔用エーテルを除く。) # 六 オリブ油 # 七 オレンジ油 # 八 カカオ脂及びこれに類似するもの # 別表第二 外国旅行の旅費(第三十五条―第三十七条、第三十九条、第四十条、第四十一条関係) `; const expectedErrorMessages: string[] = []; const expectedRendered = `\ # 別表(第一条、第三十四条関係) # 一 アラビアゴム # 二 アラビアゴム末 # 三 亜硫酸水素ナトリウム # 四 エチレンジアミン # 五 エーテル(麻酔用エーテルを除く。) # 六 オリブ油 # 七 オレンジ油 # 八 カカオ脂及びこれに類似するもの `.replace(/\r?\n/g, "\r\n"); const expectedValue = { tag: "AppdxTable", attr: {}, children: [ { tag: "AppdxTableTitle", attr: {}, children: ["別表"] }, { tag: "RelatedArticleNum", attr: {}, children: ["(第一条、第三十四条関係)"] }, { tag: "Item", attr: { Num: "1", }, children: [ { tag: "ItemTitle", attr: {}, children: ["一"] }, { tag: "ItemSentence", attr: {}, children: [ { tag: "Sentence", attr: {}, children: ["アラビアゴム"] } ] } ] }, { tag: "Item", attr: { Num: "2", }, children: [ { tag: "ItemTitle", attr: {}, children: ["二"] }, { tag: "ItemSentence", attr: {}, children: [ { tag: "Sentence", attr: {}, children: ["アラビアゴム末"] } ] } ] }, { tag: "Item", attr: { Num: "3", }, children: [ { tag: "ItemTitle", attr: {}, children: ["三"] }, { tag: "ItemSentence", attr: {}, children: [ { tag: "Sentence", attr: {}, children: ["亜硫酸水素ナトリウム"] } ] } ] }, { tag: "Item", attr: { Num: "4", }, children: [ { tag: "ItemTitle", attr: {}, children: ["四"] }, { tag: "ItemSentence", attr: {}, children: [ { tag: "Sentence", attr: {}, children: ["エチレンジアミン"] } ] } ] }, { tag: "Item", attr: { Num: "5", }, children: [ { tag: "ItemTitle", attr: {}, children: ["五"] }, { tag: "ItemSentence", attr: {}, children: [ { tag: "Sentence", attr: {}, children: ["エーテル(麻酔用エーテルを除く。)"] } ] } ] }, { tag: "Item", attr: { Num: "6", }, children: [ { tag: "ItemTitle", attr: {}, children: ["六"] }, { tag: "ItemSentence", attr: {}, children: [ { tag: "Sentence", attr: {}, children: ["オリブ油"] } ] } ] }, { tag: "Item", attr: { Num: "7", }, children: [ { tag: "ItemTitle", attr: {}, children: ["七"] }, { tag: "ItemSentence", attr: {}, children: [ { tag: "Sentence", attr: {}, children: ["オレンジ油"] } ] } ] }, { tag: "Item", attr: { Num: "8", }, children: [ { tag: "ItemTitle", attr: {}, children: ["八"] }, { tag: "ItemSentence", attr: {}, children: [ { tag: "Sentence", attr: {}, children: ["カカオ脂及びこれに類似するもの"] } ] } ] } ] }; testLawtextToStd( lawtextWithMarker, expectedRendered, expectedValue, expectedErrorMessages, (vlines, env) => { const result = $appdxTable.match(0, vlines, env); // console.log(JSON.stringify(vlines, null, 2)); // if (result.ok) console.log(JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__parsed.json", JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__expected.json", JSON.stringify(expectedValue, undefined, 2)); return result; }, el => { const lines = appdxItemToLines(el, []); // console.log(JSON.stringify(lines, null, 2)); return lines; }, ); }); }); describe("Test $appdxStyle and appdxItemToLines", () => { it("Success case", () => { /* eslint-disable no-irregular-whitespace */ const lawtextWithMarker = `\ :appdx-style:別記様式(第十四条関係)  :style-struct: # 別表第二 外国旅行の旅費(第三十五条―第三十七条、第三十九条、第四十条、第四十一条関係) `; const expectedErrorMessages: string[] = []; const expectedRendered = `\ # 別記様式(第十四条関係) :style-struct: `.replace(/\r?\n/g, "\r\n"); const expectedValue = { tag: "AppdxStyle", attr: {}, children: [ { tag: "AppdxStyleTitle", attr: {}, children: ["別記様式"], }, { tag: "RelatedArticleNum", attr: {}, children: ["(第十四条関係)"], }, { tag: "StyleStruct", attr: {}, children: [ { tag: "Style", attr: {}, children: [ { tag: "Fig", attr: { src: "./pict/001.pdf" }, children: [], }, ], }, ], }, ], }; testLawtextToStd( lawtextWithMarker, expectedRendered, expectedValue, expectedErrorMessages, (vlines, env) => { const result = $appdxStyle.match(0, vlines, env); // console.log(JSON.stringify(vlines, null, 2)); // if (result.ok) console.log(JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__parsed.json", JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__expected.json", JSON.stringify(expectedValue, undefined, 2)); return result; }, el => { const lines = appdxItemToLines(el, []); // console.log(JSON.stringify(lines, null, 2)); return lines; }, ); }); it("Success case", () => { /* eslint-disable no-irregular-whitespace */ const lawtextWithMarker = `\ :appdx-style:付録別記(第十四条関係)  :style-struct: # 別表第二 外国旅行の旅費(第三十五条―第三十七条、第三十九条、第四十条、第四十一条関係) `; const expectedErrorMessages: string[] = []; const expectedRendered = `\ :appdx-style:付録別記(第十四条関係) :style-struct: `.replace(/\r?\n/g, "\r\n"); const expectedValue = { tag: "AppdxStyle", attr: {}, children: [ { tag: "AppdxStyleTitle", attr: {}, children: ["付録別記"], }, { tag: "RelatedArticleNum", attr: {}, children: ["(第十四条関係)"], }, { tag: "StyleStruct", attr: {}, children: [ { tag: "Style", attr: {}, children: [ { tag: "Fig", attr: { src: "./pict/001.pdf" }, children: [], }, ], }, ], }, ], }; testLawtextToStd( lawtextWithMarker, expectedRendered, expectedValue, expectedErrorMessages, (vlines, env) => { const result = $appdxStyle.match(0, vlines, env); // console.log(JSON.stringify(vlines, null, 2)); // if (result.ok) console.log(JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__parsed.json", JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__expected.json", JSON.stringify(expectedValue, undefined, 2)); return result; }, el => { const lines = appdxItemToLines(el, []); // console.log(JSON.stringify(lines, null, 2)); return lines; }, ); }); it("Success case", () => { /* eslint-disable no-irregular-whitespace */ const lawtextWithMarker = `\ # 別記様式(第十四条関係)  :style-struct: # 別表第二 外国旅行の旅費(第三十五条―第三十七条、第三十九条、第四十条、第四十一条関係) `; const expectedErrorMessages: string[] = []; const expectedRendered = `\ # 別記様式(第十四条関係) :style-struct: `.replace(/\r?\n/g, "\r\n"); const expectedValue = { tag: "AppdxStyle", attr: {}, children: [ { tag: "AppdxStyleTitle", attr: {}, children: ["別記様式"], }, { tag: "RelatedArticleNum", attr: {}, children: ["(第十四条関係)"], }, { tag: "StyleStruct", attr: {}, children: [ { tag: "Style", attr: {}, children: [ { tag: "Fig", attr: { src: "./pict/001.pdf" }, children: [], }, ], }, ], }, ], }; testLawtextToStd( lawtextWithMarker, expectedRendered, expectedValue, expectedErrorMessages, (vlines, env) => { const result = $appdxStyle.match(0, vlines, env); // console.log(JSON.stringify(vlines, null, 2)); // if (result.ok) console.log(JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__parsed.json", JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__expected.json", JSON.stringify(expectedValue, undefined, 2)); return result; }, el => { const lines = appdxItemToLines(el, []); // console.log(JSON.stringify(lines, null, 2)); return lines; }, ); }); it("Success case", () => { /* eslint-disable no-irregular-whitespace */ const lawtextWithMarker = `\ # 別記様式(第十四条関係)  :style-struct: 備考 備考文 # 別表第二 外国旅行の旅費(第三十五条―第三十七条、第三十九条、第四十条、第四十一条関係) `; const expectedErrorMessages: string[] = []; const expectedRendered = `\ # 別記様式(第十四条関係) :style-struct: 備考 備考文 `.replace(/\r?\n/g, "\r\n"); const expectedValue = { tag: "AppdxStyle", attr: {}, children: [ { tag: "AppdxStyleTitle", attr: {}, children: ["別記様式"], }, { tag: "RelatedArticleNum", attr: {}, children: ["(第十四条関係)"], }, { tag: "StyleStruct", attr: {}, children: [ { tag: "Style", attr: {}, children: [ { tag: "Fig", attr: { src: "./pict/001.pdf" }, children: [], }, ], }, ], }, { tag: "Remarks", attr: {}, children: [ { tag: "RemarksLabel", attr: {}, children: ["備考"], }, { tag: "Sentence", attr: {}, children: ["備考文"], }, ], }, ], }; testLawtextToStd( lawtextWithMarker, expectedRendered, expectedValue, expectedErrorMessages, (vlines, env) => { const result = $appdxStyle.match(0, vlines, env); // console.log(JSON.stringify(vlines, null, 2)); // if (result.ok) console.log(JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__parsed.json", JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__expected.json", JSON.stringify(expectedValue, undefined, 2)); return result; }, el => { const lines = appdxItemToLines(el, []); // console.log(JSON.stringify(lines, null, 2)); return lines; }, ); }); }); describe("Test $appdxFormat and appdxItemToLines", () => { it("Success case", () => { /* eslint-disable no-irregular-whitespace */ const lawtextWithMarker = `\ :appdx-format:別紙第一号書式(第三条関係)  :format-struct: # 別表第二 外国旅行の旅費(第三十五条―第三十七条、第三十九条、第四十条、第四十一条関係) `; const expectedErrorMessages: string[] = []; const expectedRendered = `\ # 別紙第一号書式(第三条関係) :format-struct: `.replace(/\r?\n/g, "\r\n"); const expectedValue = { tag: "AppdxFormat", attr: {}, children: [ { tag: "AppdxFormatTitle", attr: {}, children: ["別紙第一号書式"], }, { tag: "RelatedArticleNum", attr: {}, children: ["(第三条関係)"], }, { tag: "FormatStruct", attr: {}, children: [ { tag: "Format", attr: {}, children: [ { tag: "Fig", attr: { src: "./pict/001.pdf" }, children: [], }, ], }, ], }, ], }; testLawtextToStd( lawtextWithMarker, expectedRendered, expectedValue, expectedErrorMessages, (vlines, env) => { const result = $appdxFormat.match(0, vlines, env); // console.log(JSON.stringify(vlines, null, 2)); // if (result.ok) console.log(JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__parsed.json", JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__expected.json", JSON.stringify(expectedValue, undefined, 2)); return result; }, el => { const lines = appdxItemToLines(el, []); // console.log(JSON.stringify(lines, null, 2)); return lines; }, ); }); it("Success case", () => { /* eslint-disable no-irregular-whitespace */ const lawtextWithMarker = `\ :appdx-format:付録別記(第三条関係)  :format-struct: # 別表第二 外国旅行の旅費(第三十五条―第三十七条、第三十九条、第四十条、第四十一条関係) `; const expectedErrorMessages: string[] = []; const expectedRendered = `\ :appdx-format:付録別記(第三条関係) :format-struct: `.replace(/\r?\n/g, "\r\n"); const expectedValue = { tag: "AppdxFormat", attr: {}, children: [ { tag: "AppdxFormatTitle", attr: {}, children: ["付録別記"], }, { tag: "RelatedArticleNum", attr: {}, children: ["(第三条関係)"], }, { tag: "FormatStruct", attr: {}, children: [ { tag: "Format", attr: {}, children: [ { tag: "Fig", attr: { src: "./pict/001.pdf" }, children: [], }, ], }, ], }, ], }; testLawtextToStd( lawtextWithMarker, expectedRendered, expectedValue, expectedErrorMessages, (vlines, env) => { const result = $appdxFormat.match(0, vlines, env); // console.log(JSON.stringify(vlines, null, 2)); // if (result.ok) console.log(JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__parsed.json", JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__expected.json", JSON.stringify(expectedValue, undefined, 2)); return result; }, el => { const lines = appdxItemToLines(el, []); // console.log(JSON.stringify(lines, null, 2)); return lines; }, ); }); it("Success case", () => { /* eslint-disable no-irregular-whitespace */ const lawtextWithMarker = `\ # 別紙第一号書式(第三条関係)  :format-struct: # 別表第二 外国旅行の旅費(第三十五条―第三十七条、第三十九条、第四十条、第四十一条関係) `; const expectedErrorMessages: string[] = []; const expectedRendered = `\ # 別紙第一号書式(第三条関係) :format-struct: `.replace(/\r?\n/g, "\r\n"); const expectedValue = { tag: "AppdxFormat", attr: {}, children: [ { tag: "AppdxFormatTitle", attr: {}, children: ["別紙第一号書式"], }, { tag: "RelatedArticleNum", attr: {}, children: ["(第三条関係)"], }, { tag: "FormatStruct", attr: {}, children: [ { tag: "Format", attr: {}, children: [ { tag: "Fig", attr: { src: "./pict/001.pdf" }, children: [], }, ], }, ], }, ], }; testLawtextToStd( lawtextWithMarker, expectedRendered, expectedValue, expectedErrorMessages, (vlines, env) => { const result = $appdxFormat.match(0, vlines, env); // console.log(JSON.stringify(vlines, null, 2)); // if (result.ok) console.log(JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__parsed.json", JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__expected.json", JSON.stringify(expectedValue, undefined, 2)); return result; }, el => { const lines = appdxItemToLines(el, []); // console.log(JSON.stringify(lines, null, 2)); return lines; }, ); }); it("Success case", () => { /* eslint-disable no-irregular-whitespace */ const lawtextWithMarker = `\ # 別紙第一号書式(第三条関係) :format-struct: 備考 備考文 # 別表第二 外国旅行の旅費(第三十五条―第三十七条、第三十九条、第四十条、第四十一条関係) `; const expectedErrorMessages: string[] = []; const expectedRendered = `\ # 別紙第一号書式(第三条関係) :format-struct: 備考 備考文 `.replace(/\r?\n/g, "\r\n"); const expectedValue = { tag: "AppdxFormat", attr: {}, children: [ { tag: "AppdxFormatTitle", attr: {}, children: ["別紙第一号書式"], }, { tag: "RelatedArticleNum", attr: {}, children: ["(第三条関係)"], }, { tag: "FormatStruct", attr: {}, children: [ { tag: "Format", attr: {}, children: [ { tag: "Fig", attr: { src: "./pict/001.pdf" }, children: [], }, ], }, ], }, { tag: "Remarks", attr: {}, children: [ { tag: "RemarksLabel", attr: {}, children: ["備考"], }, { tag: "Sentence", attr: {}, children: ["備考文"], }, ], }, ], }; testLawtextToStd( lawtextWithMarker, expectedRendered, expectedValue, expectedErrorMessages, (vlines, env) => { const result = $appdxFormat.match(0, vlines, env); // console.log(JSON.stringify(vlines, null, 2)); // if (result.ok) console.log(JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__parsed.json", JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__expected.json", JSON.stringify(expectedValue, undefined, 2)); return result; }, el => { const lines = appdxItemToLines(el, []); // console.log(JSON.stringify(lines, null, 2)); return lines; }, ); }); }); describe("Test $appdxFig and appdxItemToLines", () => { it("Success case", () => { /* eslint-disable no-irregular-whitespace */ const lawtextWithMarker = `\ :appdx-fig: 別図第十一(第19条第1項の表の6の項関係)  # 別表第二 外国旅行の旅費(第三十五条―第三十七条、第三十九条、第四十条、第四十一条関係) `; const expectedErrorMessages: string[] = []; const expectedRendered = `\ # 別図第十一(第19条第1項の表の6の項関係) `.replace(/\r?\n/g, "\r\n"); const expectedValue = { tag: "AppdxFig", attr: {}, children: [ { tag: "AppdxFigTitle", attr: {}, children: ["別図第十一"], }, { tag: "RelatedArticleNum", attr: {}, children: ["(第19条第1項の表の6の項関係)"], }, { tag: "FigStruct", attr: {}, children: [ { tag: "Fig", attr: { src: "./pict/001.pdf" }, children: [], }, ], }, ], }; testLawtextToStd( lawtextWithMarker, expectedRendered, expectedValue, expectedErrorMessages, (vlines, env) => { const result = $appdxFig.match(0, vlines, env); // console.log(JSON.stringify(vlines, null, 2)); // if (result.ok) console.log(JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__parsed.json", JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__expected.json", JSON.stringify(expectedValue, undefined, 2)); return result; }, el => { const lines = appdxItemToLines(el, []); // console.log(JSON.stringify(lines, null, 2)); return lines; }, ); }); it("Success case", () => { /* eslint-disable no-irregular-whitespace */ const lawtextWithMarker = `\ :appdx-fig:付録別記(第19条第1項の表の6の項関係)  # 別表第二 外国旅行の旅費(第三十五条―第三十七条、第三十九条、第四十条、第四十一条関係) `; const expectedErrorMessages: string[] = []; const expectedRendered = `\ :appdx-fig:付録別記(第19条第1項の表の6の項関係) `.replace(/\r?\n/g, "\r\n"); const expectedValue = { tag: "AppdxFig", attr: {}, children: [ { tag: "AppdxFigTitle", attr: {}, children: ["付録別記"], }, { tag: "RelatedArticleNum", attr: {}, children: ["(第19条第1項の表の6の項関係)"], }, { tag: "FigStruct", attr: {}, children: [ { tag: "Fig", attr: { src: "./pict/001.pdf" }, children: [], }, ], }, ], }; testLawtextToStd( lawtextWithMarker, expectedRendered, expectedValue, expectedErrorMessages, (vlines, env) => { const result = $appdxFig.match(0, vlines, env); // console.log(JSON.stringify(vlines, null, 2)); // if (result.ok) console.log(JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__parsed.json", JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__expected.json", JSON.stringify(expectedValue, undefined, 2)); return result; }, el => { const lines = appdxItemToLines(el, []); // console.log(JSON.stringify(lines, null, 2)); return lines; }, ); }); it("Success case", () => { /* eslint-disable no-irregular-whitespace */ const lawtextWithMarker = `\ # 別図第十一(第19条第1項の表の6の項関係)  # 別表第二 外国旅行の旅費(第三十五条―第三十七条、第三十九条、第四十条、第四十一条関係) `; const expectedErrorMessages: string[] = []; const expectedRendered = `\ # 別図第十一(第19条第1項の表の6の項関係) `.replace(/\r?\n/g, "\r\n"); const expectedValue = { tag: "AppdxFig", attr: {}, children: [ { tag: "AppdxFigTitle", attr: {}, children: ["別図第十一"], }, { tag: "RelatedArticleNum", attr: {}, children: ["(第19条第1項の表の6の項関係)"], }, { tag: "FigStruct", attr: {}, children: [ { tag: "Fig", attr: { src: "./pict/001.pdf" }, children: [], }, ], }, ], }; testLawtextToStd( lawtextWithMarker, expectedRendered, expectedValue, expectedErrorMessages, (vlines, env) => { const result = $appdxFig.match(0, vlines, env); // console.log(JSON.stringify(vlines, null, 2)); // if (result.ok) console.log(JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__parsed.json", JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__expected.json", JSON.stringify(expectedValue, undefined, 2)); return result; }, el => { const lines = appdxItemToLines(el, []); // console.log(JSON.stringify(lines, null, 2)); return lines; }, ); }); }); describe("Test $appdxNote and appdxItemToLines", () => { it("Success case", () => { /* eslint-disable no-irregular-whitespace */ const lawtextWithMarker = `\ :appdx-note:別記第二号(第一条第一項、第九条関係)  :note-struct: # 別表第二 外国旅行の旅費(第三十五条―第三十七条、第三十九条、第四十条、第四十一条関係) `; const expectedErrorMessages: string[] = []; const expectedRendered = `\ # 別記第二号(第一条第一項、第九条関係) :note-struct: `.replace(/\r?\n/g, "\r\n"); const expectedValue = { tag: "AppdxNote", attr: {}, children: [ { tag: "AppdxNoteTitle", attr: {}, children: ["別記第二号"], }, { tag: "RelatedArticleNum", attr: {}, children: ["(第一条第一項、第九条関係)"], }, { tag: "NoteStruct", attr: {}, children: [ { tag: "Note", attr: {}, children: [ { tag: "Fig", attr: { src: "./pict/001.pdf" }, children: [], }, ], }, ], }, ], }; testLawtextToStd( lawtextWithMarker, expectedRendered, expectedValue, expectedErrorMessages, (vlines, env) => { const result = $appdxNote.match(0, vlines, env); // console.log(JSON.stringify(vlines, null, 2)); // if (result.ok) console.log(JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__parsed.json", JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__expected.json", JSON.stringify(expectedValue, undefined, 2)); return result; }, el => { const lines = appdxItemToLines(el, []); // console.log(JSON.stringify(lines, null, 2)); return lines; }, ); }); it("Success case", () => { /* eslint-disable no-irregular-whitespace */ const lawtextWithMarker = `\ :appdx-note: :note-struct: :ignore-title:2 Bは、超硬合金(日本産業規格H5501)とし、直径1/6a以上、長さ2/3a以上の円柱状のもの `; const expectedErrorMessages: string[] = []; const expectedRendered = `\ :appdx-note: :note-struct: :ignore-title:2 Bは、超硬合金(日本産業規格H5501)とし、直径1/6a以上、長さ2/3a以上の円柱状のもの `.replace(/\r?\n/g, "\r\n"); const expectedValue = { tag: "AppdxNote", attr: {}, children: [ { tag: "NoteStruct", attr: {}, children: [ { tag: "Note", attr: {}, children: [ { tag: "Column", attr: {}, children: [ { tag: "Sentence", attr: {}, children: ["2"] } ] }, { tag: "Column", attr: {}, children: [ { tag: "Sentence", attr: {}, children: ["Bは、超硬合金(日本産業規格H5501)とし、直径1/6a以上、長さ2/3a以上の円柱状のもの"] } ] } ] } ] } ] }; testLawtextToStd( lawtextWithMarker, expectedRendered, expectedValue, expectedErrorMessages, (vlines, env) => { const result = $appdxNote.match(0, vlines, env); // console.log(JSON.stringify(vlines, null, 2)); // if (result.ok) console.log(JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__parsed.json", JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__expected.json", JSON.stringify(expectedValue, undefined, 2)); return result; }, el => { const lines = appdxItemToLines(el, []); // console.log(JSON.stringify(lines, null, 2)); return lines; }, ); }); it("Success case", () => { /* eslint-disable no-irregular-whitespace */ const lawtextWithMarker = `\ :appdx-note:付録別記(第一条第一項、第九条関係)  :note-struct: # 別表第二 外国旅行の旅費(第三十五条―第三十七条、第三十九条、第四十条、第四十一条関係) `; const expectedErrorMessages: string[] = []; const expectedRendered = `\ :appdx-note:付録別記(第一条第一項、第九条関係) :note-struct: `.replace(/\r?\n/g, "\r\n"); const expectedValue = { tag: "AppdxNote", attr: {}, children: [ { tag: "AppdxNoteTitle", attr: {}, children: ["付録別記"], }, { tag: "RelatedArticleNum", attr: {}, children: ["(第一条第一項、第九条関係)"], }, { tag: "NoteStruct", attr: {}, children: [ { tag: "Note", attr: {}, children: [ { tag: "Fig", attr: { src: "./pict/001.pdf" }, children: [], }, ], }, ], }, ], }; testLawtextToStd( lawtextWithMarker, expectedRendered, expectedValue, expectedErrorMessages, (vlines, env) => { const result = $appdxNote.match(0, vlines, env); // console.log(JSON.stringify(vlines, null, 2)); // if (result.ok) console.log(JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__parsed.json", JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__expected.json", JSON.stringify(expectedValue, undefined, 2)); return result; }, el => { const lines = appdxItemToLines(el, []); // console.log(JSON.stringify(lines, null, 2)); return lines; }, ); }); it("Success case", () => { /* eslint-disable no-irregular-whitespace */ const lawtextWithMarker = `\ # 別記第二号(第一条第一項、第九条関係) :note-struct: # 別表第二 外国旅行の旅費(第三十五条―第三十七条、第三十九条、第四十条、第四十一条関係) `; const expectedErrorMessages: string[] = []; const expectedRendered = `\ # 別記第二号(第一条第一項、第九条関係) :note-struct: `.replace(/\r?\n/g, "\r\n"); const expectedValue = { tag: "AppdxNote", attr: {}, children: [ { tag: "AppdxNoteTitle", attr: {}, children: ["別記第二号"], }, { tag: "RelatedArticleNum", attr: {}, children: ["(第一条第一項、第九条関係)"], }, { tag: "NoteStruct", attr: {}, children: [ { tag: "Note", attr: {}, children: [ { tag: "Fig", attr: { src: "./pict/001.pdf" }, children: [], }, ], }, ], }, ], }; testLawtextToStd( lawtextWithMarker, expectedRendered, expectedValue, expectedErrorMessages, (vlines, env) => { const result = $appdxNote.match(0, vlines, env); // console.log(JSON.stringify(vlines, null, 2)); // if (result.ok) console.log(JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__parsed.json", JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__expected.json", JSON.stringify(expectedValue, undefined, 2)); return result; }, el => { const lines = appdxItemToLines(el, []); // console.log(JSON.stringify(lines, null, 2)); return lines; }, ); }); it("Success case", () => { /* eslint-disable no-irregular-whitespace */ const lawtextWithMarker = `\ # 別記第二号(第一条第一項、第九条関係) :note-struct: 備考 備考文 # 別表第二 外国旅行の旅費(第三十五条―第三十七条、第三十九条、第四十条、第四十一条関係) `; const expectedErrorMessages: string[] = []; const expectedRendered = `\ # 別記第二号(第一条第一項、第九条関係) :note-struct: 備考 備考文 `.replace(/\r?\n/g, "\r\n"); const expectedValue = { tag: "AppdxNote", attr: {}, children: [ { tag: "AppdxNoteTitle", attr: {}, children: ["別記第二号"], }, { tag: "RelatedArticleNum", attr: {}, children: ["(第一条第一項、第九条関係)"], }, { tag: "NoteStruct", attr: {}, children: [ { tag: "Note", attr: {}, children: [ { tag: "Fig", attr: { src: "./pict/001.pdf" }, children: [], }, ], }, ], }, { tag: "Remarks", attr: {}, children: [ { tag: "RemarksLabel", attr: {}, children: ["備考"], }, { tag: "Sentence", attr: {}, children: ["備考文"], }, ], }, ], }; testLawtextToStd( lawtextWithMarker, expectedRendered, expectedValue, expectedErrorMessages, (vlines, env) => { const result = $appdxNote.match(0, vlines, env); // console.log(JSON.stringify(vlines, null, 2)); // if (result.ok) console.log(JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__parsed.json", JSON.stringify(result.value.value.json(false), undefined, 2)); // if (result.ok) writeFileSync("out__expected.json", JSON.stringify(expectedValue, undefined, 2)); return result; }, el => { const lines = appdxItemToLines(el, []); // console.log(JSON.stringify(lines, null, 2)); return lines; }, ); }); });