New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

asciidoc-loader

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asciidoc-loader

Compiles asciidoc with asciidoctor.js

  • 0.2.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

asciidoc-loader

This is a Webpack loader that allows you to import Asciidoc .adoc files that contain include and image directives. The result is content that you can pass directly to asciidoctor.js.

Currently, the lineoffset parameter of the include directive is supported, but lines, tag, and indent are not. All parameters of the image directive are passed through to asciidoctor unchanged.

import index from '!asciidoc-loader!../../docs/index.adoc';

export default function Docs() {
  return (
    <Asciidoc
      source={index}
      attrs={{system: 'atlas'}}/>
  );
}

Below is the Asciidoc React component that uses asciidoctor.js to render and highlight.js to syntax highlight code blocks:

import React, {Component} from 'react';
import PropTypes from 'prop-types';
import 'asciidoctor.js/dist/css/asciidoctor.css';
import hljs from 'highlight.js';
import 'highlight.js/styles/github.css';

let asciidoctor = require('asciidoctor.js')();

export default class Asciidoc extends Component {
  constructor(props) {
    super(props);
    this.highlightCode = this.highlightCode.bind(this);
  }

  componentDidMount() {
    this.highlightCode();
  }

  componentDidUpdate() {
    this.highlightCode();
  }

  highlightCode() {
    this.root.querySelectorAll('pre code').forEach(node => hljs.highlightBlock(node));
  }

  render() {
    let converted = asciidoctor.convert(this.props.source, { attributes: this.props.attrs, safe: 'safe'});
    return (
      <div
        ref={(root) => { this.root = root; }}
        dangerouslySetInnerHTML={{ __html: converted }} />
    )
  }
}

Asciidoc.propTypes = {
  source: PropTypes.string,
  attrs: PropTypes.any,
};

FAQs

Package last updated on 20 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc