`preserveOrder: true` with `format: true`: output starts with a line break and has none at the end — intended?
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 54/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- javascript
- 領域
- backend
調査の方向性
Start with spec/j2x_ordered_spec.js and the toXml() formatting path mentioned in the issue. Compare the ordered and keyed outputs for the same input, including the case with ?xml, and check how the existing specs define the leading and trailing line breaks. Done means the intended behavior is decided and the output and specs agree.
索引モデルが issue の本文から書いたものです。
説明
Description
With format: true, the ordered mode and the keyed mode put line breaks in different places for the same document:
- The ordered mode starts the output with a line break and doesn't end it with one.
- The keyed mode starts directly with the root element and ends with a line break.
When the input starts with ?xml, the ordered mode writes no line break before the declaration. So the ordered mode isn't consistent with itself either. The top-level indentation in toXml() is the line break itself, and only ?xml is exempt from it (tempInd).
Code
import XMLBuilder from "fast-xml-builder"; // 1.3.1
const ordered = new XMLBuilder({ format: true, preserveOrder: true, ignoreAttributes: false });
const keyed = new XMLBuilder({ format: true });
ordered.build([{ root: [{ a: [{ "#text": "1" }] }] }]);
keyed.build({ root: { a: "1" } });
ordered.build([
{ "?xml": [], ":@": { "@_version": "1.0" } },
{ root: [{ a: [{ "#text": "1" }] }] },
]);
Output
"\n<root>\n <a>1</a>\n</root>"
"<root>\n <a>1</a>\n</root>\n"
"<?xml version=\"1.0\"?>\n<root>\n <a>1</a>\n</root>"
Question
Several specs expect the leading line break, for example "should build formatted XML" in spec/j2x_ordered_spec.js. So I'm not sure whether this is intended. Would you accept a change that makes the ordered mode behave like the keyed mode, either by default in a major version or behind an option? I'd be happy to open a PR.
Would you like to work on this issue?
- Yes
- No
- 主要言語
- JavaScript
- スター
- 22
- フォーク
- 9
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
NaturalIntelligence/fast-xml-builder のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
-
`preserveOrder: true` with `format: true` formats mixed content wrongly and adds whitespace to content that ends with `>`対応中かも @neumaennl が 8 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
`XMLBuilder` object should be exported as a named export, not just the type対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
NaturalIntelligence/fast-xml-builder#25 · コメント 1 件 ·
-
sanitizeName not applied to names inside stopNodes (quote injection / tag break-out bypass)対応中かも @hicay が 5 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
NaturalIntelligence/fast-xml-builder#34 · コメント 1 件 ·
-
enhancement
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
NaturalIntelligence/fast-xml-builder#4 · コメント 5 件 · リアクション 2 件 ·
NaturalIntelligence/fast-xml-builder の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 84/100
-
Extended search drops any query term that contains a line break対応中かも @goranai が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
area:mcp
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信