diff --git a/src/common/text/elements/inline-code.js b/src/common/text/elements/inline-code.js new file mode 100644 index 0000000000..d117c53a15 --- /dev/null +++ b/src/common/text/elements/inline-code.js @@ -0,0 +1,14 @@ +/** + * Code (inline) + */ + +module.exports = text => { + const match = text.match(/^`(.+?)`/); + if (!match) return null; + const code = match[0]; + return { + type: 'inline-code', + content: code, + code: code.substr(1, code.length - 2).trim() + }; +}; diff --git a/src/common/text/index.js b/src/common/text/index.js index d0ef8674b0..9da3a26b91 100644 --- a/src/common/text/index.js +++ b/src/common/text/index.js @@ -7,7 +7,8 @@ const elements = [ require('./elements/url'), require('./elements/mention'), require('./elements/hashtag'), - require('./elements/code') + require('./elements/code'), + require('./elements/inline-code') ]; function analyze(source) { diff --git a/src/web/app/base.styl b/src/web/app/base.styl index 0e5eeba971..334ef91f76 100644 --- a/src/web/app/base.styl +++ b/src/web/app/base.styl @@ -107,11 +107,15 @@ a * cursor pointer +code + font-family Consolas, 'Courier New', Courier, Monaco, monospace + pre - overflow auto + display block > code - font-family Consolas, 'Courier New', Courier, Monaco, monospace + display block + overflow auto tab-size 2 .comment diff --git a/src/web/app/common/scripts/text-compiler.js b/src/web/app/common/scripts/text-compiler.js index 25f36382fb..f47ce0f3c3 100644 --- a/src/web/app/common/scripts/text-compiler.js +++ b/src/web/app/common/scripts/text-compiler.js @@ -32,6 +32,8 @@ module.exports = function(tokens, shouldBreak, shouldEscape) { return '' + escape(token.content) + ''; case 'code': return '
' + token.codeHtml + '
';
+ case 'inline-code':
+ return '' + escape(token.code) + '
';
}
}).join('');
diff --git a/src/web/app/desktop/tags/timeline-post.tag b/src/web/app/desktop/tags/timeline-post.tag
index 4b9f4eec0c..1f204254d0 100644
--- a/src/web/app/desktop/tags/timeline-post.tag
+++ b/src/web/app/desktop/tags/timeline-post.tag
@@ -232,13 +232,18 @@
font-style oblique
color #a0bf46
- pre
- padding 16px
+ code
+ padding 4px 8px
+ margin 0 0.5em
font-size 80%
color #525252
background #f8f8f8
border-radius 2px
+ pre > code
+ padding 16px
+ margin 0
+
[data-is-me]:after
content "you"
padding 0 4px
diff --git a/src/web/app/mobile/tags/timeline-post.tag b/src/web/app/mobile/tags/timeline-post.tag
index db71720574..a5a5a64f62 100644
--- a/src/web/app/mobile/tags/timeline-post.tag
+++ b/src/web/app/mobile/tags/timeline-post.tag
@@ -212,13 +212,18 @@
font-style oblique
color #a0bf46
- pre
- padding 16px
+ code
+ padding 4px 8px
+ margin 0 0.5em
font-size 80%
color #525252
background #f8f8f8
border-radius 2px
+ pre > code
+ padding 16px
+ margin 0
+
[data-is-me]:after
content "you"
padding 0 4px