New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@djot/djot

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@djot/djot - npm Package Compare versions

Comparing version 0.2.5 to 0.3.0

2

lib/attributes.js

@@ -109,3 +109,3 @@ "use strict";

const c = parser.subject.charAt(pos);
if ((/^\w/.exec(c) !== null) || c === '_' || c === '-' || c === ':') {
if ((/^[^\]\[~!@#$%^&*(){}`,.<>\\|=+/?\s]/.exec(c) !== null)) {
return State.SCANNING_ID;

@@ -112,0 +112,0 @@ }

@@ -301,3 +301,3 @@ "use strict";

this.space();
this.prefixes.push(" ".repeat(2));
this.prefixes.push(" ".repeat(6));
this.renderChildren(item.children);

@@ -408,2 +408,7 @@ this.prefixes.pop();

},
span: (node) => {
this.lit("[");
this.renderChildren(node.children);
this.lit("]");
},
link: (node) => {

@@ -627,3 +632,3 @@ this.lit("[");

if (handler) {
if ("attributes" in node && (0, ast_1.isBlock)(node)) {
if (node.attributes && (0, ast_1.isBlock)(node)) {
this.renderAttributes(node);

@@ -633,3 +638,3 @@ this.cr();

handler(node);
if ("attributes" in node && (0, ast_1.isInline)(node)) {
if (node.attributes && (0, ast_1.isInline)(node)) {
this.renderAttributes(node);

@@ -636,0 +641,0 @@ }

@@ -25,2 +25,3 @@ "use strict";

this.references = {};
this.autoReferences = {};
}

@@ -66,5 +67,6 @@ escape(s) {

}
if (node.attributes) {
for (const k in node.attributes) {
const v = node.attributes[k];
const attributes = Object.assign(Object.assign({}, node.autoAttributes), node.attributes);
if (attributes) {
for (const k in attributes) {
const v = attributes[k];
if (!(k === "class" && extraAttrs && extraAttrs.class)) {

@@ -84,3 +86,3 @@ result += ` ${k}="${this.escapeAttribute(v)}"`;

let attributes = "";
if ("attributes" in node || extraAttrs || node.pos) {
if (node.attributes || node.autoAttributes || extraAttrs || node.pos) {
attributes = this.renderAttributes(node, extraAttrs);

@@ -277,3 +279,3 @@ }

case "str": {
if (node.attributes) {
if (node.attributes || node.autoAttributes) {
return `${this.renderTag("span", node)}${this.escape(node.text)}</span>`;

@@ -342,3 +344,3 @@ }

if (node.reference) {
const ref = this.references[node.reference];
const ref = this.references[node.reference] || this.autoReferences[node.reference];
if (ref) {

@@ -361,2 +363,10 @@ dest = ref.destination;

}
if (ref.autoAttributes) {
for (const k in ref.autoAttributes) {
if (!node.autoAttributes || !node.autoAttributes[k]) {
// attribs on link take priority over attribs on reference
extraAttr[k] = ref.autoAttributes[k];
}
}
}
}

@@ -424,2 +434,3 @@ else {

this.references = doc.references;
this.autoReferences = doc.autoReferences;
return this.renderAstNode(doc);

@@ -426,0 +437,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = exports.renderDjot = exports.toPandoc = exports.fromPandoc = exports.applyFilter = exports.HTMLRenderer = exports.renderHTML = exports.parseEvents = exports.renderAST = exports.parse = void 0;
exports.isInline = exports.isBlock = exports.version = exports.renderDjot = exports.toPandoc = exports.fromPandoc = exports.applyFilter = exports.HTMLRenderer = exports.renderHTML = exports.parseEvents = exports.renderAST = exports.parse = void 0;
var parse_1 = require("./parse");

@@ -21,1 +21,4 @@ Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return parse_1.parse; } });

Object.defineProperty(exports, "version", { enumerable: true, get: function () { return version_1.version; } });
var ast_1 = require("./ast");
Object.defineProperty(exports, "isBlock", { enumerable: true, get: function () { return ast_1.isBlock; } });
Object.defineProperty(exports, "isInline", { enumerable: true, get: function () { return ast_1.isInline; } });

@@ -33,9 +33,10 @@ "use strict";

const toPandocAttr = function (node) {
if ("attributes" in node && node.attributes) {
const id = node.attributes.id || "";
const classes = (node.attributes.class && node.attributes.class.split(" ")) || [];
const attributes = Object.assign(Object.assign({}, node.autoAttributes), node.attributes);
if (attributes) {
const id = attributes.id || "";
const classes = (attributes.class && attributes.class.split(" ")) || [];
const kvs = [];
for (const k in node.attributes) {
for (const k in attributes) {
if (k !== id && k !== "class") {
kvs.push([k, node.attributes[k]]);
kvs.push([k, attributes[k]]);
}

@@ -128,20 +129,16 @@ }

case "task_list":
case "ordered_list":
case "bullet_list": {
let items;
if (node.style &&
node.style === "-" || node.style === "+" || node.style === "*" ||
node.style === "X") {
items = node.children.map(this.toPandocListItem(node));
elts.push({ t: "BulletList", c: items });
}
else {
items = node.children.map(this.toPandocListItem(node));
const [style, delim] = reverseStyleMap[node.style];
const start = node.start || 1;
elts.push({ t: "OrderedList", c: [[start, { t: style }, { t: delim }],
items] });
}
items = node.children.map(this.toPandocListItem(node));
elts.push({ t: "BulletList", c: items });
break;
}
case "ordered_list": {
const items = node.children.map(this.toPandocListItem(node));
const [style, delim] = reverseStyleMap[node.style];
const start = node.start || 1;
elts.push({ t: "OrderedList", c: [[start, { t: style }, { t: delim }],
items] });
break;
}
case "task_list_item": // should be handled at "list" above

@@ -318,5 +315,6 @@ case "list_item": // should be handled at "list" above

destination = ref.destination || "";
if (ref.attributes) {
for (const k in ref.attributes) {
linkAttrs[k] = ref.attributes[k];
const attributes = Object.assign(Object.assign({}, ref.autoAttributes), ref.attributes);
if (attributes) {
for (const k in attributes) {
linkAttrs[k] = attributes[k];
}

@@ -329,9 +327,10 @@ }

}
if (node.attributes) {
for (const k in node.attributes) {
const attributes = Object.assign(Object.assign({}, node.autoAttributes), node.attributes);
if (attributes) {
for (const k in attributes) {
if (linkAttrs[k] && k === "class") {
linkAttrs[k] += " " + node.attributes[k];
linkAttrs[k] += " " + attributes[k];
}
else if (!linkAttrs[k]) {
linkAttrs[k] = node.attributes[k];
linkAttrs[k] = attributes[k];
}

@@ -343,3 +342,3 @@ }

const url = destination || "";
const title = (node.attributes && node.attributes.title) || "";
const title = (node.attributes && node.attributes.title) || (node.autoAttributes && node.autoAttributes.title) || "";
if (title) {

@@ -794,6 +793,6 @@ attrs[2] = attrs[2].filter(([k, v]) => k !== "title");

case "Figure": {
let attr = fromPandocAttr(block.c[0]);
const attr = fromPandocAttr(block.c[0]);
const tag = /\bsection\b/.test((attr && attr.class) || "")
? "section" : "div";
let blocks = block.c[2].map((b) => {
const blocks = block.c[2].map((b) => {
return this.fromPandocBlock(b);

@@ -886,3 +885,4 @@ });

footnotes: this.footnotes,
references: {} };
references: {},
autoReferences: {} };
}

@@ -889,0 +889,0 @@ }

@@ -138,2 +138,3 @@ "use strict";

const references = {};
const autoReferences = {};
const footnotes = {};

@@ -275,3 +276,4 @@ const identifiers = {}; // identifiers used

destination: node.data.value || "",
attributes: node.attributes
attributes: node.attributes,
pos: node.pos,
};

@@ -655,15 +657,17 @@ if (node.data.key) {

}
if (!node.autoAttributes) {
node.autoAttributes = {};
}
const headingStr = getStringContent(node).trim();
if (!node.attributes.id) {
// generate auto identifier
node.attributes.id = getUniqueIdentifier(headingStr);
identifiers[node.attributes.id] = true;
node.autoAttributes.id = getUniqueIdentifier(headingStr);
identifiers[node.autoAttributes.id] = true;
}
// add implicit heading reference
const lab = normalizeLabel(headingStr);
if (!references[lab]) {
references[lab] = {
if (!references[lab] && !autoReferences[lab]) {
autoReferences[lab] = {
tag: "reference",
label: lab,
destination: "#" + node.attributes.id
destination: "#" + (node.attributes.id || node.autoAttributes.id)
};

@@ -682,2 +686,3 @@ }

attributes: pnode.attributes,
autoAttributes: pnode.autoAttributes,
pos: pnode.pos

@@ -692,2 +697,6 @@ });

// move id attribute from heading to section
if (node.autoAttributes && node.autoAttributes.id) {
topContainer().autoAttributes = node.autoAttributes;
delete node.autoAttributes;
}
if (node.attributes && node.attributes.id) {

@@ -703,2 +712,3 @@ topContainer().attributes = node.attributes;

attributes: node.attributes,
autoAttributes: node.autoAttributes,
pos: node.pos

@@ -727,2 +737,3 @@ });

attributes: node.attributes,
autoAttributes: node.autoAttributes,
pos: node.pos

@@ -737,2 +748,3 @@ });

attributes: node.attributes,
autoAttributes: node.autoAttributes,
pos: node.pos

@@ -749,2 +761,3 @@ });

attributes: node.attributes,
autoAttributes: node.autoAttributes,
pos: node.pos

@@ -761,2 +774,3 @@ });

attributes: node.attributes,
autoAttributes: node.autoAttributes,
pos: node.pos

@@ -798,2 +812,3 @@ });

attributes: node.attributes,
autoAttributes: node.autoAttributes,
pos: node.pos

@@ -812,2 +827,3 @@ });

attributes: node.attributes,
autoAttributes: node.autoAttributes,
pos: node.pos

@@ -822,2 +838,3 @@ });

attributes: node.attributes,
autoAttributes: node.autoAttributes,
checkbox: node.data.checkbox,

@@ -832,2 +849,3 @@ pos: node.pos

attributes: node.attributes,
autoAttributes: node.autoAttributes,
pos: node.pos

@@ -852,2 +870,3 @@ });

attributes: node.attributes,
autoAttributes: node.autoAttributes,
pos: node.pos

@@ -875,2 +894,3 @@ });

attributes: node.attributes,
autoAttributes: node.autoAttributes,
pos: node.pos

@@ -908,2 +928,3 @@ });

