-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
126,352 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: check | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
setup: | ||
runs-on: ubuntu-18.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: "16.x" | ||
|
||
- name: Cache dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.npm | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-node- | ||
- run: npm install | ||
- run: npm run tsc | ||
- run: npm run test | ||
- run: npm run build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: demo | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-18.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: "16.x" | ||
|
||
- name: Cache dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.npm | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-node- | ||
- run: npm install | ||
- run: npm run storybook:build | ||
|
||
- name: Deploy | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./storybook-static | ||
publish_branch: demo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
lib | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
stories: [ | ||
"../stories/**/*.stories.mdx", | ||
"../stories/**/*.stories.@(js|jsx|ts|tsx)", | ||
], | ||
addons: ["@storybook/addon-links", "@storybook/addon-essentials"], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const parameters = { | ||
actions: { argTypesRegex: "^on[A-Z].*" }, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,68 @@ | ||
# remark-docx | ||
# remark-docx | ||
|
||
![npm](https://img.shields.io/npm/v/remark-docx) ![check](https://github.com/inokawa/remark-docx/workflows/check/badge.svg) ![demo](https://github.com/inokawa/remark-docx/workflows/demo/badge.svg) | ||
|
||
[remark](https://github.com/remarkjs/remark) plugin to transform markdown to docx. | ||
|
||
### 🚧 WIP 🚧 | ||
|
||
The goal is to support all nodes in [mdast](https://github.com/syntax-tree/mdast) syntax tree, but currently transformation and stylings may not be well. | ||
|
||
If you have some feature requests or improvements, please create a [issue](https://github.com/inokawa/remark-docx/issues) or [PR](https://github.com/inokawa/remark-docx/pulls). | ||
|
||
## Demo | ||
|
||
https://inokawa.github.io/remark-docx/ | ||
|
||
## Install | ||
|
||
```sh | ||
npm install remark-docx | ||
``` | ||
|
||
## Usage | ||
|
||
### Browser | ||
|
||
```javascript | ||
import { unified } from "unified"; | ||
import markdown from "remark-parse"; | ||
import docx, { Packer } from "remark-docx"; | ||
import { saveAs } from "file-saver"; | ||
|
||
const processor = unified().use(markdown).use(docx); | ||
|
||
const text = "# hello world"; | ||
|
||
(async () => { | ||
const doc = await processor.process(text); | ||
const blob = await Packer.toBlob(doc.result); | ||
saveAs(blob, "example.docx"); | ||
})(); | ||
``` | ||
|
||
### Node.js | ||
|
||
```javascript | ||
import { unified } from "unified"; | ||
import markdown from "remark-parse"; | ||
import docx, { Packer } from "remark-docx"; | ||
import * as fs from "fs"; | ||
|
||
const processor = unified().use(markdown).use(docx); | ||
|
||
const text = "# hello world"; | ||
|
||
(async () => { | ||
const doc = await processor.process(text); | ||
const buffer = await Packer.toBuffer(doc.result); | ||
fs.writeFileSync("example.docx", buffer); | ||
})(); | ||
``` | ||
|
||
## Options | ||
|
||
| Key | Default | Type | Description | | ||
| ------------- | --------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | ||
| docProperties | undefined | object | Override properties of document. | | ||
| imageResolver | undefined | ImageResolver | **You must set** if your markdown includes images. See example for [Node.js](https://github.com/inokawa/remark-docx/blob/main/src/index.spec.ts) and [browser](https://github.com/inokawa/remark-docx/blob/main/stories/playground.stories.tsx). | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
presets: [ | ||
["@babel/preset-env", { targets: { node: "current" } }], | ||
"@babel/preset-typescript", | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
--- | ||
title: "This is frontmatter" | ||
date: 2020-04-30 12:34 | ||
categories: [JavaScript, React] | ||
--- | ||
|
||
# heading 1 | ||
|
||
## heading 2 | ||
|
||
### heading 3 | ||
|
||
#### heading 4 | ||
|
||
##### heading 5 | ||
|
||
###### heading 6 | ||
|
||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | ||
|
||
aaaaaaaa**bold**_emphasis_~~delete~~`inline code` | ||
|
||
- list | ||
|
||
- list | ||
- list | ||
- list | ||
- list | ||
|
||
- [ ] not checked | ||
- [x] checked | ||
|
||
1. ordered list | ||
1. ordered list | ||
1. ordered list | ||
1. aaa | ||
1. aaa | ||
1. eeeee | ||
1. eeeee | ||
1. aaa | ||
1. ordered list | ||
|
||
This is [link to GitHub.com](https://github.com/). | ||
|
||
This is ![image](https://github.githubassets.com/images/modules/logos_page/Octocat.png). | ||
|
||
> quote | ||
> quote | ||
> quote | ||
> quote | ||
> quote | ||
> | ||
> > quoted quote | ||
| Left align | Right align | Center align | | ||
| :--------- | ----------: | :----------: | | ||
| This | This | This | | ||
| column | column | column | | ||
| will | will | will | | ||
| be | be | be | | ||
| left | right | center | | ||
| aligned | aligned | aligned | | ||
|
||
<div style="color:red;"> | ||
This is <u>HTML</u> | ||
</div> | ||
|
||
--- | ||
|
||
--- | ||
|
||
```javascript | ||
function $initHighlight(block, cls) { | ||
try { | ||
if (cls.search(/\bno\-highlight\b/) != -1) | ||
return process(block, true, 0x0F) + | ||
` class="${cls}"`; | ||
} catch (e) { | ||
/* handle exception */ | ||
} | ||
for (var i = 0 / 2; i < classes.length; i++) { | ||
if (checkCondition(classes[i]) === undefined) | ||
console.log('undefined'); | ||
} | ||
|
||
return ( | ||
<div> | ||
<web-component>{block}</web-component> | ||
</div> | ||
) | ||
} | ||
|
||
export $initHighlight; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
|
||
*** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
```css metadata="12345" | ||
@font-face { | ||
font-family: Chunkfive; | ||
src: url("Chunkfive.otf"); | ||
} | ||
|
||
body, | ||
.usertext { | ||
color: #f0f0f0; | ||
background: #600; | ||
font-family: Chunkfive, sans; | ||
--heading-1: 30px/32px Helvetica, sans-serif; | ||
} | ||
|
||
@import url(print.css); | ||
@media print { | ||
a[href^="http"]::after { | ||
content: attr(href); | ||
} | ||
} | ||
``` | ||
|
||
```javascript | ||
function $initHighlight(block, cls) { | ||
try { | ||
if (cls.search(/\bno\-highlight\b/) != -1) | ||
return process(block, true, 0x0F) + | ||
` class="${cls}"`; | ||
} catch (e) { | ||
/* handle exception */ | ||
} | ||
for (var i = 0 / 2; i < classes.length; i++) { | ||
if (checkCondition(classes[i]) === undefined) | ||
console.log('undefined'); | ||
} | ||
|
||
return ( | ||
<div> | ||
<web-component>{block}</web-component> | ||
</div> | ||
) | ||
} | ||
|
||
export $initHighlight; | ||
``` | ||
|
||
```typescript | ||
class MyClass { | ||
public static myValue: string; | ||
constructor(init: string) { | ||
this.myValue = init; | ||
} | ||
} | ||
import fs = require("fs"); | ||
module MyModule { | ||
export interface MyInterface extends Other { | ||
myProperty: any; | ||
} | ||
} | ||
declare magicNumber number; | ||
myArray.forEach(() => { }); // fat arrow syntax | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This is footnote[^1]. And this is also ^[inline footnote]. | ||
|
||
[^1]: Here is the footnote. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
+++ | ||
title = "This is toml" | ||
date = "2020-04-30 22:34" | ||
+++ | ||
|
||
# Other markdown | ||
|
||
blablabla |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
title: "This is yaml" | ||
date: 2020-04-30 22:34 | ||
categories: [JavaScript, React] | ||
--- | ||
|
||
# Other markdown | ||
|
||
blablabla |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Alpha | ||
|
||
aaaa | ||
|
||
## Bravo | ||
|
||
bbbb | ||
|
||
### Charlie | ||
|
||
cccc | ||
|
||
## Delta | ||
|
||
dddd | ||
|
||
### E | ||
|
||
#### F | ||
|
||
##### G | ||
|
||
###### H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Lift($L$) can be determined by Lift Coefficient ($C_L$) like the following | ||
equation. | ||
|
||
$$ | ||
L = \frac{1}{2} \rho v^2 S C_L | ||
$$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<div> | ||
<span>This is <b>html</b></span> | ||
</div> | ||
|
||
<!--comment--> | ||
|
||
<mailto:foobarbaz> | ||
|
||
aaaaaa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. | ||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. |
Oops, something went wrong.