Attributes now have YAML values

This commit is contained in:
Zef Hemel
2023-07-26 17:12:56 +02:00
parent 5481e49393
commit 7b8d8af2c1
12 changed files with 139 additions and 54 deletions
+21 -3
View File
@@ -91,14 +91,32 @@ Deno.test("Test directive parser", () => {
});
const inlineAttributeSample = `
Hello there [a link](http://zef.plus) and [age:: 100]
Hello there [a link](http://zef.plus)
[age: 100]
[age:: 200]
Here's a more [ambiguous: case](http://zef.plus)
And one with nested brackets: [array: [1, 2, 3]]
`;
Deno.test("Test inline attribute syntax", () => {
const lang = buildMarkdown([]);
const tree = parse(lang, inlineAttributeSample);
const nameNode = findNodeOfType(tree, "AttributeName");
console.log("Attribute parsed", JSON.stringify(tree, null, 2));
const attributes = collectNodesOfType(tree, "Attribute");
let nameNode = findNodeOfType(attributes[0], "AttributeName");
assertEquals(nameNode?.children![0].text, "age");
const valueNode = findNodeOfType(tree, "AttributeValue");
let valueNode = findNodeOfType(attributes[0], "AttributeValue");
assertEquals(valueNode?.children![0].text, "100");
nameNode = findNodeOfType(attributes[1], "AttributeName");
assertEquals(nameNode?.children![0].text, "age");
valueNode = findNodeOfType(attributes[1], "AttributeValue");
assertEquals(valueNode?.children![0].text, "200");
nameNode = findNodeOfType(attributes[2], "AttributeName");
assertEquals(nameNode?.children![0].text, "array");
valueNode = findNodeOfType(attributes[2], "AttributeValue");
assertEquals(valueNode?.children![0].text, "[1, 2, 3]");
});