@progfay/scrapbox-parser
Advanced tools
Comparing version 1.1.2 to 1.2.0
@@ -8,4 +8,5 @@ import { QuoteNodeType } from './QuoteNode'; | ||
import { IconNodeType } from './IconNode'; | ||
import { HashTagNodeType } from './HashTagNode'; | ||
import { PlainNodeType } from './PlainNode'; | ||
export declare type LineNodeType = QuoteNodeType | StrongNodeType | DecorationNodeType | CodeNodeType | UrlNodeType | InternalLinkNodeType | IconNodeType | PlainNodeType; | ||
export declare type LineNodeType = QuoteNodeType | StrongNodeType | DecorationNodeType | CodeNodeType | UrlNodeType | InternalLinkNodeType | IconNodeType | HashTagNodeType | PlainNodeType; | ||
export declare const convertToLineNodes: (text: string, { nested, quoted }?: { | ||
@@ -12,0 +13,0 @@ nested: boolean; |
@@ -10,2 +10,3 @@ "use strict"; | ||
const IconNode_1 = require("./IconNode"); | ||
const HashTagNode_1 = require("./HashTagNode"); | ||
const PlainNode_1 = require("./PlainNode"); | ||
@@ -88,5 +89,5 @@ exports.convertToLineNodes = (text, { nested, quoted } = { nested: false, quoted: false }) => { | ||
} | ||
const urlMatch = text.match(/^(.*?)(https?:\/\/[^\s\]]+)(.*)$/); | ||
if (urlMatch) { | ||
const [, left, target, right] = urlMatch; | ||
const httpMatch = text.match(UrlNode_1.httpRegExp); | ||
if (httpMatch) { | ||
const [, left, target, right] = httpMatch; | ||
return [ | ||
@@ -98,4 +99,13 @@ ...exports.convertToLineNodes(left, { nested, quoted }), | ||
} | ||
const hashTagMatch = text.match(HashTagNode_1.hashTagRegExp); | ||
if (hashTagMatch) { | ||
const [, left, target, right] = hashTagMatch; | ||
return [ | ||
...exports.convertToLineNodes(left, { nested, quoted }), | ||
HashTagNode_1.createHashTagNode(target), | ||
...exports.convertToLineNodes(right, { nested, quoted }) | ||
]; | ||
} | ||
return [PlainNode_1.createPlainNode(text)]; | ||
}; | ||
//# sourceMappingURL=index.js.map |
import { ExternalLinkNodeType } from './ExternalLinkNode'; | ||
import { ImageNodeType } from './ImageNode'; | ||
export declare const httpRegExp: RegExp; | ||
export declare const urlRegExp: RegExp; | ||
@@ -4,0 +5,0 @@ export declare const leftUrlRegExp: RegExp; |
@@ -5,2 +5,3 @@ "use strict"; | ||
const ImageNode_1 = require("./ImageNode"); | ||
exports.httpRegExp = /^(.*?)(https?:\/\/[^\s\]]+)(.*)$/; | ||
exports.urlRegExp = /^(.*?)\[(?<href>https?:\/\/[^\s\]]+)(?<content>)\](.*)$/; | ||
@@ -7,0 +8,0 @@ exports.leftUrlRegExp = /^(.*?)\[(?<href>https?:\/\/[^\s\]]+)\s+(?<content>[^\]]*[^\s])\](.*)$/; |
{ | ||
"name": "@progfay/scrapbox-parser", | ||
"version": "1.1.2", | ||
"version": "1.2.0", | ||
"description": "parse Scrapbox notation to JavaScript Object", | ||
@@ -11,4 +11,2 @@ "main": "./lib/index.js", | ||
"prepare": "npm run build", | ||
"predoc": "rm -rf docs", | ||
"doc": "typedoc --out docs ./src", | ||
"test": "jest --coverage", | ||
@@ -48,3 +46,2 @@ "test:update": "jest --updateSnapshot", | ||
"ts-jest": "^24.0.2", | ||
"typedoc": "^0.14.2", | ||
"typescript": "^3.5.2" | ||
@@ -51,0 +48,0 @@ }, |
# Scrapbox Parser | ||
[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) [![npm version](https://badge.fury.io/js/%40progfay%2Fscrapbox-parser.svg)](https://badge.fury.io/js/%40progfay%2Fscrapbox-parser) [![Build Status](https://travis-ci.org/progfay/scrapbox-parser.svg?branch=master)](https://travis-ci.org/progfay/scrapbox-parser) [![Coverage Status](https://coveralls.io/repos/github/progfay/scrapbox-parser/badge.svg?branch=master)](https://coveralls.io/github/progfay/scrapbox-parser?branch=master) | ||
[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) [![npm version](https://badge.fury.io/js/%40progfay%2Fscrapbox-parser.svg)](https://badge.fury.io/js/%40progfay%2Fscrapbox-parser) [![Build Status](https://travis-ci.org/progfay/scrapbox-parser.svg?branch=master)](https://travis-ci.org/progfay/scrapbox-parser) [![Coverage Status](https://coveralls.io/repos/github/progfay/scrapbox-parser/badge.svg?branch=master)](https://coveralls.io/github/progfay/scrapbox-parser?branch=master) [![Maintainability](https://api.codeclimate.com/v1/badges/1a79f7f5f4b1785ac616/maintainability)](https://codeclimate.com/github/progfay/scrapbox-parser/maintainability) | ||
@@ -5,0 +5,0 @@ parse Scrapbox notation to JavaScript Object |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
49852
15
83
564