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

remark-wiki-link

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-wiki-link - npm Package Compare versions

Comparing version 0.0.4 to 1.0.0

.eslintrc.js

134

lib/index.js

@@ -1,132 +0,28 @@

"use strict";
'use strict';
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, '__esModule', { value: true });
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var micromarkExtensionWikiLink = require('micromark-extension-wiki-link');
var mdastUtilWikiLink = require('mdast-util-wiki-link');
var _unistUtilMap = _interopRequireDefault(require("unist-util-map"));
var warningIssued;
var LINK_REGEX = /^\[\[(.+?)\]\]/;
function locator(value, fromIndex) {
return value.indexOf('[', fromIndex);
}
function wikiLinkPlugin() {
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var permalinks = opts.permalinks || [];
var data = this.data();
var defaultPageResolver = function defaultPageResolver(name) {
return [name.replace(/ /g, '_').toLowerCase()];
};
var pageResolver = opts.pageResolver || defaultPageResolver;
var newClassName = opts.newClassName || 'new';
var wikiLinkClassName = opts.wikiLinkClassName || 'internal';
var defaultHrefTemplate = function defaultHrefTemplate(permalink) {
return "#/page/".concat(permalink);
};
var hrefTemplate = opts.hrefTemplate || defaultHrefTemplate;
var aliasDivider = opts.aliasDivider || ":";
function isAlias(pageTitle) {
return pageTitle.indexOf(aliasDivider) !== -1;
function add(field, value) {
if (data[field]) data[field].push(value);else data[field] = [value];
}
function parseAliasLink(pageTitle) {
var _pageTitle$split = pageTitle.split(aliasDivider),
_pageTitle$split2 = (0, _slicedToArray2["default"])(_pageTitle$split, 2),
name = _pageTitle$split2[0],
displayName = _pageTitle$split2[1];
return {
name: name,
displayName: displayName
};
if (!warningIssued && (this.Parser && this.Parser.prototype && this.Parser.prototype.blockTokenizers || this.Compiler && this.Compiler.prototype && this.Compiler.prototype.visitors)) {
warningIssued = true;
console.warn('[remark-wiki-link] Warning: please upgrade to remark 13 to use this plugin');
}
function parsePageTitle(pageTitle) {
if (isAlias(pageTitle)) {
return parseAliasLink(pageTitle);
}
return {
name: pageTitle,
displayName: pageTitle
};
}
function inlineTokenizer(eat, value) {
var match = LINK_REGEX.exec(value);
if (match) {
var pageName = match[1].trim();
var _parsePageTitle = parsePageTitle(pageName),
name = _parsePageTitle.name,
displayName = _parsePageTitle.displayName;
var pagePermalinks = pageResolver(name);
var permalink = pagePermalinks.find(function (p) {
return permalinks.indexOf(p) != -1;
});
var exists = permalink != undefined;
if (!exists) {
permalink = pagePermalinks[0];
}
var classNames = wikiLinkClassName;
if (!exists) {
classNames += ' ' + newClassName;
}
return eat(match[0])({
type: 'wikiLink',
value: name,
data: {
alias: displayName,
permalink: permalink,
exists: exists,
hName: 'a',
hProperties: {
className: classNames,
href: hrefTemplate(permalink)
},
hChildren: [{
type: 'text',
value: displayName
}]
}
});
}
}
inlineTokenizer.locator = locator;
var Parser = this.Parser;
var inlineTokenizers = Parser.prototype.inlineTokenizers;
var inlineMethods = Parser.prototype.inlineMethods;
inlineTokenizers.wikiLink = inlineTokenizer;
inlineMethods.splice(inlineMethods.indexOf('link'), 0, 'wikiLink'); // Stringify for wiki link
var Compiler = this.Compiler;
if (Compiler != null) {
var visitors = Compiler.prototype.visitors;
if (visitors) {
visitors.wikiLink = function (node) {
if (node.data.alias != node.value) {
return "[[".concat(node.value).concat(aliasDivider).concat(node.data.alias, "]]");
}
return "[[".concat(node.value, "]]");
};
}
}
add('micromarkExtensions', micromarkExtensionWikiLink.syntax(opts));
add('fromMarkdownExtensions', mdastUtilWikiLink.fromMarkdown(opts));
add('toMarkdownExtensions', mdastUtilWikiLink.toMarkdown(opts));
}
module.exports = wikiLinkPlugin;
exports.wikiLinkPlugin = wikiLinkPlugin;
{
"name": "remark-wiki-link",
"description": "Parse and render wiki-style links",
"version": "0.0.4",
"version": "1.0.0",
"keywords": [

@@ -18,11 +18,16 @@ "remark",

},
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
"browser": "dist/index.umd.js",
"scripts": {
"test": "npm run babel && mocha --require @babel/register test/index_test.js",
"babel": "babel src --out-dir lib",
"prepublish": "npm run babel"
"build": "rollup -c",
"lint": "eslint src/ test/",
"prepare": "npm run build",
"pretest": "npm run build",
"test": "npm run lint && mocha --require @babel/register test/index_test.js"
},
"main": "lib/index.js",
"dependencies": {
"@babel/runtime": "^7.4.4",
"unist-util-map": "^1.0.3"
"mdast-util-wiki-link": "0.0.1",
"micromark-extension-wiki-link": "^0.0.2"
},

@@ -36,9 +41,18 @@ "devDependencies": {

"mocha": "^6.1.4",
"rehype-stringify": "^3.0.0",
"remark-parse": "^3.0.1",
"remark-rehype": "^2.0.1",
"remark-stringify": "^3.0.1",
"unified": "^6.1.5",
"unist-util-visit": "^1.1.3"
"rollup": "^2.32.0",
"@rollup/plugin-babel": "^5.2.1",
"@rollup/plugin-commonjs": "^15.1.0",
"eslint": "^7.11.0",
"eslint-config-standard": "^14.1.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"rehype-stringify": "^8.0.0",
"remark-parse": "^9.0.0",
"remark-rehype": "^8.0.0",
"remark-stringify": "^9.0.0",
"unified": "^9.2.0",
"unist-util-visit": "^2.0.3"
}
}
# remark-wiki-link
[![npm version](https://badge.fury.io/js/remark-wiki-link.svg)](https://badge.fury.io/js/remark-wiki-link) [![Build Status](https://travis-ci.org/landakram/remark-wiki-link.svg?branch=master)](https://travis-ci.org/landakram/remark-wiki-link)
⚠️ This plugin is affected by the new parser in remark ([`micromark`](https://github.com/micromark/micromark), see [`remarkjs/remark#536`](https://github.com/remarkjs/remark/pull/536)). **For remark 12, use v0.0.x of this package**. **For remark 13+, use v1.0.0 or above.**
This [remark](https://github.com/wooorm/remark) plugin parses and renders `[[Wiki Links]]`.

@@ -10,2 +12,4 @@

Looking for lower level packages? Check out [mdast-util-wiki-link](https://github.com/landakram/mdast-util-wiki-link/) for working with ASTs and [micromark-extension-wiki-link](https://github.com/landakram/micromark-extension-wiki-link) for working with tokens.
## Usage

@@ -12,0 +16,0 @@

Sorry, the diff of this file is not supported yet

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