Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

asciidoctor-wasm

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asciidoctor-wasm

## Overview

  • 0.2023.19
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Asciidoctor WASM

Overview

This module provides an interface for converting Asciidoctor content to various formats using WebAssembly. It supports conversion to html5, docbook5, and manpage backends, and allows for customization through various options. The conversion is powered by Ruby's Asciidoctor library running in a WebAssembly (WASM) environment.

Playground

You can try out the Asciidoctor WASM in the Playground.

Installation

Ensure you have Node.js installed, then install the necessary dependencies:

npm install asciidoctor-wasm

Usage

Importing the Module

You can import the necessary functions and constants from the module:

// Node
import { Asciidoctor, wasmURL } from "asciidoctor-wasm/dist/node.js";
// Browser or Deno
import { Asciidoctor, wasmURL } from "asciidoctor-wasm/dist/browser.js";

Initializing the Converter

From a WebAssembly Module

To initialize the Asciidoctor converter from a WebAssembly module:

const wasmURL = import.meta.resolve('asciidoctor-wasm/dist/asciidoctor.wasm');
const module = await WebAssembly.compileStreaming(fetch(wasmURL));
const asciidoctor = await Asciidoctor.initFromModule(module);
From a WebAssembly URL

To initialize the Asciidoctor converter from a WebAssembly binary located at a URL:

const wasmURL = import.meta.resolve('asciidoctor-wasm/dist/asciidoctor.wasm');
const asciidoctor = await Asciidoctor.initFromURL(wasmURL);
From a WebAssembly Path

To initialize the Asciidoctor converter from a WebAssembly binary located at a path:

import {fileURLToPath} from 'node:url';
const wasmURL = import.meta.resolve('asciidoctor-wasm/dist/asciidoctor.wasm');
const wasmPath = fileURLToPath(wasmURL);
const asciidoctor = await Asciidoctor.initFromPath(wasmPath);

Converting Asciidoctor Content

Once the converter is initialized, you can use it to convert Asciidoctor content:

const asciidoctorContent = "= Asciidoctor\nDoc Writer\n\nHello, Asciidoctor!";
const options: AsciidoctorOptions = {
  backend: "html5",
  doctype: "article",
  standalone: true,
};

const convertedContent = await asciidoctor.convert(asciidoctorContent, options);
console.log(convertedContent);

Versioning

This module follows the versioning of the Asciidoctor library it is based on.

  • 0.<asciidoctor>.<asciidoctor-wasm>
    • <asciidoctor>: Asciidoctor version; e.g., 2023 is based on Asciidoctor 2.0.23.
    • <asciidoctor-wasm>: Asciidoctor WebAssembly module version.

License

WASM binary contains a copy of several OSSs as follows:

If you notice the missing license information, please let us know.

This project is licensed under the MIT License. See the LICENSE file for details.

FAQs

Package last updated on 16 Jun 2024

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