Skip to content

Commit

Permalink
whoops, patch
Browse files Browse the repository at this point in the history
Signed-off-by: Edaz <[email protected]>
  • Loading branch information
edazpotato committed Dec 16, 2021
1 parent dbb3cbc commit 5e0b053
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
40 changes: 21 additions & 19 deletions packages/marked-renderer-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@ const { Renderer } = require("marked");

module.exports = class RenderToText extends Renderer {
constructor(fancyMode, options) {
if (typeof fancyMode != "boolean") {
this.fancyMode = false;
} else {
this.fancyMode = fancyMode;
}
super(options);
if (fancyMode) {
if (typeof this.fancyMode != "boolean") {
this.fancyMode = false;
} else {
this.fancyMode = fancyMode;
}
}
}

code(code, infostring, escaped) {
if (!fancyMode) {
if (!this.fancyMode) {
return code;
}

Expand All @@ -35,7 +37,7 @@ module.exports = class RenderToText extends Renderer {
if (parsedQuote.endsWith("\n")) {
parsedQuote = parsedQuote.slice(0, -1);
}
if (!fancyMode) {
if (!this.fancyMode) {
return "“" + parsedQuote + "”\n";
}

Expand Down Expand Up @@ -65,7 +67,7 @@ module.exports = class RenderToText extends Renderer {
}

heading(text, level, raw, slugger) {
if (fancyMode) {
if (this.fancyMode) {
if (level == 1) {
return "\n" + text + "\n\n";
} else if (level == 2) {
Expand All @@ -76,20 +78,20 @@ module.exports = class RenderToText extends Renderer {
}

hr() {
return !fancyMode ? "\n" : "-------------------------\n"; // 25 hyphens
return !this.fancyMode ? "\n" : "-------------------------\n"; // 25 hyphens
}

list(body, ordered, start) {
return body;
}
listitem(text) {
if (!fancyMode) {
if (!this.fancyMode) {
return text + "\n";
}
return "- " + text + "\n";
}
checkbox(checked) {
if (!fancyMode) {
if (!this.fancyMode) {
return "";
}

Expand All @@ -108,38 +110,38 @@ module.exports = class RenderToText extends Renderer {
}

tablerow(content) {
if (!fancyMode) {
if (!this.fancyMode) {
return "\n" + content + "\n";
}
return content.slice(1) + " |\n";
}
tablecell(content, flags) {
if (!fancyMode) {
if (!this.fancyMode) {
return content;
}
return " | " + content;
}
// span level renderer
strong(text) {
return !fancyMode ? text : text.toUpperCase();
return !this.fancyMode ? text : text.toUpperCase();
}
em(text) {
return !fancyMode ? text : "*" + text + "*";
return !this.fancyMode ? text : "*" + text + "*";
}
codespan(text) {
return !fancyMode ? text : "`" + text + "`";
return !this.fancyMode ? text : "`" + text + "`";
}
br() {
return "\n";
}
del(text) {
if (!fancyMode) {
if (!this.fancyMode) {
return text;
}
return "~" + text + "~";
}
link(href, title, text) {
if (!fancyMode) {
if (!this.fancyMode) {
return text;
}

Expand All @@ -156,7 +158,7 @@ module.exports = class RenderToText extends Renderer {
return output;
}
image(href, title, altText) {
if (!fancyMode) {
if (!this.fancyMode) {
return altText;
}
return altText + "(" + (title ? title + " " : "") + href + ")";
Expand Down
2 changes: 1 addition & 1 deletion packages/marked-renderer-text/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "marked-renderer-text",
"description": "A custom renderer for Marked to render markdown to plain text",
"version": "2.0.0",
"version": "2.0.1",
"author": "Edazpotato <[email protected]> (https://edaz.codes/)",
"main": "index.js",
"types": "index.d.ts",
Expand Down

0 comments on commit 5e0b053

Please sign in to comment.