Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Serialization API

オープン
#95 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
30/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
javascript
領域
api, compilers

調査の方向性

lib/node.js の 141-355 行付近から始め、提案されている AST 表現とカバレッジを理解するために test/spec/serialize.js と test/spec/deserialize.js を読んでください。完了とは、シリアライズ、デシリアライズ、public accessors、custom node data に関する Node API の要件が解決され、参照されている deep-equality の動作が維持されていることです。

索引モデルが issue の本文から書いたものです。

説明

I am now serializing and deserializing the AST with a 1:1 exact match such that it could be converted to a JSON document and back to an AST tree.

The rationale for this functionality is that I want to pipe an AST document between processes and felt that parsing documents on the way in and rendering on the way out was too much overhead.

The implementation is two static methods Node.serialize() and Node.deserialize(), I would like it if possible to add these methods to the commonmark Node class.

The code is here:

https://github.com/mkdoc/mkast/blob/aa0fa3c5bf4ca45e8c961ad14640543da60ec529/lib/node.js#L141-L355

The test specs serialize and deserialize have 100% coverage on those methods. Notably the deserialize spec ensures a 1:1 correlation with a deep equals comparison.

Note that we don't expose private properties in the serialized object so that iteration can consistently reference firstChild and next regardless of whether it is a full AST node (with parent references) or a detached serialized object.

During this process a few requests regarding public property access have arisen, could I please expose _lastLineBlank and _htmlBlockType with public getters?

Also at times I need to associate custom data with AST nodes and this has been a bit ad-hoc so far, hence the additional properties file etc. that I would like to tuck away in an object that commonmark Node supports, maybe userData or data?

If we can formalize a way to add custom data to nodes then I can update the serialize and deserialize methods to use that and it could be folded in to commonmark Node.

Thanks for all your help and patience - especially with those questions that deserved a RTFM response ;)

主要言語
JavaScript
スター
1.6k
フォーク
231
平均マージ
2日 17時間
マージ済み PR(30日)
2

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

commonmark/commonmark.js のほかの issue

commonmark/commonmark.js の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。