@financial-times/o-syntax-highlight
Advanced tools
Comparing version 2.1.0 to 3.0.0
@@ -12,2 +12,4 @@ { | ||
"*.json", | ||
"*.js", | ||
"!main.js", | ||
"scss", | ||
@@ -27,7 +29,7 @@ "!bower.json", | ||
"name": "@financial-times/o-syntax-highlight", | ||
"version": "2.1.0", | ||
"version": "3.0.0", | ||
"description": "syntax highlighter for FT products", | ||
"homepage": "https://github.com/Financial-Times/o-syntax-highlight", | ||
"dependencies": { | ||
"@financial-times/o-colors": "^4.2.4", | ||
"@financial-times/o-colors": "^5.0.0", | ||
"prismjs": "^1.14.0" | ||
@@ -37,3 +39,5 @@ }, | ||
"scripts": {}, | ||
"devDependencies": {} | ||
"devDependencies": { | ||
"origami-ci-tools": "^1.0.0" | ||
} | ||
} |
@@ -6,7 +6,6 @@ | ||
- [Usage](#usage) | ||
- [Markup](#markup) | ||
- [JavaScript](#javascript) | ||
- [Construction](#construction) | ||
- [Sass](#sass) | ||
- [Markup](#markup) | ||
- [JavaScript](#javascript) | ||
- [Construction](#construction) | ||
- [Sass](#sass) | ||
- [Troubleshooting](#troubleshooting) | ||
@@ -16,24 +15,7 @@ - [Contact](#contact) | ||
## Usage | ||
This component provides accessible syntax highlighting for `bash`, `diff`, Javascript, JSON, YAML/YML, HTML, CSS and Sass/SCSS. | ||
_If there are any languages you would like to highlight that we don't currently support, please open an issue and we will provide it._ | ||
o-syntax-highlight uses the following colours, on a `grey-5` background (`#f2f2f2`). It is compliant with the contrast for [WCAG AA](https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html). In order to meet the criteria for AAA at 14px+, the colours would be far too dark to distinguish syntax highlighting effectively. | ||
## Markup | ||
Color | Hex | Ratio | 14px+ | 18px+ or 14px **bold** | ||
---|---|---|---|--- | ||
`black-crimson-25` | `#a50f2d` | [6.93](https://contrast-ratio.com/#%23a50f2d-on-%23f2f2f2) | AA | AAA | ||
`black-jade-30` | `#006b36` | [5.94](https://contrast-ratio.com/#%23006b36-on-%23f2f2f2) | AA | AAA | ||
`black-lemon-55` | `#736a0c` | [4.94](https://contrast-ratio.com/#%23736a0c-on-%23f2f2f2) | AA | AAA | ||
`crimson-jade-80` | `#a31f0f` | [6.79](http://contrast-ratio.com/#%23a31f0f-on-%23f2f2f2) | AA | AAA | ||
`grey-60` | `#666666` | [5.12](http://contrast-ratio.com/#%23666666-on-%23f2f2f2) | AA | AAA | ||
`grey-70` | `#4d4d4d` | [7.55](http://contrast-ratio.com/#%234d4d4d-on-%23f2f2f2) | AAA | AAA | ||
`oxford` | `#0f5499` | [6.82](http://contrast-ratio.com/#%230f5499-on-%23f2f2f2) | AA | AAA | ||
`oxford-jade-60` | `#097a7f` | [4.57](http://contrast-ratio.com/#%23097a7f-on-%23f2f2f2) | AA | AAA | ||
`oxford-lemon-80` | `#3f7280` | [4.77](http://contrast-ratio.com/#%233f7280-on-%23f2f2f2) | AA | AAA | ||
`oxford-crimson-50` | `#6e2a4d` | [8.92](http://contrast-ratio.com/#%236e2a4d-on-%23f2f2f2) | AAA | AAA | ||
### Markup | ||
o-syntax-highlight works with a single class. As long as this class is present in a wrapper that holds the code you wish to highlight, it will tokenise and colorise the syntax according to your preference. The semantically correct way of declaring a code block is to place a `<code>` inside a `<pre>`. That is what o-syntax-highlight looks for when it is tokenising the code block. | ||
@@ -108,3 +90,3 @@ | ||
### JavaScript | ||
## JavaScript | ||
@@ -114,7 +96,7 @@ No code will run automatically unless you are using the Build Service. | ||
#### Construction | ||
### Construction | ||
In order to use `o-syntax-highlight` with already declared markup, you can use: | ||
```js | ||
const oSyntaxHighlight = require('o-syntax-highlight'); | ||
import oSyntaxHighlight from 'o-syntax-highlight'; | ||
oSyntaxHighlight.init(); | ||
@@ -126,3 +108,3 @@ ``` | ||
```js | ||
const oSyntaxHighlight = require('o-syntax-highlight'); | ||
import oSyntaxHighlight from 'o-syntax-highlight'; | ||
const highlighter = new oSyntaxHighlight('code to highlight', { language: 'html'}); | ||
@@ -133,3 +115,3 @@ | ||
### Sass | ||
## Sass | ||
@@ -146,3 +128,3 @@ You can include highlighting for all languages by calling: | ||
'languages': ( | ||
'html', | ||
'html', | ||
'json' | ||
@@ -167,4 +149,5 @@ ) | ||
:---: | :---: | :---: | :---: | ||
✨ active | 2 | N/A | [migrate to v2](MIGRATION.md#migrating-from-v1-to-v2) | | ||
⚠ maintained | 1 | 1.6.4 | N/A | | ||
✨ active | 3 | N/A | [migrate to v3](MIGRATION.md#migrating-from-v2-to-v3) | | ||
⚠ maintained | 2 | 2.1 | [migrate to v2](MIGRATION.md#migrating-from-v1-to-v2) | | ||
╳ deprecated | 1 | 1.6.4 | N/A | | ||
@@ -171,0 +154,0 @@ ## Contact |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
31478
31
399
1
154
+ Added@financial-times/o-colors@5.4.1(transitive)
- Removed@financial-times/o-colors@4.10.3(transitive)