It has a starting position (line and column index) and a length of how many characters it spans.
For example, this CommonMark source text:
> foo
The BlockQuote
node would have this source span: line 0, column 0, length 5.
The Paragraph
node inside it would have: line 0, column 2, length 3.
If a block has multiple lines, it will have a source span for each line.
Note that the column index and length are measured in Java characters (UTF-16 code units). If you're outputting them to be consumed by another programming language, e.g. one that uses UTF-8 strings, you will need to translate them, otherwise characters such as emojis will result in incorrect positions.
Modifier and Type | Field and Description |
---|---|
private final int | |
private final int | |
private final int |
Access | Constructor and Description |
---|---|
private |
Modifier and Type | Method and Description |
---|---|
public boolean | equals(Object
the reference object with which to compare. o)Overrides java. Indicates whether some other object is "equal to" this one. |
public int | |
public int | |
public int | |
public int | |
public static SourceSpan | |
public String |
columnIndex | back to summary |
---|---|
private final int columnIndex |
length | back to summary |
---|---|
private final int length |
lineIndex | back to summary |
---|---|
private final int lineIndex |
SourceSpan | back to summary |
---|---|
private SourceSpan(int lineIndex, int columnIndex, int length) |
equals | back to summary |
---|---|
public boolean equals(Object o) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. |
getColumnIndex | back to summary |
---|---|
public int getColumnIndex()
|
getLength | back to summary |
---|---|
public int getLength()
|
getLineIndex | back to summary |
---|---|
public int getLineIndex()
|
hashCode | back to summary |
---|---|
public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
|
of | back to summary |
---|---|
public static SourceSpan of(int lineIndex, int columnIndex, int length) |
toString | back to summary |
---|---|
public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- |