This is less redundant:
``` c#
ITextDocument document;
if (textDocumentFactoryService.TryGetTextDocument(textBuffer, out document))
{
    markdownTransform.DocumentToTransformPath = document.FilePath;
}
```