aboutsummaryrefslogtreecommitdiffstats
path: root/src/unist.rs
diff options
context:
space:
mode:
authorLibravatar Kyle McCarthy <km@kylemccarthy.io>2023-01-03 04:52:22 -0600
committerLibravatar GitHub <noreply@github.com>2023-01-03 11:52:22 +0100
commit2045b0bfc467efeb605aad7d8297a1fa1fc3e0e9 (patch)
tree7dab2abbf993e04b269fbab3191d7bfa7b7663ae /src/unist.rs
parentaf202d3f0ea24e0a957b02a6f9fb23c6c3b4afe7 (diff)
downloadmarkdown-rs-2045b0bfc467efeb605aad7d8297a1fa1fc3e0e9.tar.gz
markdown-rs-2045b0bfc467efeb605aad7d8297a1fa1fc3e0e9.tar.bz2
markdown-rs-2045b0bfc467efeb605aad7d8297a1fa1fc3e0e9.zip
Add support for serializing trees as JSON
This adds support for serializing the mdast syntax tree as JSON, with serde, through a feature. Closes GH-10. Related-to GH-30. Closes GH-37.
Diffstat (limited to 'src/unist.rs')
-rw-r--r--src/unist.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/unist.rs b/src/unist.rs
index 514e661..56f1abf 100644
--- a/src/unist.rs
+++ b/src/unist.rs
@@ -6,6 +6,7 @@ use alloc::fmt;
/// One place in a source file.
#[derive(Clone, Eq, PartialEq)]
+#[cfg_attr(feature = "json", derive(serde::Serialize, serde::Deserialize))]
pub struct Point {
/// 1-indexed integer representing a line in a source file.
pub line: usize,
@@ -34,6 +35,7 @@ impl fmt::Debug for Point {
/// Location of a node in a source file.
#[derive(Clone, Eq, PartialEq)]
+#[cfg_attr(feature = "json", derive(serde::Serialize, serde::Deserialize))]
pub struct Position {
/// Represents the place of the first character of the parsed source region.
pub start: Point,