docsify icon indicating copy to clipboard operation
docsify copied to clipboard

Docsify can not render an embedded

Open fgaule opened this issue 4 years ago • 3 comments

Bug Report

Steps to reproduce

  1. Import tab plugin
  2. Create a .md file with a tab
  3. Import that .md into any other .m using the embedded feature

What is current behaviour

When you embedded a .md it is not being rendered.

What is the expected behaviour

When you embedded a .md should be rendered. In this case, tabs should be displayed as when they are inline.

Other relevant information

  • [ X] Bug does still occur when all/other plugins are disabled?

  • Your OS: iOS 10.15.7 (19H2)

  • Node.js version: v14.6.0

  • npm/yarn version: npm 6.14.7

  • Browser version: Chrome Version 88.0.4324.146 (Official Build) (x86_64)

  • Docsify version: docsify@4

  • Docsify plugins: docsify-tabs@1

Related issue

Please create a reproducible sandbox

https://github.com/fgaule/docsfy-embedded-not-rendering/tree/main/docs

Mention the docsify version in which this bug was not present (if any)

fgaule avatar Feb 08 '21 15:02 fgaule

From the linked issue originally filed in the docsify-tabs repo:

Unfortunately, this is a limitation of docsify's plugin system and not something that docsify-tabs can easily resolve. The short explanation is that docsify's plugin system functions at the page level, so there is no "hook" to leverage for processing content that is loaded via an embed.

Today we have beforeEach, afterEach, and doneEach plugin hooks, all of which operate on the page-level:

function(hook, vm) {
  hook.beforeEach(function(content, next) {
    // Invoked each time before parsing the Markdown file.
    // ...
    return content;
  });

  hook.afterEach(function(html, next) {
    // Invoked each time after the Markdown file is parsed.
    // ...
    return html;
  });

  hook.doneEach(function() {
    // Invoked each time after the data is fully loaded, no arguments,
    // ...
  });
}

Offering markdown-specific plugin hooks (e.g. beforeMarkdown and afterMarkdown) would give docsify the ability to create a separate, under-the-hood markdown-specific plugin pipeline that could be applied to all markdown content:

function(hook, vm) {
  hook.beforeEach(function() {
    // Invoked before loading new page content
    // Useful for cleanup/teardown
    // ...
  });

  hook.beforeMarkdown(function(md, next) {
    // Invoked before parsing Markdown
    // ...
    return md;
  });

  hook.afterMarkdown(function(html, next) {
    // Invoked after parsing Markdown
    // ...
    return html;
  });

  hook.doneEach(function() {
    // Invoked each time after the data is fully loaded, no arguments,
    // ...
  });
}

jhildenbiddle avatar Feb 08 '21 23:02 jhildenbiddle

I also encounter this problem, want to know how to solve

ayjw avatar Sep 22 '21 08:09 ayjw

We also ran into this issue with docsify-tabs and wrote our own plugin for tabs: useless-docsify-tabs. It doesn't have as many features as docsify-tabs but it does work when embedded.

Hyddan avatar Oct 12 '23 09:10 Hyddan

Marking as duplicate of more appropriately named issue: #2373

jhildenbiddle avatar Mar 02 '24 04:03 jhildenbiddle