atom / markdown-preview

📝 Markdown preview in Atom
MIT License
1.23k stars 358 forks source link

Including text/markdown from external files in the preview #333

Open andreasohlund opened 8 years ago

andreasohlund commented 8 years ago

I'm looking for a way to add support for pulling in text/markdown from external files and include that in the preview. What would be the best way to approach this?

Background

The way we do documentation for NServiceBus is by storing our docs as markdown files in a GH repo and render that repo into a static site. As part of doing this we support the concept of including code snippets using the following syntax in the .md file:

<!-- import NameOfTheSnippet -->

The reason to include the code from external files is that we have them included in a visual studio projects so that we can compile all snippets to ensure that the syntax is correct.

Example:

https://github.com/Particular/docs.particular.net/blob/master/nservicebus/rabbitmq/configuration-api.md

renders as

http://docs.particular.net/nservicebus/rabbitmq/configuration-api#configuring-rabbitmq-transport-to-be-used

and the included code snippets are pulled from

https://github.com/Particular/docs.particular.net/blob/master/Snippets/Snippets_5/Transports/RabbitMQ/Usage.cs

during rendering.

SimonCropp commented 8 years ago

The code for our snippets parsing is here https://github.com/SimonCropp/CaptureSnippets

lee-dohm commented 8 years ago

Rather than adding a feature to markdown-preview that is custom tailored to one target usage, could you create a package that post-processes the Markdown file to perform the import and then previews that?

andreasohlund commented 8 years ago

I guess you are saying:

  1. On save/preview generate a {filename}_preview.md markdown file somewhere
  2. Tell markdown preview to preview that file instead?

Is that correct?

lee-dohm commented 8 years ago

Yes, that's what I'm suggesting.

andreasohlund commented 8 years ago

Ok, any pointers how to "trick" markdown preview to show the generated file instead of the one being edited?