huy-nguyen / gatsby-remark-github

GatsbyJS plugin to replace links to GitHub files in Markdown files with the actual content of those files
5 stars 3 forks source link

Disable code formatting enclosing #8

Open cadeuh opened 5 years ago

cadeuh commented 5 years ago

Hey, I just stumbled upon your plugin which would fit me perfectly for one of my projects.

I'd like to include for example a subset of a Github Markdown file, rather than a code snippet, so i'd like to disable the ``` formatting enclosing the embedded file. So, basically embedding a Github Markdown file (or a subset of that file) inside my Markdown page.

Do you think I could achieve this with your plugin?

huy-nguyen commented 5 years ago

Hi @cadeuh. How often do you want to do this embedding? Is it just a one-time task or something you plan to do frequently in your project?

cadeuh commented 5 years ago

It's something I would use on multiples pages of the site. To give you more context, this is a developer documentation Gatsby site, we want to keep the markdown files (Readmes and other documentation) on the github repos as the main source of truth. The Gatsby site should just download and read these files on the fly.

There are other solutions/plugins that allow downloading github files to create Gatsby nodes directly. But yours is the only one that would allow me to have my Gatsby markdown pages importing multiple markdown github files, because I don't want to replicate the exact same archictecture from Github to Gatsby.

For example let's say I have 4 markdown files on my github codebase repo at different locations, and I want all these files to be displayed on one Gatsby page, I'd use your plugin to embed the 4 markdown files in my Gatsby markdown page.

(And I would also use the regular feature, importing code snippets.) Hope I'm being clear enough :)

huy-nguyen commented 5 years ago

Thanks for clarifying. I think it's not hard to do what you want. I'm wondering how to accommodate your need in addition to the existing functionality. When I created this library, I was looking for some quick solution so I came up with the idea of using simple user-defined delimiters e.g. GITHUB-EMBED to mark where the plugin should read information about the GitHub file/lines to pull from and the desired language. That feels like a hack to me. I'm wondering if there's a better way to encode this information (more like configuration) as an addition to the markdown syntax that doesn't conflict with the existing markdown syntax, something like the YAML frontmatter but in the middle of the markdown file:

file: https://github.com/lodash/lodash/blob/2900cfd/sumBy.js
language: javascript
range: 1,2,27-31

I'll ask this question on Spectrum's gatsby channel but feel free to suggest your own solution.