diff --git a/src/Markdig/Parsers/BlockProcessor.cs b/src/Markdig/Parsers/BlockProcessor.cs
index de3ef0fc..efea3f43 100644
--- a/src/Markdig/Parsers/BlockProcessor.cs
+++ b/src/Markdig/Parsers/BlockProcessor.cs
@@ -444,6 +444,8 @@ namespace Markdig.Parsers
{
CurrentLineStartPosition = newLine.Start;
+ Document.LineStartIndexes?.Add(CurrentLineStartPosition);
+
ContinueProcessingLine = true;
ResetLine(newLine);
diff --git a/src/Markdig/Parsers/MarkdownParser.cs b/src/Markdig/Parsers/MarkdownParser.cs
index 02809193..f3f16f9d 100644
--- a/src/Markdig/Parsers/MarkdownParser.cs
+++ b/src/Markdig/Parsers/MarkdownParser.cs
@@ -85,6 +85,9 @@ namespace Markdig.Parsers
/// A document instance
private MarkdownDocument Parse()
{
+ if (preciseSourceLocation)
+ document.LineStartIndexes = new List();
+
ProcessBlocks();
ProcessInlines();
diff --git a/src/Markdig/Syntax/MarkdownDocument.cs b/src/Markdig/Syntax/MarkdownDocument.cs
index 8b0a29b9..7e091df9 100644
--- a/src/Markdig/Syntax/MarkdownDocument.cs
+++ b/src/Markdig/Syntax/MarkdownDocument.cs
@@ -1,6 +1,8 @@
// Copyright (c) Alexandre Mutel. All rights reserved.
// This file is licensed under the BSD-Clause 2 license.
// See the license.txt file in the project root for more information.
+using System.Collections.Generic;
+
namespace Markdig.Syntax
{
///
@@ -20,5 +22,11 @@ namespace Markdig.Syntax
/// Gets the number of lines in this
///
public int LineCount;
+
+ ///
+ /// Gets a list of zero-based indexes of line beginnings in the source span
+ /// Available if is used, otherwise null
+ ///
+ public List LineStartIndexes;
}
}
\ No newline at end of file