Socket
Socket
Sign inDemoInstall

@antora/assembler

Package Overview
Dependencies
23
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0-alpha.5 to 1.0.0-alpha.6

21

lib/asciidoctor/reducer-extension.js

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

const prevIncDepth = this.include_stack.length
let offset = lineno > 1 ? lineno - 1 : 0
const result = Opal.send(this, Opal.find_super_dispatcher(this, 'push_include', pushInclude), [

@@ -132,8 +133,8 @@ data,

])
pushIncludeReplacement.call(
this,
directiveLineno,
this.include_stack.length > prevIncDepth ? this.$lines() : [],
lineno > 1 ? lineno - 1 : 0
)
let incLines = []
if (this.include_stack.length > prevIncDepth) {
incLines = this.$lines()
if (attrs['$key?']('leveloffset') && incLines[0].startsWith(':leveloffset: ') && incLines[1] === '') offset -= 2
}
pushIncludeReplacement.call(this, directiveLineno, incLines, offset)
return result

@@ -179,4 +180,8 @@ })

targetLines = incReplacements[into].lines
// adds assurance that we're replacing the correct line
if (targetLines[(idx = lineno - 1)] !== line) return
// adds extra assurance that the program is replacing the correct line
if (targetLines[(idx = lineno - 1)] !== line) {
const msg = `include directive to reduce not found; expected: "${line}"; got: "${targetLines[idx]}"`
doc.getLogger().error(msg)
return
}
}

