mirror of
https://github.com/kokonect-link/cherrypick
synced 2024-11-01 15:45:58 +09:00
インラインコードを実装
This commit is contained in:
parent
8107a6e539
commit
fa70c40b33
14
src/common/text/elements/inline-code.js
Normal file
14
src/common/text/elements/inline-code.js
Normal 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()
|
||||||
|
};
|
||||||
|
};
|
@ -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) {
|
||||||
|
@ -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
|
||||||
|
@ -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('');
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user