diff --git a/src/directives/code.ts b/src/directives/code.ts index 8195b6c..535ca4b 100644 --- a/src/directives/code.ts +++ b/src/directives/code.ts @@ -38,6 +38,18 @@ export class Code extends Directive { content: data.body, map: data.bodyMap }) + if (data.options["number-lines"]) { + token.attrSet("number-lines", data.options["number-lines"]) + } + if (data.options.force) { + token.attrSet("force", data.options.force) + } + if (data.options.name) { + token.attrSet("name", data.options.name) + } + if (data.options.class) { + token.attrJoin("class", data.options.class.join(" ")) + } return [token] } } @@ -77,6 +89,31 @@ export class CodeBlock extends Directive { content: data.body, map: data.bodyMap }) + if (data.options.linenos === null) { + token.attrSet("linenos", "true") + } + if (data.options["lineno-start"]) { + token.attrSet("lineno-start", data.options["lineno-start"]) + } + if (data.options.dedent) { + token.attrSet("dedent", data.options.dedent) + } + if (data.options["emphasize-lines"]) { + token.attrSet("emphasize-lines", data.options["emphasize-lines"]) + } + if (data.options.caption) { + token.attrSet("caption", data.options.caption) + } + if (data.options.force) { + token.attrSet("force", data.options.force) + } + if (data.options.name) { + token.attrSet("name", data.options.name) + } + if (data.options.class) { + token.attrJoin("class", data.options.class.join(" ")) + } + return [token] } } diff --git a/src/directives/plugin.ts b/src/directives/plugin.ts index fb4bd19..341de6c 100644 --- a/src/directives/plugin.ts +++ b/src/directives/plugin.ts @@ -53,7 +53,7 @@ function runDirectives(directives: { try { const directive = new directives[token.info](state) const data = directiveToData(token, directive) - const [content, opts] = parseDirectiveOptions( + const [content] = parseDirectiveOptions( token.content.trim() ? token.content.split(/\r?\n/) : [], directive ) @@ -63,19 +63,13 @@ function runDirectives(directives: { directiveOpen.content = content.join("\n").trim() directiveOpen.meta = { arg: token.meta.arg, - opts + opts: data.options } const newTokens = [directiveOpen] newTokens.push(...directive.run(data)) const directiveClose = new state.Token("parsed_directive_close", "", -1) directiveClose.hidden = true newTokens.push(directiveClose) - // Ensure `meta` exists and add the directive options to parsed child - newTokens[1].meta = { - directive: true, - ...data.options, - ...newTokens[1].meta - } finalTokens.push(...newTokens) } catch (err) { const errorToken = new state.Token("directive_error", "", 0) diff --git a/src/directives/tables.ts b/src/directives/tables.ts index b3850e1..56c400f 100644 --- a/src/directives/tables.ts +++ b/src/directives/tables.ts @@ -44,6 +44,9 @@ export class ListTable extends Directive { // table opening const tableOpen = this.createToken("table_open", "table", 1, { map: data.bodyMap }) + if (data.options.name) { + tableOpen.attrSet("name", data.options.name) + } if (data.options.align) { tableOpen.attrJoin("class", `align-${data.options.align}`) }