Skip to content

Commit

Permalink
.callout-content support (jackyzha0#1188)
Browse files Browse the repository at this point in the history
* .callout-content support

* Use BlockContent | FootnoteContent for callout body

* Update quartz/plugins/transformers/ofm.ts

Co-authored-by: Jacky Zhao <[email protected]>

* Refactor

* Combine child selectors

* Fix multiple callout members

* Empty check

* Replace splice

---------

Co-authored-by: Jacky Zhao <[email protected]>
  • Loading branch information
saberzero1 and jackyzha0 authored Jun 13, 2024
1 parent 1f21d5d commit 37e168c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
19 changes: 17 additions & 2 deletions quartz/plugins/transformers/ofm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,8 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>
return
}

// find first line
const firstChild = node.children[0]
// find first line and callout content
const [firstChild, ...calloutContent] = node.children
if (firstChild.type !== "paragraph" || firstChild.children[0]?.type !== "text") {
return
}
Expand Down Expand Up @@ -492,6 +492,21 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>
"data-callout-metadata": calloutMetaData,
},
}

// Add callout-content class to callout body if it has one.
if (calloutContent.length > 0) {
const contentData: BlockContent | DefinitionContent = {
data: {
hProperties: {
className: "callout-content",
},
hName: "div",
},
type: "blockquote",
children: [...calloutContent],
}
node.children = [node.children[0], contentData]
}
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion quartz/styles/callouts.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
transition: max-height 0.3s ease;
box-sizing: border-box;

& > *:nth-child(2) {
& > .callout-content > :first-child {
margin-top: 0;
}

Expand Down

0 comments on commit 37e168c

Please sign in to comment.