Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX Resolve final callout block issues #285

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/theme/assets/scss/theme/_docs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@
font-size: 1rem;
}

.content p:last-of-type {
// Don't add unnecessary space at the end of a callout block
.content > :last-child {
margin-bottom: 0;
}

Expand Down
8 changes: 6 additions & 2 deletions src/utils/parseCalloutTags.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { ReactElement, createElement } from 'react';
import { DomElement, HTMLReactParserOptions, domToReact } from "html-react-parser";
import CalloutBlock from '../components/CalloutBlock';

/**
* Turn [hint] and other callouts into a proper React component.
* @param data
*/
const parseCalloutTags = (type: string, content: any): ReactElement|false => {
return createElement(CalloutBlock, { type, content });
const parseCalloutTags = (type: string, domChildren: DomElement[], parseOptions: HTMLReactParserOptions): ReactElement|false => {
return createElement(CalloutBlock, {
type,
content: domToReact(domChildren, parseOptions),
});
};

export default parseCalloutTags;
2 changes: 1 addition & 1 deletion src/utils/parseHTML.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const parseHTML = (html: string): ReactElement | ReactElement[] | string => {
}
// Remove the type marker and render the component
firstTextNode.data = firstTextNode.data.replace(calloutTypeRegex, '');
return parseCalloutTags(matches[1], domToReact(children));
return parseCalloutTags(matches[1], children, parseOptions);
}
}
}
Expand Down