Socket
Socket
Sign inDemoInstall

@antora/asciidoc-loader

Package Overview
Dependencies
Maintainers
2
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antora/asciidoc-loader - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

lib/converter/create.js

13

lib/include/resolve-include-file.js

@@ -7,2 +7,3 @@ 'use strict'

const { EXAMPLES_DIR_TOKEN, PARTIALS_DIR_TOKEN } = require('../constants')
const RESOURCE_ID_DETECTOR_RX = /[$:@]/

@@ -27,3 +28,4 @@ /**

let placeholder
if (~target.indexOf('$')) {
if (RESOURCE_ID_DETECTOR_RX.test(target)) {
// NOTE support legacy {partialsdir} and {examplesdir} prefixes (same as resource ID w/ only family and relative)
if (target.startsWith(PARTIALS_DIR_TOKEN) || target.startsWith(EXAMPLES_DIR_TOKEN)) {

@@ -42,4 +44,5 @@ ;[family, relative] = splitOnce(target, '$')

})
} else {
resolved = catalog.resolveResource(target, { component: ctx.component, version: ctx.version, module: ctx.module })
// NOTE require family segment for now
} else if (~target.indexOf('$')) {
resolved = catalog.resolveResource(target, selectResourceId(ctx))
}

@@ -75,2 +78,6 @@ } else {

function selectResourceId ({ component, version, module, family, relative }) {
return { component, version, module, family, relative }
}
module.exports = resolveIncludeFile

@@ -10,4 +10,5 @@ 'use strict'

const asciidoctor = require('asciidoctor.js')()
const Extensions = asciidoctor.Extensions
const convertPageRef = require('./xref/convert-page-ref')
const createConverter = require('./create-converter')
const createConverter = require('./converter/create')
const createExtensionRegistry = require('./create-extension-registry')

@@ -20,2 +21,3 @@ const ospath = require('path')

const { EXAMPLES_DIR_TOKEN, PARTIALS_DIR_TOKEN } = require('./constants')
const EXTENSION_DSL_TYPES = Extensions.$constants(false).filter((name) => name.endsWith('Dsl'))

@@ -43,16 +45,2 @@ /**

function loadAsciiDoc (file, contentCatalog = undefined, config = {}) {
if (!config) config = {}
const envAttrs = {
env: 'site',
'env-site': '',
'site-gen': 'antora',
'site-gen-antora': '',
}
const defaultAttrs = {
'attribute-missing': 'warn',
'data-uri': null,
icons: 'font',
sectanchors: '',
'source-highlighter': 'highlight.js',
}
const fileSrc = file.src

@@ -71,5 +59,5 @@ const intrinsicAttrs = {

const pageAttrs = fileSrc.family === 'page' ? computePageAttrs(fileSrc, contentCatalog) : {}
const attributes = Object.assign({}, envAttrs, defaultAttrs, config.attributes, intrinsicAttrs, pageAttrs)
const attributes = Object.assign({}, config.attributes, intrinsicAttrs, pageAttrs)
const relativizePageRefs = config.relativizePageRefs !== false
const converter = createConverter(asciidoctor, {
const converter = createConverter({
onPageRef: (refSpec, content) => convertPageRef(refSpec, content, file, contentCatalog, relativizePageRefs),

@@ -80,7 +68,7 @@ })

})
if (config.extensions && config.extensions.length) {
const context = { file, contentCatalog, config }
config.extensions.forEach((extension) => extension.register(extensionRegistry, context))
const extensions = config.extensions || []
if (extensions.length) {
extensions.forEach((extension) => extension.register(extensionRegistry, { file, contentCatalog, config }))
}
return asciidoctor.load(file.contents.toString(), {
const doc = asciidoctor.load(file.contents.toString(), {
attributes,

@@ -91,2 +79,4 @@ converter,

})
if (extensions.length) freeExtensions()
return doc
}

@@ -98,3 +88,3 @@

attrs['page-component-name'] = fileSrc.component
attrs['page-component-version'] = fileSrc.version
attrs['page-component-version'] = attrs['page-version'] = fileSrc.version
const component = contentCatalog && contentCatalog.getComponent(fileSrc.component)

@@ -125,4 +115,6 @@ if (component) attrs['page-component-title'] = component.title

* Reads data from the asciidoc category of the playbook and resolves it into a global AsciiDoc configuration object
* that can be used by the loadAsciiDoc function. This configuration object is a shallow clone of the data in the
* playbook. The main purpose of this function is to resolve extension references in the playbook to extension
* that can be used by the loadAsciiDoc function. This configuration object consists of built-in attributes as well as a
* shallow clone of the data from the asciidoc category in the playbook.
*
* The main purpose of this function is to resolve extension references in the playbook to extension
* functions. If the extension is scoped, the function is stored in this object. If the extension is global, it is

@@ -133,3 +125,3 @@ * registered with the global extension registry, then discarded.

*
* @param {Object} playbook - The configuration object for Antora.
* @param {Object} playbook - The configuration object for Antora (default: {}).
* @param {Object} playbook.asciidoc - The AsciiDoc configuration data in the playbook.

@@ -139,6 +131,23 @@ *

*/
function resolveConfig (playbook) {
if (!playbook.asciidoc) return {}
const config = Object.assign({}, playbook.asciidoc)
function resolveConfig (playbook = {}) {
const attributes = {
env: 'site',
'env-site': '',
'site-gen': 'antora',
'site-gen-antora': '',
'attribute-missing': 'warn',
'data-uri': null,
icons: 'font',
sectanchors: '',
'source-highlighter': 'highlight.js',
}
if (playbook.site) {
const site = playbook.site
if (site.title) attributes['site-title'] = site.title
if (site.url) attributes['site-url'] = site.url
}
const config = { attributes }
if (!playbook.asciidoc) return config
// TODO process !name attributes
Object.assign(config, playbook.asciidoc, { attributes: Object.assign(attributes, playbook.asciidoc.attributes) })
if (config.extensions && config.extensions.length) {

@@ -157,5 +166,5 @@ const extensions = config.extensions.reduce((accum, extensionPath) => {

accum.push(extension)
} else if (!isExtensionRegistered(extension, asciidoctor.Extensions)) {
} else if (!isExtensionRegistered(extension, Extensions)) {
// QUESTION should we assign an antora-specific group name?
asciidoctor.Extensions.register(extension)
Extensions.register(extension)
}

@@ -179,3 +188,10 @@ return accum

/**
* Low-level operation to free objects from memory that have been weaved into an extension DSL module
*/
function freeExtensions () {
EXTENSION_DSL_TYPES.forEach((type) => (Opal.const_get_local(Extensions, type).$$included_in.length = 0))
}
module.exports = loadAsciiDoc
module.exports.resolveConfig = resolveConfig
{
"name": "@antora/asciidoc-loader",
"version": "1.1.0",
"version": "1.1.1",
"description": "Loads AsciiDoc content into an Asciidoctor Document object (AST) for use in an Antora documentation pipeline.",

@@ -5,0 +5,0 @@ "license": "MPL-2.0",

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