Skip to content

Commit

Permalink
fix: Content element will no longer be added if no content is provided (
Browse files Browse the repository at this point in the history
close #201)
  • Loading branch information
valentine195 committed Mar 3, 2022
1 parent aa4a075 commit 94d7a4b
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ export default class ObsidianAdmonition extends Plugin {
: null),
collapse
);
const contentEl = this.renderAdmonitionContent(
this.renderAdmonitionContent(
admonitionElement,
type,
content,
Expand Down Expand Up @@ -431,7 +431,7 @@ export default class ObsidianAdmonition extends Plugin {
.join("\n")
.replace(/^(>[ ]|\t|\s{4})/gm, "");

const contentEl = this.renderAdmonitionContent(
this.renderAdmonitionContent(
admonition,
type,
content,
Expand Down Expand Up @@ -844,16 +844,15 @@ export default class ObsidianAdmonition extends Plugin {
ctx.addChild(markdownRenderChild);
}

const contentEl = this.getAdmonitionContentElement(
type,
admonitionElement,
content
);
if (content && content.length) {
if (content && content?.trim().length) {
/**
* Render the content as markdown and append it to the admonition.
*/

const contentEl = this.getAdmonitionContentElement(
type,
admonitionElement,
content
);
if (/^`{3,}mermaid/m.test(content)) {
const wasCollapsed = !admonitionElement.hasAttribute("open");
if (admonitionElement instanceof HTMLDetailsElement) {
Expand Down Expand Up @@ -912,8 +911,6 @@ export default class ObsidianAdmonition extends Plugin {

this.addLinksToCache(links, sourcePath);
}

return contentEl;
}

getAdmonitionContentElement(
Expand Down

0 comments on commit 94d7a4b

Please sign in to comment.