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

rebber

Package Overview
Dependencies
Maintainers
2
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rebber - npm Package Compare versions

Comparing version 4.0.2 to 5.0.0

54

dist/types/code.js
"use strict";
var detab = require('detab');
/* Expose. */
module.exports = code;
var codeBlockParamsMapping = [null, 'hl_lines=', 'linenostart='];
var defaultMacro = function defaultMacro(content, lang) {
if (!lang) lang = 'text';
var param = '';
var defaultMacro = function defaultMacro(content, lang, attrs) {
// Default language is "text"
if (!lang) lang = 'text'; // Create a list of attributes to be serialized
if (lang.indexOf('hl_lines=') > -1) {
var lines = lang.split('hl_lines=')[1].trim();
var localCodeBlockParams = Array(codeBlockParamsMapping.length).fill(''); // Check for attributes and enumerate them
if (lines.startsWith('"') && lines.endsWith('"') || lines.startsWith("'") && lines.endsWith("'")) {
lines = lines.slice(1, -1).trim();
if (attrs !== null) {
for (var i = 0; i < codeBlockParamsMapping.length; i++) {
var _param = codeBlockParamsMapping[i]; // Skip unwanted parameters
if (_param === null) continue;
var location = attrs.indexOf(_param); // Parse the attributes we know
if (location > -1) {
var begin = location + _param.length;
var remaining = attrs.slice(begin);
var length = remaining.indexOf(' ');
var value = length > -1 ? attrs.slice(begin, begin + length) : remaining; // Remove string-delimiters
if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
value = value.slice(1, -1).trim();
}
localCodeBlockParams[i] = value;
}
}
} // If we matched something, return optional arguments
// Note that we do stop serialization on a chain of empty arguments
param += "[][".concat(lines, "]");
}
lang = lang.split(' ')[0];
var matched = localCodeBlockParams.reduce(function (a, v, i) {
return v !== '' ? i : a;
}, -1) + 1;
var param = matched > 0 ? "[".concat(localCodeBlockParams.slice(0, matched).join(']['), "]") : '';
return "\\begin{CodeBlock}".concat(param, "{").concat(lang, "}\n").concat(content, "\n\\end{CodeBlock}\n\n");
};
/* Stringify a Blockquote `node`. */
/* Stringify a code `node`. */
module.exports = function code(ctx, node) {
var value = node.value ? detab("".concat(node.value, "\n")) : '';
function code(ctx, node) {
var macro = ctx.code || defaultMacro;
return macro(value, node.lang);
};
return "".concat(macro(node.value, node.lang, node.meta, node));
}
code.macro = defaultMacro;
{
"name": "rebber",
"version": "4.0.2",
"version": "5.0.0",
"description": "Stringifies MDAST to LaTeX",

@@ -34,10 +34,7 @@ "repository": "https://github.com/zestedesavoir/zmarkdown/tree/master/packages/rebber",

"dependencies": {
"collapse-white-space": "^1.0.5",
"detab": "^2.0.2",
"has": "^1.0.1",
"mdast-util-definitions": "^1.2.3",
"trim-lines": "^1.1.2",
"xtend": "^4.0.1"
"has": "^1.0.3",
"mdast-util-definitions": "^2.0.0",
"xtend": "^4.0.2"
},
"gitHead": "86ca62fff4fbc11a45ce795ca8863f8e847eea08"
"gitHead": "c2bf169996c4adfdf75a55290080947a2384c09f"
}

@@ -1,25 +0,59 @@

const detab = require('detab')
/* Expose. */
module.exports = code
const defaultMacro = (content, lang) => {
const codeBlockParamsMapping = [
null,
'hl_lines=',
'linenostart=',
]
const defaultMacro = (content, lang, attrs) => {
// Default language is "text"
if (!lang) lang = 'text'
let param = ''
if (lang.indexOf('hl_lines=') > -1) {
let lines = lang.split('hl_lines=')[1].trim()
if (
(lines.startsWith('"') && lines.endsWith('"')) ||
(lines.startsWith("'") && lines.endsWith("'"))
) {
lines = lines.slice(1, -1).trim()
// Create a list of attributes to be serialized
const localCodeBlockParams = Array(codeBlockParamsMapping.length).fill('')
// Check for attributes and enumerate them
if (attrs !== null) {
for (let i = 0; i < codeBlockParamsMapping.length; i++) {
const param = codeBlockParamsMapping[i]
// Skip unwanted parameters
if (param === null) continue
const location = attrs.indexOf(param)
// Parse the attributes we know
if (location > -1) {
const begin = location + param.length
const remaining = attrs.slice(begin)
const length = remaining.indexOf(' ')
let value = length > -1 ? attrs.slice(begin, begin + length) : remaining
// Remove string-delimiters
if (
(value.startsWith('"') && value.endsWith('"')) ||
(value.startsWith("'") && value.endsWith("'"))
) {
value = value.slice(1, -1).trim()
}
localCodeBlockParams[i] = value
}
}
param += `[][${lines}]`
}
lang = lang.split(' ')[0]
// If we matched something, return optional arguments
// Note that we do stop serialization on a chain of empty arguments
const matched = localCodeBlockParams.reduce((a, v, i) => v !== '' ? i : a, -1) + 1
const param = matched > 0 ? `[${localCodeBlockParams.slice(0, matched).join('][')}]` : ''
return `\\begin{CodeBlock}${param}{${lang}}\n${content}\n\\end{CodeBlock}\n\n`
}
/* Stringify a Blockquote `node`. */
module.exports = function code (ctx, node) {
const value = node.value ? detab(`${node.value}\n`) : ''
/* Stringify a code `node`. */
function code (ctx, node) {
const macro = ctx.code || defaultMacro
return macro(value, node.lang)
return `${macro(node.value, node.lang, node.meta, node)}`
}
code.macro = defaultMacro
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