[PR #241] Expose the number of lines in a document #891

Open
opened 2026-01-29 14:46:52 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/xoofx/markdig/pull/241

State: closed
Merged: Yes


I think this would be a nice feature to have (I know I need it).

I've tried to do it by using a block parser just to count lines, but, while it worked, it seemed overkill considering the value is already known, just hidden.

private class LineCounter : BlockParser
{
    public int Count => _count + 1;
    private int _count = -1;
    public override BlockState TryOpen(BlockProcessor processor)
    {
        _count = processor.LineIndex;
        return BlockState.None;
    }
}
**Original Pull Request:** https://github.com/xoofx/markdig/pull/241 **State:** closed **Merged:** Yes --- I think this would be a nice feature to have (I know I need it). I've tried to do it by using a block parser just to count lines, but, while it worked, it seemed overkill considering the value is already known, just hidden. ```csharp private class LineCounter : BlockParser { public int Count => _count + 1; private int _count = -1; public override BlockState TryOpen(BlockProcessor processor) { _count = processor.LineIndex; return BlockState.None; } } ```
claunia added the pull-request label 2026-01-29 14:46:53 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#891