@@ -183,0 +188,0 @@ if ((drop || []).length) {

'use strict'
const camelCaseKeys = require('camelcase-keys')
const expandPath = require('@antora/expand-path-helper')

@@ -9,4 +8,2 @@ const { promises: fsp } = require('fs')

const CAMEL_CASE_KEYS_OPTS = { deep: true, stopPaths: ['asciidoc'] }
function loadConfig (playbook, configSource = './antora-assembler.yml') {

@@ -23,5 +20,3 @@ return (

.then((exists) =>
exists
? fsp.readFile(configSource).then((data) => camelCaseKeys(yaml.load(data), CAMEL_CASE_KEYS_OPTS))
: {}
exists ? fsp.readFile(configSource).then((data) => camelCaseKeys(yaml.load(data), ['asciidoc'])) : {}
)

@@ -66,2 +61,14 @@ ).then((config) => {

function camelCaseKeys (o, stopPaths = [], p) {
if (Array.isArray(o)) return o.map((it) => camelCaseKeys(it, stopPaths, p))
if (o == null || o.constructor !== Object) return o
const pathPrefix = p ? p + '.' : ''
const accum = {}
for (const [k, v] of Object.entries(o)) {
const camelKey = k.charAt() + k.substr(1).replace(/_([a-z])/g, (_, l) => l.toUpperCase())
accum[camelKey] = ~stopPaths.indexOf(pathPrefix + camelKey) ? v : camelCaseKeys(v, stopPaths, pathPrefix + camelKey)
}
return accum
}
module.exports = loadConfig

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

outline,
doctype,
pages,

@@ -20,3 +21,3 @@ asciidocConfig,

const stem = generateStem(componentVersion, navtitle)
const header = buildAsciiDocHeader(componentVersion, navtitle)
const header = buildAsciiDocHeader(componentVersion, navtitle, doctype)
const body = aggregateAsciiDoc(

@@ -49,9 +50,9 @@ loadAsciiDoc,

function buildAsciiDocHeader (componentVersion, navtitle) {
function buildAsciiDocHeader (componentVersion, navtitle, doctype = 'book') {
const doctitle = navtitle === componentVersion.title ? navtitle : `${componentVersion.title}: ${navtitle}`
const version = componentVersion.version && componentVersion.version !== 'master' ? componentVersion.version : ''
const version = componentVersion.version === 'master' ? '' : componentVersion.version
return [
`= ${doctitle}`,
...(version ? [`v${version}`] : []),
':doctype: book', // for debugging only; set via CLI
...(doctype === 'article' ? [] : [`:doctype: ${doctype}`]),
// Q: should we pass these via the CLI so they cannot be modified?

@@ -214,2 +215,7 @@ `:page-component-name: ${componentVersion.name}`,

let line = lines[idx]
if (line.charAt() === ':' && /^:(?:leveloffset: .*|!leveloffset:|leveloffset!:)$/.test(line)) {
if (lines[idx - 1] === '') lines[idx - 1] = undefined
lines[idx] = undefined
continue
}
if (~line.indexOf('<<')) {

@@ -230,3 +236,3 @@ line = line.replace(/(?<![\\+])<<#?([\p{Alpha}0-9_/.:{][^>,]*?)(?:|, *([^>]+?))?>>/gu, (m, refid, text) => {

// Q: should we allow : as first character of target?
line = line.replace(/xref:([\p{Alpha}0-9_/.{#].*?)\[(|.*?[^\\])\]/gu, (m, target, text) => {
line = line.replace(/(?<![\\+])xref:([\p{Alpha}0-9_/.{#].*?)\[(|.*?[^\\])\]/gu, (m, target, text) => {
let pagePart, fragment, targetPage

@@ -313,10 +319,8 @@ const hashIdx = target.indexOf('#')

if (block.getSectionName() === 'header') {
lines.splice(idx, 1)
lines[idx] = undefined
return
}
let blockStyle = sectionMergeStrategy === 'discrete' ? 'discrete' : undefined
// FIXME: quick fix; needs more thorough review
const leveloffset = Number(doc.getAttribute('leveloffset') || 0)
lines[idx] = lines[idx].replace(/^=+( .+)/, (_, rest) => {
let targetMarkerLength = block.level + (1 - leveloffset) + level + (enclosed ? 1 : 0)
lines[idx] = lines[idx].replace(/^=+ (.+)/, (_, rest) => {
let targetMarkerLength = block.level + 1 + level + (enclosed ? 1 : 0)
if (targetMarkerLength > 6) {

@@ -326,3 +330,3 @@ targetMarkerLength = 6

}
return '='.repeat(targetMarkerLength) + rest
return '='.repeat(targetMarkerLength) + ' ' + rest
})

@@ -337,3 +341,3 @@ // NOTE: ID will be undefined if sectids are turned off

let imageMacroOffset = (
lastImageMacroAt && lastImageMacroAt[0] === idx ? line.substr(0, lastImageMacroAt[1]) : line
lastImageMacroAt?.[0] === idx ? line.substr(0, lastImageMacroAt[1]) : line
).lastIndexOf('image::')

@@ -369,3 +373,3 @@ if (imageMacroOffset > 0) {

})
buffer.push(...lines)
buffer.push(...lines.filter((it) => it !== undefined))
const attributeEntries = Object.entries(doc.attributes_defined_in_header || {})

@@ -383,3 +387,3 @@ if (attributeEntries.length) {

}
} else if (val != null && !(doc.isAttributeLocked(name) || name === 'doctype')) {
} else if (val != null && !(doc.isAttributeLocked(name) || name === 'doctype' || name === 'leveloffset')) {
accum.push(`:!${name}:`)

@@ -451,3 +455,4 @@ }

const { name, version } = componentVersion
const segments = [name]
const segments = []
if (name !== 'ROOT') segments.push(name)
if (version && version !== 'master') segments.push(version)

@@ -454,0 +459,0 @@ segments.push(

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

outline,
doctype,
contentCatalog.getPages((page) => page.out),

@@ -45,0 +46,0 @@ mergedAsciiDocConfig,

{
"name": "@antora/assembler",
"version": "1.0.0-alpha.5",
"version": "1.0.0-alpha.6",
"description": "An extension library for Antora that assembles content from multiple pages into a single AsciiDoc file to converted and publish.",

@@ -34,3 +34,2 @@ "license": "MPL-2.0",

"braces": "~3.0",
"camelcase-keys": "~7.0",
"picomatch": "~2.3",

@@ -37,0 +36,0 @@ "vinyl": "~2.2",

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc