Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace showdown with highlight + markdown #4948

Merged
merged 6 commits into from
Aug 7, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ app/assets/v2/js/event_ethdenver2019/blockies.js
app/assets/v2/js/lib/ipfs-api.js
app/assets/v2/js/lib/jquery*.js
app/assets/v2/js/lib/jsrender.js
app/assets/v2/js/lib/showdown.js
app/assets/v2/js/lib/markdown-it.js
app/assets/v2/js/lib/highlight.js
app/assets/v2/js/lib/tooltip.js
app/assets/v2/js/lib/tweenlite.js
app/assets/v2/js/abi.js
Expand Down
1 change: 1 addition & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ app/assets/v2/css/jquery.select2.min.css
app/assets/v2/css/bootstrap.min.css
app/assets/v2/js/lib/tweenlite.js
app/assets/v2/js/abi.js
app/assets/v2/css/highlight_github.css
10 changes: 3 additions & 7 deletions app/assets/v2/css/bounty.css
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ body {
color: #000000;
}

#issue_description pre, code {
/* #issue_description pre, code {
padding: 1em 0;
}
} */

#bounty-info-row {
margin-left: 1px;
Expand Down Expand Up @@ -529,11 +529,6 @@ a.btn {
color: #F5A623;
}

.code-snippet {
background-color: #F2F6F9;
padding: 1rem;
}

#funder_notif_info .bounty-notification {
border: orange 1px solid;
border-radius: 3px;
Expand Down Expand Up @@ -737,6 +732,7 @@ a.btn {
.modal .magnify {
width: auto;
max-width: 100%;
overflow-y: scroll;
}

.bg-container {
Expand Down
1 change: 1 addition & 0 deletions app/assets/v2/css/highlight_github.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions app/assets/v2/js/lib/highlight.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/assets/v2/js/lib/markdown-it.js

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions app/assets/v2/js/lib/showdown.js

This file was deleted.

32 changes: 22 additions & 10 deletions app/assets/v2/js/pages/bounty_details.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,25 @@ var callbacks = {
return [ 'status', ui_status ];
},
'issue_description': function(key, val, result) {
var converter = new showdown.Converter({
simplifiedAutoLink: true

const _markdown = new markdownit({
linkify: true,
highlight: function(str, lang) {
if (lang && hljs.getLanguage(lang)) {
try {
return '<pre class="hljs"><code>' +
hljs.highlight(lang, str, true).value +
'</code></pre>';
} catch (__) {}
}
return '<pre class="hljs"><code>' + sanitize(md.utils.escapeHtml(str)) + '</code></pre>';
}
});

ui_body = sanitize(converter.makeHtml(val));
_markdown.renderer.rules.table_open = function() {
return '<table class="table">';
};
ui_body = sanitize(_markdown.render(val));
return [ 'issue_description', ui_body ];
},
'bounty_owner_address': address_ize,
Expand Down Expand Up @@ -950,11 +964,10 @@ var build_detail_page = function(result) {
_result = callbacks[key](key, val, result);
val = _result[1];
}
var _entry = {
'head': head,
'key': key,
'val': val
};

hljs.initHighlighting.called = false;
hljs.initHighlighting();

var id = '#' + key;

if ($(id).length) {
Expand All @@ -976,12 +989,11 @@ var build_detail_page = function(result) {
'</div>' +
'<div class="col-12 pt-2 pb-2"><img class="magnify" src="' + $(this).attr('src') + '"/></div></div></div>');

var modal = $(content).appendTo('body').modal({
$(content).appendTo('body').modal({
modalClass: 'modal magnify'
});
});

$('#bounty_details #issue_description code').parent().addClass('code-snippet');
appendGithubSyncButton(result);
};

Expand Down
11 changes: 6 additions & 5 deletions app/dashboard/templates/bounty/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<link rel="stylesheet" href="{% static "v2/css/bounty.css" %}">
<link rel="stylesheet" href="{% static "v2/css/user_popover.css" %}">
<link rel="stylesheet" href="{% static "v2/css/tag.css" %}">
<link rel="stylesheet" href="{% static "v2/css/highlight_github.css" %}">
</head>

<body class="interior {{active}} g-font-muli">
Expand Down Expand Up @@ -440,19 +441,19 @@ <h5 class="bounty-heading">{% trans "Funder" %}</h5>
{% endif %}
</script>

<!-- jQuery -->
<script src="{% static "v2/js/lib/showdown.js" %}"></script>
<script src="{% static "v2/js/lib/highlight.js" %}"></script>
<script src="{% static "v2/js/lib/markdown-it.js" %}"></script>

<script src="{% static "v2/js/abi.js" %}"></script>
<script src="/dynamic/js/tokens_dynamic.js"></script>
<script src="{% static "v2/js/tokens.js" %}"></script>
<script src="{% static "v2/js/amounts.js" %}"></script>
<script src="{% static "v2/js/clipboard.js" %}"></script>>
<script src="{% static "v2/js/clipboard.js" %}"></script>
<script>
$('[data-toggle="popover"]').popover()

$("body").on("mouseover", "[data-username] img", function(e) {
openContributorPopOver($(this).parent().data("username"), $(this));
});
});
</script>
<script src="{% static "v2/js/pages/bounty_funder_payout_reminder.js" %}"></script>
<script src="{% static "v2/js/pages/bounty_share.js" %}"></script>
Expand Down