mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-07-08 19:00:02 +02:00
Markdown rendering overhaul (#186)
* Markdown rendering overhaul Cleaned up and squashed commits into single one. Signed-off-by: Andrew Boyarshin <boyarshinand@gmail.com> * Fix markdown API, add markdown module and API tests, improve code coverage Signed-off-by: Andrew Boyarshin <boyarshinand@gmail.com>
This commit is contained in:
parent
5cc275b1de
commit
dc8248f8a4
13 changed files with 1374 additions and 187 deletions
|
@ -613,6 +613,7 @@ function initWikiForm() {
|
|||
function (data) {
|
||||
preview.innerHTML = '<div class="markdown">' + data + '</div>';
|
||||
emojify.run($('.editor-preview')[0]);
|
||||
$('.editor-preview').autolink();
|
||||
}
|
||||
);
|
||||
}, 0);
|
||||
|
@ -1388,6 +1389,7 @@ $(document).ready(function () {
|
|||
node.append('<a class="anchor" href="#' + name + '"><span class="octicon octicon-link"></span></a>');
|
||||
});
|
||||
});
|
||||
$('.markdown').autolink();
|
||||
|
||||
buttonsClickOnEnter();
|
||||
searchUsers();
|
||||
|
|
12
public/js/libs/autolink.js
Normal file
12
public/js/libs/autolink.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
jQuery.fn.autolink = function() {
|
||||
return this.find('*').contents().filter(function () { return this.nodeType === 3; }).each(function() {
|
||||
var re = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-]*)?\??(?:[\-\+:=&;%@\.\w]*)#?(?:[\.\!\/\\\w]*))?)/g;
|
||||
$(this).each(function() {
|
||||
$(this).replaceWith(
|
||||
$("<span />").html(
|
||||
this.nodeValue.replace(re, "<a href='$1'>$1</a>")
|
||||
)
|
||||
);
|
||||
});
|
||||
});
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue