From 2e1e4d90c9de79f94d1f384b462af92584725f13 Mon Sep 17 00:00:00 2001 From: Ralph Jbeily Date: Thu, 24 Jan 2019 11:09:18 +0200 Subject: [PATCH] feat: add remarklint for md docs (#213) * feat: add remarklint for md docs * fix: remarkrc file and run linter on commit hook --- .remarkrc | 6 + package.json | 6 +- src/extractors/custom/README.md | 61 +-- yarn.lock | 648 +++++++++++++++++++++++++++++++- 4 files changed, 685 insertions(+), 36 deletions(-) create mode 100644 .remarkrc diff --git a/.remarkrc b/.remarkrc new file mode 100644 index 00000000..8ed323bc --- /dev/null +++ b/.remarkrc @@ -0,0 +1,6 @@ +{ + "plugins": [ + "remark-preset-lint-recommended", + ["remark-lint-list-item-indent", false] + ] +} diff --git a/package.json b/package.json index f29d8354..88e6f7bb 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "main": "./dist/mercury.js", "scripts": { "lint": "if test \"$CI\" != \"true\" ; then eslint . --fix; fi", - "lint:ci": "eslint .", + "lint:ci": "remark . && eslint .", "lint-fix-quiet": "eslint --fix --quiet", "build": "yarn lint && rollup -c && yarn test:build", "build:web": "yarn lint && rollup -c rollup.config.web.js && yarn test:build:web", @@ -79,6 +79,9 @@ "nock": "^10.0.6", "ora": "^3.0.0", "prettier": "^1.15.3", + "remark-cli": "^6.0.1", + "remark-lint": "^6.0.4", + "remark-preset-lint-recommended": "^3.0.2", "requirejs": "^2.3.6", "rollup": "^1.1.0", "rollup-plugin-babel": "^4.0.1", @@ -125,6 +128,7 @@ "git add" ], "*.{json,css,md}": [ + "remark .", "prettier --write", "git add" ] diff --git a/src/extractors/custom/README.md b/src/extractors/custom/README.md index 1eece61b..488a0dad 100644 --- a/src/extractors/custom/README.md +++ b/src/extractors/custom/README.md @@ -8,18 +8,19 @@ Custom parsers allow you to write CSS selectors that will find the content you'r You can query for every field returned by the Mercury Parser: - - title - - author - - content - - date_published - - lead_image_url - - dek - - next_page_url - - excerpt +- title +- author +- content +- date_published +- lead_image_url +- dek +- next_page_url +- excerpt ### Using selectors #### Basic selectors + To demonstrate, let's start with something simple: Your selector for the page's title might look something like this: ```javascript @@ -41,12 +42,13 @@ As you might guess, the selectors key provides an array of selectors that Mercur The selector you choose should return one element. If more than one element is returned by your selector, it will fail (and Mercury will fall back to its generic extractor). #### Selecting an attribute -Sometimes the information you want to return lives in an element's attribute rather than its text — e.g., sometimes a more exact ISO-formatted date/time will be stored in an attribute of an element. + +Sometimes the information you want to return lives in an element's attribute rather than its text — e.g., sometimes a more exact ISO-formatted date/time will be stored in an attribute of an element. So your element looks like this: ```html -