Code Monkey home page Code Monkey logo

remark-code-screenshot's Introduction

remark-code-screenshot

Remark plugin to convert code blocks into carbon.now.sh screenshots.

Basic Usage

import remark from 'remark'
import codeScreenshot from 'remark-code-screenshot'

const markdownInput = ["```
    import remark from 'remark'
    import codeScreenshot from 'remark-code-screenshot'

    const markdownInput = \"\"

    remark().use(codeScreenshot)
    .process(markdownInput, function (err, output) {
        console.log(output)
    })
```"]

remark()
    .use(codeScreenshot)
    .process(markdownInput, function (err, output) {
        console.log(output)
    });

Outputs something like this:

remark-code-screenshot's People

Contributors

swizec avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

remark-code-screenshot's Issues

remark@next (13)

Hi!

remark is switching to a new parser internally (micromark, see remarkjs/remark#536 for more info).
From a quick glance at the code, it seems this plugin should be fine. However, it would be good to check that in the future (there is 13.0.0-alpha.0 published now, and one or two more will come before the release)

ERROR ReferenceError: btoa is not defined

I'm using this plugin with mdx.js - https://mdxjs.com/ and next.js - https://nextjs.org/

The project is located at - https://github.com/robertsmieja/nextjs-md-sandbox

Steps the reproduce:

  1. Uncomment the remark-code-screenshot plugin in next.config.js
  2. npm run dev

This is the code that seems be causing the issue:

var getCodeScreenshot = function () {
    var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee(src) {
        var codeType, srcArg, res;
        return _regenerator2.default.wrap(function _callee$(_context) {
            while (1) {
                switch (_context.prev = _context.next) {
                    case 0:
                        codeType = "javascript", srcArg = btoa(src);
                        _context.next = 3;
                        return fetch("https://84wz7ux5rc.execute-api.us-east-1.amazonaws.com/default/screenshot-as-a-service-dev-screenshot-function?type=code&code=" + srcArg + "&codeType=" + codeType);

                    case 3:
                        res = _context.sent;
                        return _context.abrupt("return", res.text());

                    case 5:
                    case "end":
                        return _context.stop();
                }
            }
        }, _callee, this);
    }));

    return function getCodeScreenshot(_x) {
        return _ref.apply(this, arguments);
    };
}();

OS: Windows 10 64-bit
Node.js: v12.16.0
npm: 6.13.4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.