news: fix news other than google news
This commit is contained in:
parent
1cc7e12a57
commit
b26bd44735
2 changed files with 13 additions and 7 deletions
|
|
@ -851,6 +851,10 @@
|
|||
font-size: lib.s(15);
|
||||
margin-top: lib.s(10);
|
||||
color: scheme.$subtext1;
|
||||
|
||||
& > :last-child {
|
||||
margin-top: lib.s(8);
|
||||
}
|
||||
}
|
||||
|
||||
button:hover .article-body,
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@ const fixGoogleNews = (colours: IPalette, title: string, desc: string) => {
|
|||
// Add separator, bold and split at domain (domain is at the end of each headline)
|
||||
const domain = title.split(" - ").at(-1);
|
||||
if (domain) desc = desc.replaceAll(domain, `— <span foreground="${colours.subtext0}">${domain}</span>\n\n`);
|
||||
// Add spaces between sentences
|
||||
desc = desc.replace(/\.([A-Z])/g, ". $1");
|
||||
// Split headlines
|
||||
desc = desc.replace(/(( |\.)[^A-Z][a-z]+)([A-Z])/g, "$1\n\n$3");
|
||||
desc = desc.replace(/( [A-Z]+)([A-Z](?![s])[a-z])/g, "$1\n\n$2");
|
||||
|
|
@ -20,6 +18,14 @@ const fixGoogleNews = (colours: IPalette, title: string, desc: string) => {
|
|||
return desc.trim();
|
||||
};
|
||||
|
||||
const fixNews = (colours: IPalette, title: string, desc: string, source: string) => {
|
||||
// Add spaces between sentences
|
||||
desc = desc.replace(/\.([A-Z])/g, ". $1");
|
||||
// Google News needs some other fixes
|
||||
if (source === "Google News") desc = fixGoogleNews(colours, title, desc);
|
||||
return desc.replaceAll("&", "&");
|
||||
};
|
||||
|
||||
const getCategoryIcon = (category: string) => {
|
||||
if (category === "business") return "monitoring";
|
||||
if (category === "crime") return "speed_camera";
|
||||
|
|
@ -81,11 +87,7 @@ const Article = ({ title, description, creator, pubDate, source_name, link }: IA
|
|||
useMarkup
|
||||
xalign={0}
|
||||
label={bind(Palette.get_default(), "colours").as(c =>
|
||||
`\n${
|
||||
source_name === "Google News"
|
||||
? fixGoogleNews(c, title, description)
|
||||
: description
|
||||
}`.replaceAll("&", "&")
|
||||
fixNews(c, title, description, source_name)
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue