From 4cabbe1668879aa784af91ad276ece294bcf65fd Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 9 Feb 2017 22:47:17 +0900 Subject: [PATCH] Method and property support --- src/common/text/elements/code.js | 27 +++++++++++++++++++++++++++ src/web/app/base.styl | 7 +++++++ 2 files changed, 34 insertions(+) diff --git a/src/common/text/elements/code.js b/src/common/text/elements/code.js index 958bbe8d87..bda3816a7b 100644 --- a/src/common/text/elements/code.js +++ b/src/common/text/elements/code.js @@ -240,6 +240,33 @@ const elements = [ } }, + // method + code => { + const match = code.match(/^([a-zA-Z_-]+?)\(/); + if (!match) return null; + + if (match[1] == '-') return null; + + return { + html: `${match[1]}`, + next: match[1].length + }; + }, + + // property + (code, i, source) => { + const prev = source[i - 1]; + if (prev != '.') return null; + + const match = code.match(/^[a-zA-Z_-]+/); + if (!match) return null; + + return { + html: `${match[0]}`, + next: match[0].length + }; + }, + // symbol code => { const match = symbols.filter(s => code[0] == s)[0]; diff --git a/src/web/app/base.styl b/src/web/app/base.styl index 1e26a9f85c..3b375c2b31 100644 --- a/src/web/app/base.styl +++ b/src/web/app/base.styl @@ -141,6 +141,13 @@ pre > code font-style italic //text-decoration underline + .method + font-style italic + color #8964c1 + + .property + color #a71d5d + mk-locker display block position fixed