Skip to content

Commit

Permalink
Merge pull request #2650 from owid/entry-emulator-edit-notice
Browse files Browse the repository at this point in the history
Entry Emulator - Edit Notice
  • Loading branch information
ikesau authored Oct 13, 2023
2 parents 3842687 + 9d26298 commit 0d4d198
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions db/model/Gdoc/htmlToEnriched.ts
Original file line number Diff line number Diff line change
Expand Up @@ -732,13 +732,13 @@ function cheerioToArchieML(
unwrapElement(element, context)

const span = cheerioToSpan(element)
if (span)
if (span) {
return {
errors: [],
// TODO: below should be a list of spans and a rich text block
content: [{ type: "text", value: [span], parseErrors: [] }],
}
else if (element.type === "tag") {
} else if (element.type === "tag") {
context.htmlTagCounts[element.tagName] =
(context.htmlTagCounts[element.tagName] ?? 0) + 1
const result: BlockParseResult<ArchieBlockOrWpComponent> = match(
Expand Down Expand Up @@ -769,7 +769,28 @@ function cheerioToArchieML(
.with({ tagName: "body" }, unwrapElementWithContext)
.with({ tagName: "center" }, unwrapElementWithContext) // might want to translate this to a block with a centered style?
.with({ tagName: "details" }, unwrapElementWithContext)
.with({ tagName: "div" }, unwrapElementWithContext)
.with({ tagName: "div" }, (div) => {
const className = div.attribs.class
// Special handling for a div that we use to mark the "First published on..." notice
if (className === "blog-info") {
const children = unwrapElementWithContext(div)
const textChildren = children.content.filter(
(c) => "type" in c && c.type === "text"
) as EnrichedBlockText[]
const callout: EnrichedBlockCallout = {
type: "callout",
title: "",
text: textChildren,
parseErrors: [],
}
return {
errors: [],
content: [callout],
}
} else {
return unwrapElementWithContext(div)
}
})
.with({ tagName: "figcaption" }, unwrapElementWithContext)
.with(
{ tagName: "figure" },
Expand Down

0 comments on commit 0d4d198

Please sign in to comment.