Closed akabekobeko closed 3 years ago
値の型が Object であるプロパティで値を指定しないとエラーになります。
例:
---
html:
---
↓
/Users/shinyu/viv/vfm/lib/plugins/metadata.js:119
for (var _i = 0, _a = Object.keys(data); _i < _a.length; _i++) {
^
TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at readAttributes (/Users/shinyu/viv/vfm/lib/plugins/metadata.js:119:34)
at Object.readMetadata (/Users/shinyu/viv/vfm/lib/plugins/metadata.js:180:33)
at Object.stringify (/Users/shinyu/viv/vfm/lib/index.js:104:45)
at compile (/Users/shinyu/viv/vfm/lib/cli.js:41:20)
at Interface.<anonymous> (/Users/shinyu/viv/vfm/lib/cli.js:64:13)
at Interface.emit (node:events:394:28)
at Interface.pause (node:readline:597:8)
at Interface.close (node:readline:581:8)
at ReadStream.onend (node:readline:277:10)
---
vfm:
---
↓
/Users/shinyu/viv/vfm/lib/plugins/metadata.js:153
math: typeof data.math === 'boolean' ? data.math : undefined,
^
TypeError: Cannot read property 'math' of null
at readSettings (/Users/shinyu/viv/vfm/lib/plugins/metadata.js:153:27)
at Object.readMetadata (/Users/shinyu/viv/vfm/lib/plugins/metadata.js:188:33)
at Object.stringify (/Users/shinyu/viv/vfm/lib/index.js:104:45)
at compile (/Users/shinyu/viv/vfm/lib/cli.js:41:20)
at Interface.<anonymous> (/Users/shinyu/viv/vfm/lib/cli.js:64:13)
at Interface.emit (node:events:394:28)
at Interface.pause (node:readline:597:8)
at Interface.close (node:readline:581:8)
at ReadStream.onend (node:readline:277:10)
at ReadStream.emit (node:events:406:35)
試しに空文字列 "" を指定すると、エラーにはなりません。値指定なしの場合にもこれと同様になるとよいと思います:
---
html: ""
vfm: ""
---
↓
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body></body>
</html>
@MurakamiShinyu
key のみ指定 = null の場合にエラーとなる問題を修正しました。レビューをお願いします。metadata.test.md
のテストとしては念の為に vfm
のような Object
だけでなく入れ子の Array<Object>
である meta
も対象としました。
@akabekobeko
vfm:
について直っていないようです。
--- vfm: ---
↓
/Users/shinyu/viv/vfm/lib/plugins/metadata.js:153 math: typeof data.math === 'boolean' ? data.math : undefined, ^ TypeError: Cannot read property 'math' of null at readSettings (/Users/shinyu/viv/vfm/lib/plugins/metadata.js:153:27) at Object.readMetadata (/Users/shinyu/viv/vfm/lib/plugins/metadata.js:188:33) at Object.stringify (/Users/shinyu/viv/vfm/lib/index.js:104:45) at compile (/Users/shinyu/viv/vfm/lib/cli.js:41:20) at Interface.<anonymous> (/Users/shinyu/viv/vfm/lib/cli.js:64:13) at Interface.emit (node:events:394:28) at Interface.pause (node:readline:597:8) at Interface.close (node:readline:581:8) at ReadStream.onend (node:readline:277:10) at ReadStream.emit (node:events:406:35)
@MurakamiShinyu
すみません vfm
だけ別関数で処理してて対応が抜けてました。修正したので再レビューをお願いします。
111 修正。
@MurakamiShinyu レビューをお願いします。https://github.com/vivliostyle/vfm/issues/111#issuecomment-871301117 のとおり key のみ指定を空文字として扱い、またこれまで空文字で書き込みをスキップしていた
id
やtitle
なども属性値や要素の値を空文字として出力するようにしました。