Expose line start indexes

This commit is contained in:
Miha Zupan
2018-09-25 00:56:36 +02:00
parent 9a74f3708e
commit f3bb06531e
3 changed files with 13 additions and 0 deletions

View File

@@ -444,6 +444,8 @@ namespace Markdig.Parsers
{
CurrentLineStartPosition = newLine.Start;
Document.LineStartIndexes?.Add(CurrentLineStartPosition);
ContinueProcessingLine = true;
ResetLine(newLine);

View File

@@ -85,6 +85,9 @@ namespace Markdig.Parsers
/// <returns>A document instance</returns>
private MarkdownDocument Parse()
{
if (preciseSourceLocation)
document.LineStartIndexes = new List<int>();
ProcessBlocks();
ProcessInlines();

View File

@@ -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
{
/// <summary>
@@ -20,5 +22,11 @@ namespace Markdig.Syntax
/// Gets the number of lines in this <see cref="MarkdownDocument"/>
/// </summary>
public int LineCount;
/// <summary>
/// Gets a list of zero-based indexes of line beginnings in the source span
/// <para>Available if <see cref="MarkdownPipelineBuilder.PreciseSourceLocation"/> is used, otherwise null</para>
/// </summary>
public List<int> LineStartIndexes;
}
}