Avoid export default

This commit is contained in:
Aya Morisawa 2019-01-30 16:56:27 +09:00
parent 1c60a49c96
commit 28bfb45426
No known key found for this signature in database
GPG key ID: 3E64865D70D579F2
18 changed files with 26 additions and 28 deletions

View file

@ -1,7 +1,7 @@
const parse5 = require('parse5');
import { URL } from 'url';
export default function(html: string): string {
export function fromHtml(html: string): string {
if (html == null) return null;
const dom = parse5.parseFragment(html);

View file

@ -1,19 +1,19 @@
import parser from './parser';
import { mfmLanguage } from './parser';
import { MfmForest } from './types';
import { normalize } from './normalize';
export default (source: string): MfmForest => {
export function parse(source: string): MfmForest {
if (source == null || source == '') {
return null;
}
return normalize(parser.root.tryParse(source));
};
return normalize(mfmLanguage.root.tryParse(source));
}
export function parsePlain(source: string): MfmForest {
if (source == null || source == '') {
return null;
}
return normalize(parser.plain.tryParse(source));
return normalize(mfmLanguage.plain.tryParse(source));
}

View file

@ -28,7 +28,7 @@ const newline = P((input, i) => {
}
});
const mfm = P.createLanguage({
export const mfmLanguage = P.createLanguage({
root: r => P.alt(
r.big,
r.small,
@ -413,5 +413,3 @@ const mfm = P.createLanguage({
.map(x => createLeaf('url', { url: x })),
//#endregion
});
export default mfm;

View file

@ -5,7 +5,7 @@ import { INote } from '../models/note';
import { intersperse } from '../prelude/array';
import { MfmForest, MfmTree } from './types';
export default (tokens: MfmForest, mentionedRemoteUsers: INote['mentionedRemoteUsers'] = []) => {
export function toHtml(tokens: MfmForest, mentionedRemoteUsers: INote['mentionedRemoteUsers'] = []) {
if (tokens == null) {
return null;
}
@ -184,4 +184,4 @@ export default (tokens: MfmForest, mentionedRemoteUsers: INote['mentionedRemoteU
appendChildren(tokens, doc.body);
return `<p>${doc.body.innerHTML}</p>`;
};
}