Add note about missing character for position.end · syntax-tree/unist@5565ad1 (original) (raw)

Original file line number Diff line number Diff line change
@@ -132,7 +132,7 @@ interface Position {
132 132 The `start` field of **Position** represents the place of the first character
133 133 of the parsed source region.
134 134 The `end` field of **Position** represents the place of the first character
135 -after the parsed source region.
135 +after the parsed source region, whether it exists or not.
136 136 The value of the `start` and `end` fields implement the [**Point**][dfn-point]
137 137 interface.
138 138
@@ -143,6 +143,20 @@ If the syntactic unit represented by a node is not present in the source
143 143 [_file_][term-file] at the time of parsing, the node is said to be
144 144 [_generated_][term-generated] and it must not have positional information.
145 145
146 +For example, if the following value was represented as unist:
147 +
148 +```markdown
149 +alpha
150 +bravo
151 +```
152 +
153 +…the first word (`alpha`) would start at line `1`, column `1`, offset `0`, and
154 +end at line `1`, column `6`, offset `5`.
155 +The line feed would start at line `1`, column `6`, offset `5`, and end at line
156 +`2`, column `1`, offset `6`.
157 +The last word (`bravo`) would start at line `2`, column `1`, offset `6`, and
158 +end at line `2`, column `6`, offset `11`.
159 +
146 160 #### `Point`
147 161
148 162 ```idl