fix codacy issue

pull/6158/head
Maki Nishifuji 9 years ago
parent 8c2613b23e
commit 9e16354310
  1. 10
      packages/rocketchat-markdown/markdown.js
  2. 5
      packages/rocketchat-markdown/parser/original/code.js
  3. 18
      packages/rocketchat-markdown/settings.js
  4. 2
      packages/rocketchat-markdown/tests/jasmine/client/unit/markdown.spec.coffee
  5. 4
      packages/rocketchat-message-snippet/client/page/snippetPage.js
  6. 12
      packages/rocketchat-theme/client/imports/base.less
  7. 2
      packages/rocketchat-ui-message/message/message.coffee
  8. 8
      packages/rocketchat-ui-message/message/messageBox.coffee

@ -11,10 +11,10 @@ import { original } from './parser/original/original.js';
const parsers = {
original,
marked,
marked
};
const Markdown = (message) => {
const markdown = (message) => {
const parser = RocketChat.settings.get('Markdown_Parser');
if (typeof parsers[parser] === 'function') {
return parsers[parser](message);
@ -22,11 +22,11 @@ const Markdown = (message) => {
return parsers['original'](message);
};
RocketChat.Markdown = Markdown;
RocketChat.callbacks.add('renderMessage', Markdown, RocketChat.callbacks.priority.HIGH, 'markdown');
RocketChat.markdown = markdown;
RocketChat.callbacks.add('renderMessage', markdown, RocketChat.callbacks.priority.HIGH, 'markdown');
if (Meteor.isClient) {
Blaze.registerHelper('RocketChatMarkdown', (text) => {
return RocketChat.Markdown(text);
return RocketChat.markdown(text);
});
}

@ -27,8 +27,8 @@ const blockCode = (message) => {
}
if (count % 2 > 0) {
message.html = message.html + "\n```";
message.msg = message.msg + "\n```";
message.html = message.html + '\n```';
message.msg = message.msg + '\n```';
}
let msgParts = message.html.replace(/<br>/gm, '\n').split(/^\s*(```(?:[a-zA-Z]+)?(?:(?:.|\n)*?)```)(?:\n)?$/gm);
@ -48,6 +48,7 @@ const blockCode = (message) => {
code = _.unescapeHTML(codeMatch[2]);
}
let result = null;
lang = _.trim(lang);
if (hljs.listLanguages().includes(lang)) {
result = hljs.highlight(lang, code);

@ -13,7 +13,7 @@ Meteor.startup(function() {
}],
group: 'Message',
section: 'Markdown',
"public": true
'public': true
});
const enableQueryOriginal = {_id: 'Markdown_Parser', value: 'original'};
@ -21,14 +21,14 @@ Meteor.startup(function() {
type: 'boolean',
group: 'Message',
section: 'Markdown',
"public": true,
'public': true,
enableQuery: enableQueryOriginal
});
RocketChat.settings.add('Markdown_SupportSchemesForLink', 'http,https', {
type: 'string',
group: 'Message',
section: 'Markdown',
"public": true,
'public': true,
i18nDescription: 'Markdown_SupportSchemesForLink_Description',
enableQuery: enableQueryOriginal
});
@ -38,28 +38,28 @@ Meteor.startup(function() {
type: 'boolean',
group: 'Message',
section: 'Markdown',
"public": true,
'public': true,
enableQuery: enableQueryMarked
});
RocketChat.settings.add('Markdown_Marked_Tables', true, {
type: 'boolean',
group: 'Message',
section: 'Markdown',
"public": true,
'public': true,
enableQuery: enableQueryMarked
});
RocketChat.settings.add('Markdown_Marked_Breaks', true, {
type: 'boolean',
group: 'Message',
section: 'Markdown',
"public": true,
'public': true,
enableQuery: enableQueryMarked
});
RocketChat.settings.add('Markdown_Marked_Pedantic', false, {
type: 'boolean',
group: 'Message',
section: 'Markdown',
"public": true,
'public': true,
enableQuery: [{
_id: 'Markdown_Parser',
value: 'marked'
@ -72,14 +72,14 @@ Meteor.startup(function() {
type: 'boolean',
group: 'Message',
section: 'Markdown',
"public": true,
'public': true,
enableQuery: enableQueryMarked
});
RocketChat.settings.add('Markdown_Marked_Smartypants', true, {
type: 'boolean',
group: 'Message',
section: 'Markdown',
"public": true,
'public': true,
enableQuery: enableQueryMarked
});
});

@ -1,4 +1,4 @@
describe 'rocketchat:markdown Client', ->
it 'should exist', ->
expect(RocketChat.Markdown).toBeDefined()
expect(RocketChat.markdown).toBeDefined()

@ -11,8 +11,8 @@ Template.snippetPage.helpers({
return null;
}
message.html = message.msg;
const markdownCode = new RocketChat.MarkdownCode(message);
return markdownCode.tokens[0].text;
const markdown = RocketChat.markdown(message);
return markdown.tokens[0].text;
},
date() {
const snippet = SnippetedMessages.findOne({ _id: FlowRouter.getParam('snippetId') });

@ -2952,7 +2952,8 @@ label.required::after {
line-height: 1em;
}
ul, ol {
ul,
ol {
padding: 0 0 0 24px;
}
@ -2974,16 +2975,17 @@ label.required::after {
overflow: auto;
tr {
background-color: #fff;
border-top: 1px solid #ccc;
background-color: #ffffff;
border-top: 1px solid #cccccc;
th {
font-weight: 600;
}
th, td {
th,
td {
padding: 6px 13px;
border: 1px solid #ddd;
border: 1px solid #dddddd;
}
}
}

@ -177,7 +177,7 @@ Template.message.onCreated ->
msg = renderMessageBody msg
if isSystemMessage
return RocketChat.Markdown msg
return RocketChat.markdown msg
else
return msg

@ -18,17 +18,17 @@ Template.messageBox.helpers
else
return roomData.name
showMarkdown: ->
return RocketChat.Markdown
return RocketChat.markdown
markdownParserOriginal: ->
return RocketChat.Markdown && 'original' == RocketChat.settings.get('Markdown_Parser')
return RocketChat.markdown && 'original' == RocketChat.settings.get('Markdown_Parser')
markdownParserMarked: ->
return RocketChat.Markdown && 'marked' == RocketChat.settings.get('Markdown_Parser')
return RocketChat.markdown && 'marked' == RocketChat.settings.get('Markdown_Parser')
showKatex: ->
return RocketChat.katex
katexSyntax: ->
return katexSyntax()
showFormattingTips: ->
return RocketChat.settings.get('Message_ShowFormattingTips') and (RocketChat.Markdown or RocketChat.MarkdownCode or katexSyntax())
return RocketChat.settings.get('Message_ShowFormattingTips') and (RocketChat.markdown or katexSyntax())
canJoin: ->
return RocketChat.roomTypes.verifyShowJoinLink @_id
joinCodeRequired: ->

Loading…
Cancel
Save