attributes: node.attributes,
autoAttributes: node.autoAttributes,
pos: node.pos

@@ -936,2 +957,3 @@ });

attributes: node.attributes,
autoAttributes: node.autoAttributes,
pos: node.pos

@@ -954,2 +976,3 @@ });

attributes: node.attributes,
autoAttributes: node.autoAttributes,
pos: node.pos

@@ -974,2 +997,3 @@ };

attributes: node.attributes,
autoAttributes: node.autoAttributes,
pos: node.pos

@@ -999,2 +1023,3 @@ };

attributes: node.attributes,
autoAttributes: node.autoAttributes,
pos: node.pos

@@ -1009,2 +1034,3 @@ });

attributes: node.attributes,
autoAttributes: node.autoAttributes,
pos: node.pos

@@ -1029,2 +1055,3 @@ });

attributes: node.attributes,
autoAttributes: node.autoAttributes,
pos: node.pos

@@ -1161,2 +1188,3 @@ });

attributes: pnode.attributes,
autoAttributes: pnode.autoAttributes,
pos: pnode.pos

@@ -1169,5 +1197,9 @@ });

references: references,
autoReferences: autoReferences,
footnotes: footnotes,
children: containers[0].children,
};
if (containers[0].autoAttributes) {
doc.autoAttributes = containers[0].autoAttributes;
}
if (containers[0].attributes) {

@@ -1184,3 +1216,5 @@ doc.attributes = containers[0].attributes;

attributes: true,
autoAttributes: true,
references: true,
autoReferences: true,
footnotes: true

@@ -1187,0 +1221,0 @@ };

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = void 0;
exports.version = "0.2.5";
exports.version = "0.3.0";
{
"name": "@djot/djot",
"sideEffects": false,
"version": "0.2.5",
"version": "0.3.0",
"engines": {

@@ -20,3 +20,4 @@ "node": ">=17.0.0"

"require": "./dist/djot.js",
"default": "./lib/index.js"
"default": "./lib/index.js",
"types": "./types/index.d.ts"
}

@@ -42,4 +43,3 @@ },

],
"dependencies": {
},
"dependencies": {},
"devDependencies": {

@@ -46,0 +46,0 @@ "@types/jest": "^29.2.4",

@@ -56,2 +56,12 @@ # djot.js

## CDN
The library is available via the `unpkg` CDN:
``` html
<script src="https://unpkg.com/@djot/djot@0.2.5/dist/djot.js"></script>
```
(Replace `0.2.5` with the version you want to use.)
## Library API

@@ -58,0 +68,0 @@

@@ -13,2 +13,3 @@ type Attributes = Record<string, string>;

attributes?: Attributes;
autoAttributes?: Attributes;
pos?: Pos;

@@ -241,2 +242,3 @@ }

