mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-27 11:23:08 +02:00
インラインコードを実装
This commit is contained in:
parent
8107a6e539
commit
fa70c40b33
6 changed files with 38 additions and 7 deletions
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/mention'),
|
||||
require('./elements/hashtag'),
|
||||
require('./elements/code')
|
||||
require('./elements/code'),
|
||||
require('./elements/inline-code')
|
||||
];
|
||||
|
||||
function analyze(source) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -32,6 +32,8 @@ module.exports = function(tokens, shouldBreak, shouldEscape) {
|
|||
return '<a>' + escape(token.content) + '</a>';
|
||||
case 'code':
|
||||
return '<pre><code>' + token.codeHtml + '</code></pre>';
|
||||
case 'inline-code':
|
||||
return '<code>' + escape(token.code) + '</code>';
|
||||
}
|
||||
}).join('');
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue