Skip to content

Commit

Permalink
fix: Update versants.com to parse figures
Browse files Browse the repository at this point in the history
- Strip image carousels of thumbnail images
  • Loading branch information
jocmp committed Jan 15, 2025
1 parent c2bc684 commit a45b329
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ Note that the URL argument is still supplied, in order to identify the web site

Mercury Parser also ships with a CLI, meaning you can use it from your command line like so:

![Mercury Parser CLI Basic Usage](./assets/parser-basic-usage.gif)

```bash
# Install Mercury Parser globally
yarn global add @jocmp/mercury-parser
Expand Down
17 changes: 15 additions & 2 deletions src/extractors/custom/www.versants.com/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,20 @@ export const WwwVersantsComExtractor = {
},

content: {
selectors: ['.entry-content'],
clean: ['.adv-link', '.versa-target'],
transforms: {
'.featured-image': $node => {
$node.addClass('mercury-parser-keep');
const figcaption = $node.find('span');
$node.find('figure').append(figcaption);
},
},
selectors: ['.article-content'],
clean: [
'.adv-link',
'.versa-target',
'header', // Clean title
'.author', // Clean author
'.thumbnail-slider', // Remove, the main images will be within the .main-slider div.
],
},
};
2 changes: 1 addition & 1 deletion src/extractors/custom/www.versants.com/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('WwwVersantsComExtractor', () => {

assert.equal(
first13,
'La 32e campagne d’Opération Nez rouge de la Vallée-du-Richelieu sera en vigueur durant'
"C'est à Sainte-Julie que les bénévoles de l'ONR VDR se retrouveront dès le"
);
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/utils/dom/clean-tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export default function cleanTags($article, $) {
if (weight < 0) {
$node.remove();
} else {
// deteremine if node seems like content
// determine if node seems like content
removeUnlessContent($node, $, weight);
}
});
Expand Down

0 comments on commit a45b329

Please sign in to comment.