diff --git a/src/plugins/kss.ts b/src/plugins/kss.ts index aa82f7e4..6e7dedbc 100644 --- a/src/plugins/kss.ts +++ b/src/plugins/kss.ts @@ -49,7 +49,7 @@ export class KssPlugin implements IPlugin { public compile(cssFiles: IFile[], dm: ICompiler) { const styleguide = this.parseFiles(cssFiles); - const sections = styleguide.sections().map(convertSection, dm); + const sections = styleguide.sections().map((s) => convertSection(s, dm)); const css = dm.objectify(sections, (s) => s.reference); return { css }; } @@ -65,19 +65,20 @@ export class KssPlugin implements IPlugin { } } -function convertSection(this: ICompiler, section: kss.ISection): IKssExample { +// using `this` arg to pass a "context" arg to these callbacks so they have access to some helper funcs +function convertSection(section: kss.ISection, dm: ICompiler): IKssExample { return { - documentation: this.renderMarkdown(section.description()), + documentation: dm.renderMarkdown(section.description()), markup: section.markup() || "", - markupHtml: this.renderMarkdown(`\`\`\`html\n${section.markup() || ""}\n\`\`\``), - modifiers: section.modifiers().map(convertModifier, this), + markupHtml: dm.renderMarkdown(`\`\`\`html\n${section.markup() || ""}\n\`\`\``), + modifiers: section.modifiers().map((mod) => convertModifier(mod, dm)), reference: section.reference(), }; } -function convertModifier(this: ICompiler, mod: kss.IModifier): IKssModifier { +function convertModifier(mod: kss.IModifier, dm: ICompiler): IKssModifier { return { - documentation: this.renderMarkdown(mod.description()), + documentation: dm.renderMarkdown(mod.description()), name: mod.name(), }; }