Skip to content

Commit

Permalink
Render citations
Browse files Browse the repository at this point in the history
  • Loading branch information
pfoerster committed Jun 5, 2019
1 parent 2a4bc47 commit 4807f19
Show file tree
Hide file tree
Showing 14 changed files with 4,230 additions and 24 deletions.
93 changes: 93 additions & 0 deletions citeproc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@

# Created by https://www.gitignore.io/api/node
# Edit at https://www.gitignore.io/?templates=node

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# End of https://www.gitignore.io/api/node

# TypeScript output
out/

# dist
dist/
5 changes: 5 additions & 0 deletions citeproc/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"printWidth": 80,
"singleQuote": true,
"trailingComma": "all"
}
34 changes: 34 additions & 0 deletions citeproc/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "texlab-citeproc",
"version": "0.1.0",
"description": "LaTeX Language Server",
"repository": "https://github.com/latex-lsp/texlab.git",
"author": "Eric Förster <[email protected]>",
"license": "MIT",
"scripts": {
"dist": "webpack",
"build": "tsc -p .",
"watch": "tsc -p . --watch",
"lint": "tslint --project .",
"format": "prettier --write \"src/**/*.{ts,json}\" \"*.{ts,json,yml,md}\" \".vscode/**/*.{json}\""
},
"devDependencies": {
"@citation-js/core": "^0.4.0-rc.4",
"@citation-js/plugin-bibtex": "^0.4.0-rc.4",
"@citation-js/plugin-csl": "^0.4.0-rc.4",
"@types/jsdom": "^12.2.3",
"@types/node": "^11.12.0",
"@types/turndown": "^5.0.0",
"@types/webpack": "^4.4.26",
"null-loader": "^0.1.1",
"prettier": "^1.14.3",
"ts-loader": "^5.3.3",
"ts-node": "^8.0.3",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0",
"turndown": "^5.0.3",
"typescript": "^3.0.3",
"webpack": "^4.29.6",
"webpack-cli": "^3.3.0"
}
}
7 changes: 7 additions & 0 deletions citeproc/src/citation-js.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
declare module '@citation-js/core' {
export class Cite {
constructor(text: string);

public format(type: string, options: any): string;
}
}
13 changes: 13 additions & 0 deletions citeproc/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Cite } from '@citation-js/core';
import '@citation-js/plugin-bibtex';
import '@citation-js/plugin-csl';
import fs from 'fs';

const code = fs.readFileSync('entry.bib').toString();
const cite = new Cite(code);
const html = cite.format('bibliography', {
format: 'html',
template: 'apa',
lang: 'en-US',
});
console.log(html);
15 changes: 15 additions & 0 deletions citeproc/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"lib": ["es6"],
"rootDir": "src",
"outDir": "dist",
"sourceMap": true,
"strict": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"skipLibCheck": true
},
"include": ["src/**/*"]
}
20 changes: 20 additions & 0 deletions citeproc/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"no-implicit-dependencies": false,
"interface-name": false,
"max-classes-per-file": false,
"object-literal-sort-keys": false,
"variable-name": [
true,
"ban-keywords",
"check-format",
"allow-leading-underscore",
"allow-pascal-case"
],
"no-empty": false,
"no-console": false,
"no-conditional-assignment": false,
"no-bitwise": false
}
}
44 changes: 44 additions & 0 deletions citeproc/webpack.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import path from 'path';
import { Configuration, ContextReplacementPlugin } from 'webpack';

const config: Configuration = {
target: 'node',
entry: './src/main.ts',
mode: 'production',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'citeproc.js',
libraryTarget: 'commonjs2',
devtoolModuleFilenameTemplate: '../[resource-path]',
},
resolve: {
extensions: ['.ts', '.js', '.json'],
},
plugins: [
// Do not resolve canvas API of jsdom (jsdom/lib/jsdom/utils.js 186:21-40)
new ContextReplacementPlugin(/jsdom[/\\]lib/, /^$/),

// Do not resolve streaming API of parse5 (parse5/lib/index.js 55:23-49)
new ContextReplacementPlugin(/parse5[/\\]lib/, /^$/),
],
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
use: [
{
loader: 'ts-loader',
},
],
},
{
// Map browser dependencies to an empty module
test: /node_modules[/\\](sync-request|isomorphic-fetch|ws)[/\\]/,
use: 'null-loader',
},
],
},
};

export default config;
Loading

0 comments on commit 4807f19

Please sign in to comment.