How to use asciidoctor - 9 common examples

To help you get started, we’ve selected a few asciidoctor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github phenomic / phenomic / packages / plugin-transform-asciidoc / src / index.js View on Github external
transform: ({
      file,
      contents,
    }: {|
      file: PhenomicContentFile,
      contents: Buffer,
    |}) => {
      debug(`transforming ${file.fullpath}`);
      const ad = asciidoctor();
      const doc = ad.load(contents, adDefaultOptions);
      const tags = doc.getAttribute("tags");

      const content = ad.convert(contents, adDefaultOptions);
      // $FlowFixMe it's here, I can feel it Flow
      const body = processor.processSync(content).contents;

      const partial = {
        ...extractMetaFromBodyNode(body),
        ...doc.attributes.$$smap,
        date:
          doc.getAttribute("date") || doc.getAttribute("revdate") || undefined,
        // title fallback
        title: doc.getAttribute("doctitle") || file.name,
        layout: doc.getAttribute("layout"),
        showdate: doc.getAttribute("nodate", true),
github integr8ly / tutorial-web-app / server.js View on Github external
const giteaClient = require('./gitea_client');
const gitClient = require('./git_client');
const bodyParser = require('body-parser');
const uuid = require('uuid');
const promMid = require('express-prometheus-middleware');
const Prometheus = require('prom-client');
const querystring = require('querystring');
const flattenDeep = require('lodash.flattendeep');
const proxy = require('express-http-proxy');
const { sync, closeConnection, getUserWalkthroughs, setUserWalkthroughs, validUrl } = require('./model');

const OPENSHIFT_PROXY_PATH = '/proxy/openshift';

const app = express();

const adoc = asciidoctor();

app.use(bodyParser.json());
app.use(OPENSHIFT_PROXY_PATH, proxy(`https://${process.env.OPENSHIFT_API}`, {
  proxyReqOptDecorator: function(proxyReqOpts, _) {
    proxyReqOpts.rejectUnauthorized = false
    return proxyReqOpts;
  }
}));

// prometheus metrics endpoint
app.use(
  promMid({
    metricsPath: '/metrics',
    collectDefaultMetrics: true,
    requestDurationBuckets: [0.1, 0.5, 1, 1.5]
  })
github phenomic / phenomic / packages / plugin-transform-asciidoc / src / transformer.js View on Github external
function processAsciidoc(text) {
  const ad = asciidoctor();
  const doc = ad.load(text, defaultOptions);
  const data = {
    ...doc.attributes.$$smap,
    contents: ad.convert(text, defaultOptions)
  };

  data.date =
    doc.getAttribute("date") || doc.getAttribute("revdate") || undefined;
  data.title = doc.getAttribute("doctitle");
  data.layout = doc.getAttribute("layout");
  data.showdate = doc.getAttribute("nodate", true);
  data.tags = doc.getAttribute("tags");
  data.tags = data.tags
    ? data.tags.split(",").map(tag => kebabCase(deburr(tag)))
    : [];
github integr8ly / tutorial-web-app / src / components / asciiDocTemplate / asciiDocTemplate.js View on Github external
getDocContent() {
    if (this.props.template) {
      return this.state.docContent;
    }
    const adoc = Asciidoctor();
    if (!this.state.docContent) {
      return null;
    }
    return adoc.convert(this.state.docContent, { loaded: true, attributes: this.props.attributes });
  }
github Gisto / Gisto / src / components / common / editor / Asciidoc.js View on Github external
const Asciidoc = ({ text, className }) => {
  const asciidoctor = Asciidoctor();
  const html = asciidoctor.convert(text);

  return (
    <div>
  );
};
</div>
github grissius / emily-editor / src / modes / asciidoc.js View on Github external
const React = require('react');
const Asciidoctor = require('asciidoctor.js');
const bootstrap = require('./boostrap');

const asciidoctor = Asciidoctor();
require('asciidoctor-html5s');

const options = {
  attributes: {
    showtitle: true,
    icons: 'fonts@',
    'source-highlighter': 'highlightjs@',
  },
  backend: 'html5s',
};

const fetchReferences = (adocDoc, transformValue = null) =&gt; adocDoc.$references().$fetch('ids').$to_a().map(([key, content]) =&gt; {
  const caption = content.replace(/&lt;[^&gt;]*&gt;?/g, '');
  return {
    value: transformValue ? transformValue(key, caption) : key,
    caption,
github integr8ly / tutorial-web-app / src / common / walkthroughHelpers.js View on Github external
const parseAdoc = (rawAdoc, attrs) => asciidoctor().load(rawAdoc, { attributes: attrs });
github asciidoctor / asciidoctor-vscode / src / AsciiDocProvider.ts View on Github external
}
}

export default class AsciiDocProvider implements TextDocumentContentProvider {
    static scheme = 'adoc-preview';

    private _onDidChange = new EventEmitter();
    private resultText = "";
    private lastPreviewHTML = null;
    private lastURI = null;
    private needsRebuild : boolean = true;
    private editorDocument: TextDocument = null;
    private refreshInterval = 1000;


    private asciidoctor = Asciidoctor(asciidoctor_config);

    private resolveDocument(uri: Uri): TextDocument {
        const matches = workspace.textDocuments.filter(d =&gt; {
            return MakePreviewUri(d).toString() == uri.toString();
        });
        if (matches.length &gt; 0) {
            return matches[0];
        } else {
            return null;
        }
    }

    public provideTextDocumentContent(uri: Uri): string | Thenable {
        const doc = this.resolveDocument(uri);
        return this.createAsciiDocHTML(doc);
    }
github Talend / component-runtime / component-tools-webapp / src / main / frontend / src / store / componentsList / actions.js View on Github external
return () => {
        if (!cache.instance) {
            cache.instance = asciidoctorFactory();
        }
        return cache.instance;
    };
}();

asciidoctor

A JavaScript AsciiDoc processor, cross-compiled from the Ruby-based AsciiDoc implementation, Asciidoctor, using Opal

MIT
Latest version published 9 months ago

Package Health Score

63 / 100
Full package analysis

Popular asciidoctor functions