asciidoctor-rhrev 1.2.3 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -490,6 +490,46 @@ module.exports.register = function (registry, context = {}) {
490
490
  })
491
491
  })
492
492
 
493
+ // Tag blocks carrying the current revision attribute with the rhrev-changed
494
+ // role so the site stylesheet can draw an HTML change bar (right-side border).
495
+ // Enabled by rhrev-change-bars, mirroring the PDF backend; color/width/offset
496
+ // overrides are emitted as CSS custom properties. Side is always right in HTML.
497
+ registry.treeProcessor(function () {
498
+ const self = this
499
+
500
+ self.process(function (doc) {
501
+ if (!doc.hasAttribute('rhrev-change-bars')) return doc
502
+ const revnumber = doc.getAttribute('revnumber')
503
+ if (!revnumber) return doc
504
+ const prefix = doc.getAttribute('revhistoryprefix') || 'rhrev'
505
+ const changeAttr = prefix + String(revnumber).replace(/\./g, '-')
506
+ const contexts = ['section', 'floating_title', 'example', 'listing', 'table', 'image']
507
+
508
+ let tagged = false
509
+ doc.findBy((b) => contexts.includes(b.getContext())).forEach((block) => {
510
+ const attrs = block.getAttributes()
511
+ if (!attrs || attrs[changeAttr] === undefined) return
512
+ const role = attrs.role ? attrs.role + ' rhrev-changed' : 'rhrev-changed'
513
+ block.setAttribute('role', role)
514
+ tagged = true
515
+ })
516
+ if (!tagged) return doc
517
+
518
+ const overrides = []
519
+ const color = doc.getAttribute('rhrev-change-bars-color')
520
+ if (color) overrides.push(`--rhrev-change-bar-color: #${String(color).replace(/^#/, '')};`)
521
+ const width = doc.getAttribute('rhrev-change-bars-width')
522
+ if (width) overrides.push(`--rhrev-change-bar-width: ${width}px;`)
523
+ const offset = doc.getAttribute('rhrev-change-bars-offset')
524
+ if (offset) overrides.push(`--rhrev-change-bar-offset: ${offset}px;`)
525
+ if (overrides.length) {
526
+ const style = self.createBlock(doc, 'pass', `<style>:root { ${overrides.join(' ')} }</style>`)
527
+ doc.getBlocks().unshift(style)
528
+ }
529
+ return doc
530
+ })
531
+ })
532
+
493
533
  // Register treeprocessor for auto-injection
494
534
  registry.treeProcessor(function () {
495
535
  const self = this
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asciidoctor-rhrev",
3
- "version": "1.2.3",
3
+ "version": "1.3.0",
4
4
  "description": "Revision history block macro extension for Asciidoctor.js and Antora (HTML5 backend)",
5
5
  "main": "antora-extension/antora-rhrev-asciidoc.js",
6
6
  "scripts": {