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

rehype-footnotes-title

Package Overview
Dependencies
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rehype-footnotes-title - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

39

dist/index.js
"use strict";
var visit = require('unist-util-visit');
function findLastTag(node) {
var tag = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'p';
const visit = require('unist-util-visit');
function findLastTag(node, tag = 'p') {
if (!node.children || !node.children.length) return;
var links = node.children.filter(function (e) {
return e.tagName === tag;
});
const links = node.children.filter(e => e.tagName === tag);
if (!links.length) return;
return links[links.length - 1];
}
function findLastLink(node, className) {
if (!node.children || !node.children.length) return;
var links = node.children.filter(function (e) {
return e.tagName === 'a';
});
const links = node.children.filter(e => e.tagName === 'a');
if (!links.length) return;
var aTag = links[links.length - 1];
const aTag = links[links.length - 1];
if (!aTag.properties || !aTag.properties.className || !aTag.properties.className.includes(className)) return;
return aTag;
}
function plugin() {
var title = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
function plugin(title = '') {
function transformer(tree) {
visit(tree, 'element', visitor);
}
function visitor(node, index, parent) {
if (node.tagName === 'li' && node.properties.id) {
if (!node.children || !node.children.length) return;
var aTag = findLastLink(node, 'footnote-backref');
let aTag = findLastLink(node, 'footnote-backref');
if (!aTag) {
var pTag = findLastTag(node, 'p');
const pTag = findLastTag(node, 'p');
aTag = findLastLink(pTag, 'footnote-backref');
}
if (!aTag) return;
var identifier = node.properties.id.slice(3);
var placeholderIndex = title.indexOf('$id');
var thisTitle;
const identifier = node.properties.id.slice(3);
const placeholderIndex = title.indexOf('$id');
let thisTitle;
if (placeholderIndex !== -1) {

@@ -53,3 +39,2 @@ thisTitle = title.split('');

}
if (!thisTitle) thisTitle = identifier;

@@ -59,6 +44,4 @@ aTag.properties.title = thisTitle;

}
return transformer;
}
module.exports = plugin;
{
"name": "rehype-footnotes-title",
"version": "2.0.0",
"version": "2.0.1",
"repository": {

@@ -16,3 +16,3 @@ "url": "https://github.com/zestedesavoir/zmarkdown/tree/master/packages/rehype-footnotes-title",

"pretest": "eslint .",
"build": "del-cli dist && cross-env BABEL_ENV=production babel src --out-dir dist",
"build": "babel --root-mode upward --delete-dir-on-start --env-name production --out-dir dist src",
"test": "jest",

@@ -35,3 +35,3 @@ "coverage": "jest --coverage"

},
"gitHead": "7dfdfdf98ac64c3867791036ab0cf1ce45918e40"
"gitHead": "b278abe5320c5ca01bdaed3c833f5f68ab389663"
}

@@ -26,3 +26,2 @@ const visit = require('unist-util-visit')

if (node.tagName === 'li' && node.properties.id) {
if (!node.children || !node.children.length) return

@@ -29,0 +28,0 @@ let aTag = findLastLink(node, 'footnote-backref')

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