references: Record<string, Reference>;
autoReferences: Record<string, Reference>;
footnotes: Record<string, Footnote>;

@@ -243,0 +245,0 @@ children: Block[];

@@ -13,2 +13,3 @@ import { Doc, Reference, Footnote, HasChildren, HasAttributes, AstNode, Visitor } from "./ast";

references: Record<string, Reference>;
autoReferences: Record<string, Reference>;
constructor(options: HTMLRenderOptions);

@@ -15,0 +16,0 @@ escape(s: string): string;

@@ -8,1 +8,3 @@ export { parse, renderAST } from "./parse";

export { version } from "./version";
export { isBlock, isInline } from "./ast";
export type { Alignment, AstNode, Attributes, Block, BlockQuote, BulletList, BulletListStyle, Caption, Cell, CheckboxStatus, CodeBlock, Definition, DefinitionList, DefinitionListItem, Delete, DisplayMath, Div, Doc, DoubleQuoted, Email, Emph, Footnote, FootnoteReference, HardBreak, HasAttributes, HasChildren, HasText, Heading, Image, Inline, InlineMath, Insert, Link, ListItem, Mark, NonBreakingSpace, OrderedList, OrderedListStyle, Para, Pos, RawBlock, RawInline, Reference, Row, Section, SingleQuoted, SmartPunctuation, SmartPunctuationType, SoftBreak, SourceLoc, Span, Str, Strong, Subscript, Superscript, Symb, Table, TaskList, TaskListItem, Term, ThematicBreak, Url, Verbatim, Visitor, } from "./ast";

@@ -6,2 +6,3 @@ import { Options } from "./options";

attributes?: Attributes;
autoAttributes?: Attributes;
data: Record<string, any>;

@@ -8,0 +9,0 @@ pos?: Pos;

@@ -1,1 +0,1 @@

export declare const version = "0.2.5";
export declare const version = "0.3.0";

Sorry, the diff of this file is too big to display

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