diff --git a/packages/api/src/utils/newsletter.ts b/packages/api/src/utils/newsletter.ts new file mode 100644 index 000000000..5c3d81e14 --- /dev/null +++ b/packages/api/src/utils/newsletter.ts @@ -0,0 +1,25 @@ +import { Readability } from '@omnivore/readability'; +import { DOMWindow } from 'jsdom' + + +// Attempt to determine if an HTML blob is a newsletter +// based on it's contents. +export const isProbablyNewsletter = (dom: DOMWindow): boolean => { + const article = new Readability(document, { + debug: false, + keepTables: true, + }).parse() + + if (!article || !article.content) { + return false + } + + // Maybe it is a substack newsletter + const body = dom.document.querySelector('.email-body-container') + if (body?.querySelector('.post-meta') || body?.querySelector('.post-cta')) { + return true + } + + return false +}; + diff --git a/packages/api/test/utils/data/substack-forwarded-newsletter.html b/packages/api/test/utils/data/substack-forwarded-newsletter.html new file mode 100644 index 000000000..ebfa93cee --- /dev/null +++ b/packages/api/test/utils/data/substack-forwarded-newsletter.html @@ -0,0 +1 @@ +
The phrase, ‘eating people’ (吃人 chī rén), is used to criticise companies in China that exploit their employees. It’s originally from Lǔ Xùn’s (鲁迅), A Madman's Diary (狂人日记 kuángrén rìjì), published in 1918:
The times have changed since Lu Xun made that observation more than 100 years ago, but the culture of ‘eating people’ has not, according to social media comments this week, such as this one:
Two of China’s biggest tech companies, Tencent and Bilibili, have recently been accused of ‘eating people’, abusing and exploiting their staff. So that’s what we discuss this week.
Use this link to claim a one-month free trial of the membership to give the full experience a go: 1. CONVERSATIONS WITH CONSUMINGInterview with Zhang YifeiTwo weeks ago a 25-year-old programmer at Tencent, Zhāng Yìfēi 张义飞, became an Internet sensation after standing up to his bosses at the company. He announced in an internal group chat that he was quitting his job, which then went viral on social media. If 20-hour days is what the company wants, he wrote, ‘I’ll resign tomorrow’ 36Kr interviewed Zhang this week (in Chinese). He talks more about the overtime culture at Tencent, and why he dared to take on his company in such a public way - he already had another job lined up. There are some excellent words in his description of life as a working person at Tencent. Useful words
Idioms
2. WORDS OF THE WEEKBilibili eats peopleA man who headed a content moderation department at Chinese video-streaming site Bilibili died last week after suffering a cerebral hemorrhage while working a Chinese New Year holiday shift. The company was heavily criticised (Sohu - in Chinese) of having a toxic work culture. One of the top comments on social media adapted the line from Lu Xun’s A Madman’s Diary. But instead of looking through the pages of history, overworked netizens find the same message hidden in their payslips:
The words shared below are from the Sohu article and also from social media comments. Useful words
Idioms
Colloquial phrases
3. RECOMMENDATIONSBecome a member of the communityAs a member of the community you get access to unique resources to help you master modern Mandarin, learn, use, and understand Chinese language the way people speak it today.
Use this link to claim a one-month free trial of the membership to give the full experience a go. That’s it for this week. I look forward to seeing you in your inbox same time next weekend. Andrew +++ ps - please do share this newsletter on your social channels and with your networks |
Thanks so much for subscribing to Slow Chinese 每周漫闻 and welcome aboard! I’m excited to help you improve and practice your Chinese language skills. Here’s a quick way I can help:
I’ll reply with a specific suggestion to help you. Also, to make sure the next issue of the newsletter doesn’t land in your spam folder, add my email address to your contacts. Thanks! Andrew |