Comparing version 0.2.1 to 0.2.2
@@ -21,6 +21,6 @@ "use strict"; | ||
else if (/^[(]?[ivxlcdm][).]/.exec(marker)) { | ||
return [marker.replace(/[a-z]+/, "a"), marker.replace(/[a-z]+/, "i")]; | ||
return [marker.replace(/[a-z]+/, "i"), marker.replace(/[a-z]+/, "a")]; | ||
} | ||
else if (/^[(]?[IVXLCDM][).]/.exec(marker)) { | ||
return [marker.replace(/[A-Z]+/, "A"), marker.replace(/[A-Z]+/, "I")]; | ||
return [marker.replace(/[A-Z]+/, "I"), marker.replace(/[A-Z]+/, "A")]; | ||
} | ||
@@ -563,10 +563,25 @@ else if (/^[(]?[ivxlcdm]+[).]/.exec(marker)) { | ||
return; | ||
this.addMatch(container.extra.startpos, container.extra.startpos, "+block_attributes"); | ||
if (container.attributeParser) { // should always be true | ||
const attrMatches = container.attributeParser.matches; | ||
for (const match of attrMatches) { | ||
this.matches.push(match); | ||
if (container.extra.status === "continue") { | ||
// attribute parsing failed; convert to para | ||
this.addMatch(container.extra.startpos, container.extra.startpos, "+para"); | ||
// add para container | ||
const para = this.addContainer(new Container(this.paraSpec, {}), true); | ||
if (!para || !para.inlineParser) { | ||
throw (new Error("Could not add paragraph")); | ||
} | ||
// reparse the text we couldn't parse as a block attribute: | ||
para.inlineParser.attributeSlices = container.extra.slices; | ||
para.inlineParser.reparseAttributes(); | ||
para.close(); | ||
} | ||
this.addMatch(this.pos, this.pos, "-block_attributes"); | ||
else { | ||
this.addMatch(container.extra.startpos, container.extra.startpos, "+block_attributes"); | ||
if (container.attributeParser) { // should always be true | ||
const attrMatches = container.attributeParser.matches; | ||
for (const match of attrMatches) { | ||
this.matches.push(match); | ||
} | ||
} | ||
this.addMatch(this.pos, this.pos, "-block_attributes"); | ||
} | ||
} | ||
@@ -733,4 +748,6 @@ }, | ||
} | ||
addContainer(container) { | ||
this.closeUnmatchedContainers(); | ||
addContainer(container, skipCloseUnmatched) { | ||
if (!skipCloseUnmatched) { | ||
this.closeUnmatchedContainers(); | ||
} | ||
// close containers that can't contain this one: | ||
@@ -737,0 +754,0 @@ let tip = this.tip(); |
@@ -401,2 +401,8 @@ "use strict"; | ||
}, | ||
email: (node) => { | ||
this.lit("<" + node.text + ">"); | ||
}, | ||
url: (node) => { | ||
this.lit("<" + node.text + ">"); | ||
}, | ||
link: (node) => { | ||
@@ -629,2 +635,5 @@ this.lit("["); | ||
} | ||
else { | ||
throw (new Error("No renderer defined for node type " + node.tag)); | ||
} | ||
} | ||
@@ -631,0 +640,0 @@ renderAttributes(node) { |
@@ -11,9 +11,9 @@ "use strict"; | ||
this.smartPunctuationMap = { | ||
right_single_quote: "’", | ||
left_single_quote: "‘", | ||
right_double_quote: "”", | ||
left_double_quote: "“", | ||
ellipses: "…", | ||
em_dash: "—", | ||
en_dash: "–" | ||
right_single_quote: "’", | ||
left_single_quote: "‘", | ||
right_double_quote: "”", | ||
left_double_quote: "“", | ||
ellipses: "…", | ||
em_dash: "—", | ||
en_dash: "–" | ||
}; | ||
@@ -242,3 +242,3 @@ this.warn = options.warn || (() => { }); | ||
const cellAttr = {}; | ||
if (node.align !== "default") { | ||
if (node.align && node.align !== "default") { | ||
cellAttr.style = `text-align: ${node.align};`; | ||
@@ -245,0 +245,0 @@ } |
@@ -484,3 +484,3 @@ "use strict"; | ||
.replace(/[ \r\n]+/g, " ") // collapse interior whitespace | ||
.replace(/\\(?=[.,\\/#!$%^&*;:{}=\-_`~+[\]()'"?|])/g, ""); | ||
.replace(/\\([.,\\/#!$%^&*;:{}=\-_`~+[\]()'"?|])/g, "$1"); | ||
// resolve backslash escapes | ||
@@ -685,3 +685,3 @@ if (!top.attributes) { | ||
if (node.attributes && node.attributes.id) { | ||
topContainer().attributes = { id: node.attributes.id }; | ||
topContainer().attributes = node.attributes; | ||
delete node.attributes; | ||
@@ -874,3 +874,3 @@ } | ||
tip.children[i].head = true; | ||
tip.children[i].align = node.data.aligns[i]; | ||
tip.children[i].align = node.data.aligns[i] || "default"; | ||
} | ||
@@ -877,0 +877,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.version = void 0; | ||
exports.version = "0.2.1"; | ||
exports.version = "0.2.2"; |
{ | ||
"name": "@djot/djot", | ||
"sideEffects": false, | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"engines": { | ||
@@ -6,0 +6,0 @@ "node": ">=17.0.0" |
@@ -87,3 +87,3 @@ # djot.js | ||
`new EventParser(input : string, options : Options = {})` | ||
`parseEvents(input : string, options : Options = {})` | ||
@@ -95,3 +95,3 @@ Exposes an iterator over events, each with the form | ||
```js | ||
for (let event in new djot.EventParser("Hi _there_")) { | ||
for (let event of parseEvents("Hi _there_")) { | ||
console.log(event) | ||
@@ -98,0 +98,0 @@ } |
@@ -71,3 +71,3 @@ import { Event } from "./event"; | ||
closeUnmatchedContainers(): void; | ||
addContainer(container: Container): Container; | ||
addContainer(container: Container, skipCloseUnmatched?: boolean): Container; | ||
skipSpace(): void; | ||
@@ -74,0 +74,0 @@ getEol(): void; |
@@ -1,1 +0,1 @@ | ||
export declare const version = "0.2.1"; | ||
export declare const version = "0.2.2"; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
340028
6374