Skip to content

Commit 5bc7e45

Browse files
committed
Rewrite
1 parent 2bc3307 commit 5bc7e45

35 files changed

+2511
-1807
lines changed

.gitignore

+15-10
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11

2-
# Created by https://www.gitignore.io/api/node,visualstudiocode
2+
# Created by https://www.gitignore.io/api/node
33

44
### Node ###
55
# Logs
66
logs
77
*.log
88
npm-debug.log*
9+
yarn-debug.log*
10+
yarn-error.log*
911

1012
# Runtime data
1113
pids
@@ -25,15 +27,21 @@ coverage
2527
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
2628
.grunt
2729

30+
# Bower dependency directory (https://bower.io/)
31+
bower_components
32+
2833
# node-waf configuration
2934
.lock-wscript
3035

3136
# Compiled binary addons (http://nodejs.org/api/addons.html)
3237
build/Release
3338

3439
# Dependency directories
35-
node_modules
36-
jspm_packages
40+
node_modules/
41+
jspm_packages/
42+
43+
# Typescript v1 declaration files
44+
typings/
3745

3846
# Optional npm cache directory
3947
.npm
@@ -50,12 +58,9 @@ jspm_packages
5058
# Yarn Integrity file
5159
.yarn-integrity
5260

53-
# Build
54-
lib
61+
# dotenv environment variables file
62+
.env
5563

5664

