1
0
mirror of https://github.com/hotomoe/hotomoe synced 2024-12-02 08:48:11 +09:00

インラインコードを実装

This commit is contained in:
syuilo 2017-02-11 23:41:57 +09:00
parent 8107a6e539
commit fa70c40b33
6 changed files with 38 additions and 7 deletions

View File

@ -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()
};
};

View File

@ -7,7 +7,8 @@ const elements = [
require('./elements/url'), require('./elements/url'),
require('./elements/mention'), require('./elements/mention'),
require('./elements/hashtag'), require('./elements/hashtag'),
require('./elements/code') require('./elements/code'),
require('./elements/inline-code')
]; ];
function analyze(source) { function analyze(source) {

View File

@ -107,11 +107,15 @@ a
* *
cursor pointer cursor pointer
code
font-family Consolas, 'Courier New', Courier, Monaco, monospace
pre pre
overflow auto display block
> code > code
font-family Consolas, 'Courier New', Courier, Monaco, monospace display block
overflow auto
tab-size 2 tab-size 2
.comment .comment

View File

@ -32,6 +32,8 @@ module.exports = function(tokens, shouldBreak, shouldEscape) {
return '<a>' + escape(token.content) + '</a>'; return '<a>' + escape(token.content) + '</a>';
case 'code': case 'code':
return '<pre><code>' + token.codeHtml + '</code></pre>'; return '<pre><code>' + token.codeHtml + '</code></pre>';
case 'inline-code':
return '<code>' + escape(token.code) + '</code>';
} }
}).join(''); }).join('');

View File

@ -232,13 +232,18 @@
font-style oblique font-style oblique
color #a0bf46 color #a0bf46
pre code
padding 16px padding 4px 8px
margin 0 0.5em
font-size 80% font-size 80%
color #525252 color #525252
background #f8f8f8 background #f8f8f8
border-radius 2px border-radius 2px
pre > code
padding 16px
margin 0
[data-is-me]:after [data-is-me]:after
content "you" content "you"
padding 0 4px padding 0 4px

View File

@ -212,13 +212,18 @@
font-style oblique font-style oblique
color #a0bf46 color #a0bf46
pre code
padding 16px padding 4px 8px
margin 0 0.5em
font-size 80% font-size 80%
color #525252 color #525252
background #f8f8f8 background #f8f8f8
border-radius 2px border-radius 2px
pre > code
padding 16px
margin 0
[data-is-me]:after [data-is-me]:after
content "you" content "you"
padding 0 4px padding 0 4px