FIX Resolve final callout block issues (#285)

* FIX Remove unnecessary space at the end of callout blocks

* FIX correctly parse links inside callout blocks
This commit is contained in:
Guy Sartorelli 2024-02-02 13:12:41 +13:00 committed by GitHub
parent fc34b760c0
commit 8ce02bcf8e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 4 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -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);
}
}
}