Skip to content

Commit

Permalink
fix(article-md): Use Element from react-native-render-html
Browse files Browse the repository at this point in the history
  • Loading branch information
WaDadidou committed Dec 28, 2024
1 parent a58719b commit a1632dd
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/utils/feed/markdown.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Element as DomHandlerElement } from "domhandler";
import markdownit from "markdown-it";
import { full as emoji } from "markdown-it-emoji/dist/index.cjs";
import footnote_plugin from "markdown-it-footnote";
import { MixedStyleRecord } from "react-native-render-html";
import { MixedStyleRecord, Element } from "react-native-render-html";

import {
neutral17,
Expand All @@ -26,15 +25,15 @@ export const articleMd = markdownit({
// DOM modifications on document, texts, or elements from react-native-render-html.
// Because react-native-render-html doesn't allow common CSS selectors, we need to style tags using domVisitors callbacks
export const renderHtmlDomVisitors = {
onElement: (element: DomHandlerElement) => {
onElement: (element: Element) => {
// Removing marginBottom from the child p of blockquote
if (
element.name === "blockquote" &&
element.children &&
element.children.length > 0
) {
const tagChild = element.children.find((child) => child.type === "tag");
// tagChild is a domhandler Node. It doesn't have attribs, but it has attribs in fact (wtf ?)
// tagChild is a react-native-render-html Node. It doesn't have attribs, but it has attribs in fact (wtf ?)
if (tagChild && "attribs" in tagChild) {
tagChild.attribs = {
style: "margin-bottom: 0",
Expand Down

0 comments on commit a1632dd

Please sign in to comment.