Skip to content

Commit

Permalink
Merge pull request #69 from stencila/code
Browse files Browse the repository at this point in the history
Conversion of source code nodes
  • Loading branch information
nokome authored Jun 6, 2019
2 parents 9fe2f68 + ae885d8 commit a902e99
Show file tree
Hide file tree
Showing 18 changed files with 2,719 additions and 87 deletions.
58 changes: 17 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"dependencies": {
"@stencila/logga": "^1.0.0",
"@stencila/schema": "^0.12.2",
"@stencila/schema": "^0.13.1",
"ajv": "^6.10.0",
"axios": "^0.19.0",
"better-ajv-errors": "^0.6.4",
Expand Down Expand Up @@ -59,6 +59,7 @@
"remark-generic-extensions": "^1.4.0",
"remark-parse": "^6.0.3",
"remark-stringify": "^6.0.4",
"tempy": "^0.3.0",
"to-vfile": "^6.0.0",
"unified": "^7.1.0",
"unist-util-filter": "^1.0.2",
Expand Down Expand Up @@ -98,7 +99,6 @@
"prettier": "^1.17.1",
"semantic-release": "^15.13.12",
"tar": "^4.4.9",
"tempy": "^0.3.0",
"ts-jest": "^24.0.1",
"ts-node": "^8.2.0",
"tslint": "^5.17.0",
Expand Down
8 changes: 0 additions & 8 deletions src/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,6 @@ function decodeLink(elem: HTMLAnchorElement): stencila.Link {
content: decodeInlineChildNodes(elem)
}
const meta = decodeDataAttrs(elem)
// TODO: remove ts-ignore
// @ts-ignore
if (meta) link.meta = meta
return link
}
Expand All @@ -531,8 +529,6 @@ function decodeLink(elem: HTMLAnchorElement): stencila.Link {
function encodeLink(link: stencila.Link): HTMLAnchorElement {
let attrs = {
href: link.target,
// TODO: remove ts-ignores
// @ts-ignore
...encodeDataAttrs(link.meta || {})
}
return h('a', attrs, link.content.map(encodeNode))
Expand Down Expand Up @@ -568,8 +564,6 @@ function decodeCode(elem: HTMLElement): stencila.Code {
}
}
const meta = decodeDataAttrs(elem)
// TODO: remove ts-ignore
// @ts-ignore
if (meta) code.meta = meta
return code
}
Expand All @@ -584,8 +578,6 @@ function encodeCode(
return h('code', {
class: code.language ? `language-${code.language}` : undefined,
innerHTML: escape(code.value),
// TODO: remove ts-ignore
// @ts-ignore
...(dataAttrs ? encodeDataAttrs(code.meta || {}) : {})
})
}
Expand Down
11 changes: 9 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import stencila from '@stencila/schema'
import * as stencila from '@stencila/schema'
import mime from 'mime'
import path from 'path'
import * as csv from './csv'
import * as demoMagic from './demo-magic'
import * as docx from './docx'
import * as gdoc from './gdoc'
import * as html from './html'
import * as ipynb from './ipynb'
import * as jats from './jats'
import * as json from './json'
import * as json5 from './json5'
Expand All @@ -17,6 +18,7 @@ import * as pandoc from './pandoc'
import * as pdf from './pdf'
import * as rpng from './rpng'
import * as tdp from './tdp'
import * as txt from './txt'
import * as vfile from './vfile'
import * as xlsx from './xlsx'
import * as yaml from './yaml'
Expand All @@ -42,11 +44,13 @@ export const codecList: Array<Codec> = [
docx,
gdoc,
html,
ipynb,
jats,
latex,
md,
odt,
pdf,
txt,

// Scripts
demoMagic,
Expand Down Expand Up @@ -154,7 +158,10 @@ export async function match(content?: string, format?: string): Promise<Codec> {
// If the content is a path then begin with derived values
if (content && vfile.isPath(content)) {
fileName = path.basename(content)
extName = path.extname(content).slice(1)
extName = path
.extname(content)
.slice(1)
.toLowerCase()
mediaType = mime.getType(content) || undefined
}
// But override with supplied format (if any) assuming that
Expand Down
Loading

0 comments on commit a902e99

Please sign in to comment.