Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

embed code fragments from external sources #205

Open
jthegedus opened this issue Mar 21, 2019 · 8 comments · May be fixed by #246
Open

embed code fragments from external sources #205

jthegedus opened this issue Mar 21, 2019 · 8 comments · May be fixed by #246
Labels
💵 Funded on Issuehunt This issue has been funded on Issuehunt feature request

Comments

@jthegedus
Copy link

jthegedus commented Mar 21, 2019

Issuehunt badges

I would like to import fenced code from GitHub repo files similar to https://docsify.js.org/#/embed-files?id=embedded-code-fragments

Is this on the roadmap?


IssueHunt Summary

Sponsors (Total: $100.00)

Become a sponsor now!

Or submit a pull request to get the deposits!

Tips

@egoist
Copy link
Owner

egoist commented Mar 22, 2019

Yeah but probably using a different syntax, like:

<!-- embed foo.js as code block -->
#embed(/foo.js code language="js")

<!-- result: -->
```js
// content in foo.js
```

A fragment:

#embed(/foo.md fragment)

<!-- result: -->

something to embed

Where foo.md looks like:

# title

<!-- docute-embed-start -->

something to embed

<!-- docute-embed-end -->

@jthegedus
Copy link
Author

jthegedus commented Mar 22, 2019

Sounds great! A couple more things 😛 is it possible to add support for:

  • these files to be externally loaded?
  • adding arbitrary fencing?

For instance:

<!-- embed example.js as code block -->
#embed(
  https://raw.githubusercontent.com/someuser/somerepo/code/example.js
  type=code
  language="js"
  fence="some-demo"
)

<!-- .../example.js -->
...
/// [some-demo-start]
...
/// [some-demo-end]
...

<!-- result -->
// some content from example.js within the /// [some-demo]

and then

<!-- import content from other .md file -->
#embed(
  https://raw.githubusercontent.com/someuser/somerepo/example.md
  type=fragment
  fence="some-fragment"
)

<!-- .../exmaple.md -->
...
<!-- some-fragment-start -->
something to embed
<!-- some-fragment-end -->
...

Being able to define the fence allows multiple partials from a single file to be imported.

Externally loading code decouples the need for it to live alongside the documentation, say in an examples repo.

@egoist
Copy link
Owner

egoist commented Mar 23, 2019

The api.processMarkdown(fn) API now can return a Promise:

屏幕快照 2019-03-23 下午6 30 29

You can probably implement it as a plugin using this API:

const embedPlugin = () => {
  return {
    name: 'embed',
    extend(api) {
      api.processMarkdown(async markdown => {
        return modifiedMarkdown
      })
    }
  }
}

new Docute({
  plugins: [embedPlugin()]
})

@jthegedus
Copy link
Author

Sweet, I'll give this a go soon! Cheers!

@issuehunt-oss issuehunt-oss bot added the 💵 Funded on Issuehunt This issue has been funded on Issuehunt label Jun 9, 2019
@IssueHuntBot
Copy link

@issuehunt has funded $100.00 to this issue.


@janat08
Copy link

janat08 commented Jun 13, 2019

Can i take this?

@jthegedus
Copy link
Author

@janat08 Feel free. I got caught up with life!

@janat08 janat08 linked a pull request Jun 17, 2019 that will close this issue
@janat08
Copy link

janat08 commented Jan 29, 2020

@egoist please merge, its been half a year

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💵 Funded on Issuehunt This issue has been funded on Issuehunt feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants