Skip to content

Commit

Permalink
Add support for CHM (#424)
Browse files Browse the repository at this point in the history
Add support for CHM (Microsoft Compiled HTML Help)
  • Loading branch information
Richienb committed Dec 21, 2020
1 parent b19e296 commit e43cdc9
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
6 changes: 4 additions & 2 deletions core.d.ts
Expand Up @@ -135,7 +135,8 @@ declare namespace core {
| 'lzh'
| 'pgp'
| 'asar'
| 'stl';
| 'stl'
| 'chm';

type MimeType =
| 'image/jpeg'
Expand Down Expand Up @@ -264,7 +265,8 @@ declare namespace core {
| 'application/x-lzh-compressed'
| 'application/pgp-encrypted'
| 'application/x-asar'
| 'model/stl';
| 'model/stl'
| 'application/vnd.ms-htmlhelp';

interface FileTypeResult {
/**
Expand Down
7 changes: 7 additions & 0 deletions core.js
Expand Up @@ -880,6 +880,13 @@ async function _fromTokenizer(tokenizer) {
}
}

if (checkString('ITSF')) {
return {
ext: 'chm',
mime: 'application/vnd.ms-htmlhelp'
};
}

// -- 6-byte signatures --

if (check([0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00])) {
Expand Down
Binary file added fixture/fixture.chm
Binary file not shown.
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -179,7 +179,8 @@
"lzh",
"pgp",
"asar",
"stl"
"stl",
"chm"
],
"devDependencies": {
"@types/node": "^13.1.4",
Expand Down
1 change: 1 addition & 0 deletions readme.md
Expand Up @@ -404,6 +404,7 @@ Returns a set of supported MIME types.
- [`pgp`](https://en.wikipedia.org/wiki/Pretty_Good_Privacy) - Pretty Good Privacy
- [`asar`](https://github.com/electron/asar#format) - Archive format primarily used to enclose Electron applications
- [`stl`](https://en.wikipedia.org/wiki/STL_(file_format)) - Standard Tesselated Geometry File Format (ASCII only)
- [`chm`](https://en.wikipedia.org/wiki/Microsoft_Compiled_HTML_Help) - Microsoft Compiled HTML Help

*Pull requests are welcome for additional commonly used file types.*

Expand Down
6 changes: 4 additions & 2 deletions supported.js
Expand Up @@ -133,7 +133,8 @@ module.exports = {
'lzh',
'pgp',
'asar',
'stl'
'stl',
'chm'
],
mimeTypes: [
'image/jpeg',
Expand Down Expand Up @@ -262,6 +263,7 @@ module.exports = {
'application/x-lzh-compressed',
'application/pgp-encrypted',
'application/x-asar',
'model/stl'
'model/stl',
'application/vnd.ms-htmlhelp'
]
};

0 comments on commit e43cdc9

Please sign in to comment.