question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Transclusion of _inline_ markdown?

See original GitHub issue

Hi. Markdown file transclusion (MFT) is super cool, but I cannot find a way to do the equivalent when all of the markdown is defined in the same file. Something like:

// page.mdx
import FancyLayout from '../components/FancyLayout

# Title

[1] Parsed _markdown_ content

<FancyLayout>
  [2] More parsed _markdown_ content, in a fancy layout
</FancyLayout>

I would like [2] to be parsed as markdown, but not sure how, beyond defining it in a separate file and using MFT. I’d like to keep it all in one file, though, for the sake of non-technical authors. Do I need to somehow make FancyLayout an MDX-savvy component?

If it’s relevant, I’m using gatsby-mdx on a brand-new gatsby-starter-default.

Thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:36
  • Comments:22 (10 by maintainers)

github_iconTop GitHub Comments

7reactions
kylegachcommented, Aug 28, 2018

What if mdx exported a function that took in mdx-friendly syntax (as a string, I assume) and output parsed content. Then a consumer could make a component using that function and include it:

// page.mdx
import FancyLayout from '../components/FancyLayout

# Title

[1] Parsed _markdown_ content

<FancyLayout>
  <MDXParser>
    [2] More parsed _markdown_ content, in a fancy layout
  </MDXParser>
</FancyLayout>

Of course, that MDXParser (name tbd) could then be integrated within FancyLayout, for a better authoring experience.

For simplicity, you could also restrict MDXParser from allowing imports/exports (at least for my use case).

6reactions
silvenoncommented, Oct 4, 2018

It appears that all of us forgot to check if that syntax actually works in MDX 🤣

Edit yj7y73qwpv

It appears that it does, please confirm if this is what you wanted.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Transclusion or including sub-documents for reuse - Extensions
I have implemented this in a code documentation tool I'm writing, with the following syntax: {{ my_file }} -> include the file and...
Read more >
Zettelmarkup: Inline-mode Transclusion - Zettelstore
Inline-mode transclusion applies to all zettel that are parsed in a non-trivial way, e.g. as structured textual content. For example, textual content is ......
Read more >
Simpler transclusion syntax - Feedback | Docusaurus
Embed a markdown file content into your current document. ... Simpler transclusion syntax ... It would be nice if one could import a...
Read more >
Better export inline transclusions? - Obsidian Forum
Is there any way I can make the inline transclusion take less space? This would help make the page more concise and print...
Read more >
jamesramsay/hercule: Simple document transclusion, ideal for ...
Hercule extends the Markdown inline link syntax with a leading colon ( : ) to denote the link should be transcluded. The content...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found