57-
### VisualStudioCode ###
58-
.vscode/*
59-
!.vscode/settings.json
60-
!.vscode/tasks.json
61-
!.vscode/launch.json
65+
# End of https://www.gitignore.io/api/node
66+
lib

.vscode/settings.json

-3
This file was deleted.

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
The MIT License (MIT)
2-
Copyright © 2016 3846masa
2+
Copyright © 2017 3846masa
33

44
Permission is hereby granted, free of charge, to any person obtaining a copy
55
of this software and associated documentation files (the “Software”), to deal

README.md

+156-20
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
# remark-latex
1+
# @paperist/remark-latex
22

3-
[![standard-readme compliant][standard-readme-badge]][standard-readme]
43
[![LICENSE][license-badge]][license]
54
[![NPM][npm-badge]][npm]
6-
[![CircleCI][circleci-badge]][circleci]
5+
[![standard-readme compliant][standard-readme-badge]][standard-readme]
76

87
[npm]: https://www.npmjs.com/package/@paperist/remark-latex
98
[license]: https://3846masa.mit-license.org
10-
[circleci]: https://circleci.com/gh/Paperist/remark-latex
119
[standard-readme]: https://github.com/RichardLitt/standard-readme
1210

1311
[npm-badge]: https://img.shields.io/npm/v/@paperist/remark-latex.svg?style=flat-square&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgBAMAAACBVGfHAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAbUExURcwAAOeIiP////G7u/ri4tIZGdpFReJsbPC3t075sZwAAAAvSURBVCjPY2CgDWAThIMEsACjEhwIUCZg0dGCIqASwMAxMgXAgSzOwMAOC2TqAwBvzR4JxLaP0gAAAABJRU5ErkJggg==
1412
[license-badge]: https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAIGNIUk0AAHomAACAhAAA%2BgAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAVUExURSBTICJcIiNgIiZoJTuhNyt3Kf///%2BCqxSgAAAAGdFJOUwpclbn%2B4Fj6/H8AAAABYktHRAZhZrh9AAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4AkEEjEV7MDQQwAAAGBJREFUCNc1TUEKgDAMi07vE/Q%2BRD8g%2B4BbvAvi/79iMjDQJm1CC6BbDzRsZI3incIpYeYFhCaYnLiyPYnYkwWZFWoFHrSuttCmmbwXh0eJQYVON4JthZTxCzzAmyb8%2BAAKXBRyN6RyZQAAAABJRU5ErkJggg==
15-
[circleci-badge]: https://img.shields.io/circleci/project/Paperist/remark-latex/master.svg?style=flat-square&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQEAYAAABPYyMiAAAAIGNIUk0AAHomAACAhAAA%2BgAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAGYktHRP///////wlY99wAAAAHdElNRQfgCQQSJS8EYt6kAAAAiklEQVRIx2M41nqs9Xi9WDQh%2BjQQnDnz%2BS5x9KS9xJrLgN/CSXtJs5h0BzHQ1mLCDmEgL4jJpyl0AOG4JTYE4Q6gdqIi1UMM2F1OrE9xBy2xDmGgrs8wHU5nB2CGBNEOQPcBoaigThQA08AgS4QDkA3pXRChe4SBskqHiiUhreoEsmtDyhxEfKIFAG4yoGuqR9fTAAAAAElFTkSuQmCC
1613
[standard-readme-badge]: https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square
1714

1815
> [wooorm/remark] plugin for latex
@@ -21,41 +18,180 @@
2118

2219
## Table of Contents
2320

21+
<!-- TOC depthFrom:2 depthTo:3 updateOnSave:false -->
22+
2423
- [Install](#install)
2524
- [Usage](#usage)
25+
- [CLI](#cli)
26+
- [Syntax](#syntax)
27+
- [Configure](#configure)
2628
- [Contribute](#contribute)
2729
- [License](#license)
2830

31+
<!-- /TOC -->
32+
2933
## Install
3034

3135
```
32-
npm i remark @paperist/remark-latex
36+
npm i remark remark-cli @paperist/remark-latex
3337
```
3438

3539
## Usage
3640

37-
```js
38-
const remark = require('remark');
39-
const latex = require('remark-latex');
41+
### CLI
42+
43+
See [here][remark-cli] for more details.
44+
45+
```bash
46+
remark -u @paperist/remark-latex document.md -o document.tex
47+
```
48+
49+
If you configure via `rc` file, you should type below.
50+
51+
```bash
52+
remark -r ./remarkrc.yml document.md -o document.tex
53+
```
54+
55+
[remark-cli]: https://github.com/wooorm/remark/tree/master/packages/remark-cli#cli
56+
57+
### Syntax
58+
59+
Inspired by [pandoc-crossref].
60+
61+
[pandoc-crossref]: https://github.com/lierdakil/pandoc-crossref
62+
63+
#### Image label
64+
65+
```md
66+
![Caption](file.ext){#fig:label}
67+
```
68+
69+
#### Equation label
70+
71+
```md
72+
$$ math $$ {#eq:label}
73+
```
74+
75+
#### Table caption / label
76+
77+
```md
78+
| a | b | c |
79+
|:---:|:---:|:---:|
80+
| 1 | 2 | 3 |
81+
82+
: Caption {#tbl:label}
83+
```
84+
85+
#### Section label
86+
87+
```md
88+
# Section {#sec:section}
89+
```
90+
91+
#### Code block label
92+
93+
**Not implemented**
4094

41-
const markdown = `
42-
# Introduction
95+
#### References
4396

44-
This paper proposes ...
45-
`;
97+
##### From label (e.g. Figure)
4698

47-
remark().use(latex).process(markdown, (err, vfile) => {
48-
if (err) {
49-
console.error(err);
50-
}
51-
console.log(vfile);
52-
});
99+
```md
100+
[@fig:label1] or [@fig:label1;@fig:label2;...]
53101
```
54102

103+
##### BibTeX
104+
105+
```md
106+
[@jones99] or [@jones99;@smith06;...]
107+
```
108+
109+
### Configure
110+
111+
#### Fields
112+
113+
| Field | Description |
114+
| :----------: | :----------------------------------------------------- |
115+
| baseTemplate | The document template |
116+
| documentInfo | The data passed to the base template |
117+
| imageConfigs | `\includegraphics` configs |
118+
| templatesDir | Template folder for AST (See [`templates`][templates]) |
119+
120+
[templates]: https://github.com/Paperist/remark-latex/tree/master/src/templates
121+
122+
##### Templates
123+
124+
You can use [ejs] template.
125+
remark-latex read `baseTemplate` and bind `documentInfo` to output.
126+
127+
[ejs]: https://github.com/mde/ejs
128+
129+
```latex
130+
%% TeX Template written by ejs format.
131+
132+
\author{<%= author %>}
133+
\title{<%= title %>}
134+
135+
\begin{document}
136+
137+
\maketitle
138+
139+
%% Render results will be exported as `body`.
140+
<%= body %>
141+
142+
\end{document}
143+
```
144+
145+
#### `remarkrc`
146+
147+
You can configure via `rc` file (e.g. `remarkrc.json`, `remarkrc.yml`).
148+
See also [here][remarkrc].
149+
150+
```yml
151+
# Required
152+
output: true
153+
plugins:
154+
- "@paperist/remark-latex"
155+
156+
# Optional
157+
# NOTE: You should put remark-latex configs under `latex`.
158+
settings:
159+
latex:
160+
baseTemplate: latex/template.tex
161+
imageConfigs:
162+
width: 0.9\linewidth
163+
documentInfo:
164+
title: A Survey on Markdown
165+
author:
166+
- John Smith
167+
```
168+
169+
[remarkrc]: https://github.com/unifiedjs/unified-engine/blob/master/doc/configure.md
170+
171+
#### YAML Frontmatter
172+
173+
You can configure each files via YAML Frontmatter.
174+
See also [here][yaml-frontmatter]
175+
176+
177+
```md
178+
---
179+
baseTemplate: ../latex/template.tex
180+
---
181+
182+
# Hello World
183+
Lorem ipsum dolor sit amet...
184+
```
185+
186+
[yaml-frontmatter]: https://github.com/wooorm/remark-frontmatter
187+
55188
## Contribute
56189

57190
PRs accepted.
58191

59192
## License
60193

61-
MIT © 3846masa
194+
![3846masa] MIT (c) 3846masa
195+
196+
[3846masa]: https://www.gravatar.com/avatar/cfeae69aae4f4fc102960f01d35d2d86?s=50
197+

index.js

-3
This file was deleted.

package.json

+38-27
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,55 @@
11
{
22
"name": "@paperist/remark-latex",
33
"description": "wooorm/remark plugin for latex",
4+
"license": "MIT",
45
"version": "0.0.7",
6+
"main": "lib/index.js",
7+
"files": [
8+
"lib"
9+
],
10+
"scripts": {
11+
"build": "npm-run-all clean -p build:*",
12+
"build:cp": "cpx \"src/**/!(*.ts)\" lib",
13+
"build:ts": "tsc",
14+
"clean": "rimraf lib/*"
15+
},
516
"dependencies": {
6-
"ejs": "^2.5.2",
7-
"js-yaml": "^3.7.0",
8-
"lodash": "^4.17.2",
9-
"unist-util-visit": "^1.1.1"
17+
"@paperist/remark-crossref": "^1.0.3",
18+
"@paperist/remark-math": "^1.0.3",
19+
"@paperist/remark-table-caption": "^1.0.1",
20+
"ejs": "^2.5.7",
21+
"find-up": "^2.1.0",
22+
"js-yaml": "^3.9.1",
23+
"lodash": "^4.17.4",
24+
"remark-frontmatter": "^1.1.0",
25+
"unist-util-visit": "^1.1.3"
1026
},
1127
"devDependencies": {
28+
"@paperist/types-remark": "^0.1.3",
1229
"@types/ejs": "^2.3.33",
13-
"@types/js-yaml": "^3.5.28",
14-
"@types/lodash": "^4.14.43",
15-
"@types/node": "^6.0.48",
30+
"@types/js-yaml": "^3.9.0",
31+
"@types/lodash": "^4.14.71",
32+
"@types/node": "^8.0.19",
1633
"cpx": "^1.5.0",
17-
"greenkeeper-postpublish": "^1.0.1",
18-
"npm-run-all": "^4.0.0",
19-
"rimraf": "^2.5.4",
20-
"typescript": "^2.0.10"
34+
"husky": "^0.14.3",
35+
"npm-run-all": "^4.0.2",
36+
"prettier-package-json": "^1.4.0",
37+
"remark": "^8.0.0",
38+
"remark-cli": "^4.0.0",
39+
"rimraf": "^2.6.1",
40+
"typescript": "^2.4.2"
2141
},
22-
"files": [
23-
"package.json",
24-
"README",
25-
"LICENSE",
26-
"lib",
27-
"index.js"
28-
],
2942
"keywords": [
3043
"latex",
3144
"markdown",
3245
"remark",
3346
"tex"
3447
],
35-
"license": "MIT",
36-
"main": "index.js",
37-
"scripts": {
38-
"build": "npm-run-all clean -p build:*",
39-
"build:cp": "cpx 'src/**/!(*.ts)' lib",
40-
"build:ts": "tsc",
41-
"clean": "rimraf lib/*",
42-
"postpublish": "greenkeeper-postpublish"
43-
}
48+
"lint-staged": {
49+
"package.json": [
50+
"prettier-package-json --write",
51+
"git add"
52+
]
53+
},
54+
"types": "lib/index.d.ts"
4455
}

src/@types/unist-util-visit/index.d.ts

-1
This file was deleted.

0 commit comments

Comments
 (0)