diff --git a/README.md b/README.md index 3561a7f..6b252ae 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ Between title and group or lines, we can set meta data in markdown by key-value - age: show - date: 2014/01/01 - author: @hotoo -- memtion: https://twitter.com/{@memtion} +- mention: https://twitter.com/{@mention} ---- @@ -128,19 +128,19 @@ Now we support meta data: ```markdown - age: show ``` -* `memtion`: set memtion enable, and memtion base url. default memtion is disable. +* `mention`: set mention enable, and mention base url. default mention is disable. ```md - # @Memtion Demo + # @Mention Demo - - memtion: https://github.com/{@memtion} + - mention: https://github.com/{@mention} ---- - - 2014 @hotoo memtion @lizzie + - 2014 @hotoo mention @lizzie ``` - `{@memtion}` is placeholder for memtion name. + `{@mention}` is placeholder for mention name. * `hashtag`: custom hashtag styles. diff --git a/examples/data.mdown b/examples/data.mdown index 04fa442..a52032c 100644 --- a/examples/data.mdown +++ b/examples/data.mdown @@ -4,7 +4,7 @@ - date: 2014/09/20 - author: @hotoo - age: show -- memtion: https://twitter.com/{@memtion} +- mention: https://twitter.com/{@mention} - tags: - job: #fff, #f00 - life: #fff, rgba(255,0,0,0.5) @@ -20,7 +20,7 @@ ## @Memthon and #HashTags -- 1998 @hotoo memtion @lizzie +- 1998 @hotoo mention @lizzie - 1998 this is my #life - 2013/05/07~2014/10/04 Fall in Love with @lizzie #hashtag - 2014-09-30 Married diff --git a/markline.js b/markline.js index 814a596..0e4d7e5 100644 --- a/markline.js +++ b/markline.js @@ -2,7 +2,7 @@ var Timeline = require("./timeline"); var $ = require("jquery"); -var DEFAULT_MEMTION_URL = "https://github.com/{@memtion}"; +var DEFAULT_MENTION_URL = "https://github.com/{@mention}"; function isString (object){ return Object.prototype.toString.call(object) === "[object String]"; @@ -69,8 +69,8 @@ function parseMarkdown(markdown, meta){ var RE_STRONG = /(\*\*|__)(.*?)\1/g; var RE_EM = /(\*|_)(.*?)\1/g; var RE_DELETE = /(\~\~?)(.*?)\1/g; - var RE_MEMTION = /(^|[^a-zA-Z0-9])@([^\s\t,\(\)\[\]\{\}]+)/g; - var RE_MEMTION_PLACEHOLDER = /\{@memtion\}/ig; + var RE_MENTION = /(^|[^a-zA-Z0-9])@([^\s\t,\(\)\[\]\{\}]+)/g; + var RE_MENTION_PLACEHOLDER = /\{@mention\}/ig; var RE_HASHTAG = /(?:^|[\s\t])\#([^\s\t]+)/g; @@ -80,13 +80,13 @@ function parseMarkdown(markdown, meta){ html = html.replace(RE_EM, '$2'); html = html.replace(RE_DELETE, '$2'); - // memtion: - if (meta.memtion) { - html = html.replace(RE_MEMTION, function($0, prefix, memtion_name){ - var memtion_url = meta.memtion || DEFAULT_MEMTION_URL; + // mention: + if (meta.mention) { + html = html.replace(RE_MENTION, function($0, prefix, mention_name){ + var mention_url = meta.mention || DEFAULT_MENTION_URL; return prefix + '@' + memtion_name + ''; + mention_url.replace(RE_MENTION_PLACEHOLDER, mention_name) + + '" target="_blank">@' + mention_name + ''; }); }