Skip to content

Commit

Permalink
Compact disable settings
Browse files Browse the repository at this point in the history
  • Loading branch information
confused-Techie committed Oct 21, 2023
1 parent d72cf65 commit 30e0793
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
6 changes: 1 addition & 5 deletions packages/settings-view/lib/rich-description.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ module.exports = {
{
html: false,
useTaskCheckbox: false,
disableInlineCode: true,
disableCodeBlocks: true,
disableHeading: true,
disableImage: true,
disableList: true
disableMode: "strict",
}
).replace(/<p>(.*)<\/p>/, "$1").trim();
}
Expand Down
32 changes: 17 additions & 15 deletions src/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@ function renderMarkdown(content, givenOpts = {}) {
transformNonFqdnLinks: true, // Attempt to resolve non-FQDN links
rootDomain: "", // The root URL that should be used for the above 'transform' options
filePath: "", // The path to the file where this markdown is generated from,
disableInlineCode: false,
disableCodeBlocks: false,
disableHeading: false,
disableImage: false,
disableList: false
disableMode: "none", // The level of disabling that should be done on the output.
// Provides helpful defaults to control how much or how little is disabled:
// - none: Nothing is disabled
// - strict: Everything possible is disabled, except what is otherwise needed
};

let opts = { ...defaultOpts, ...givenOpts };
Expand Down Expand Up @@ -184,22 +183,25 @@ function renderMarkdown(content, givenOpts = {}) {
};

// Process disables
if (opts.disableInlineCode) {
md.renderer.rules.code_inline = () => { return ""; };
}
if (opts.disableCodeBlocks) {
if (opts.disableMode === "strict") {
// Disable Code Blocks
md.disable("code");
md.disable("fence");
}
if (opts.disableHeading) {
// Disable BlockQuotes
md.disable("blockquote");
// Disable Headings
md.disable("heading");
md.disable("lheading");
}
if (opts.disableImage) {
// Disable Images
md.disable("image");
}
if (opts.disableList) {
// Disable Lists
md.disable("list");
// Disable Tables
md.disable("table");
// Only support line breaks in HTML
md.inline.ruler.before("html_inline", "only_allow_line_breaks", (state) => {
state.tokens.forEach()
});
}

let textContent;
Expand Down

0 comments on commit 30e0793

Please sign in to comment.