From f159394e7d22bf068177251677dcd2bb867f2e36 Mon Sep 17 00:00:00 2001 From: Adam Pritchard Date: Mon, 13 Apr 2015 21:05:54 -0400 Subject: [PATCH] Fixed example for adding target to links --- docs/architecture.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/architecture.md b/docs/architecture.md index 37687ad..86b69e4 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -137,21 +137,21 @@ Here is another example, how to add `target="_blank"` to all links: ```js // Remember old renderer, if overriden, or proxy to default renderer val old_render = md.renderer.rules.link_open || function(tokens, idx, options, env, self) { - self.renderToken(tokens, idx, options); + return self.renderToken(tokens, idx, options); }; md.renderer.rules.link_open = function (tokens, idx, options, env, self) { // If you are sure other plugins can't add `target` - drop check below - var aIndex = token[idx].attrIndex('target'); + var aIndex = tokens[idx].attrIndex('target'); if (aIndex < 0) { - token[idx].attrPush(['target', '_blank']); // add new attribute + tokens[idx].attrPush(['target', '_blank']); // add new attribute } else { - token[idx].attrs[aIndex][1] = '_blank'; // replace value of existing attr + tokens[idx].attrs[aIndex][1] = '_blank'; // replace value of existing attr } // pass token to default renderer. - old_render(tokens, idx, options, env, self); + return old_render(tokens, idx, options, env, self); }; ```