• Y
  • List All
  • Feedback
    • This Project
    • All Projects
Profile Account Log out
  • Favorite
  • Project
  • Recent History
Loading...
  • Log in
  • Sign up
kadrians / Testing_for_YONA star
  • Project homeH
  • CodeC
  • IssueI 1
  • Pull requestP
  • Review R
  • MilestoneM
  • BoardB 2
  • Files
  • Commit
  • Branches
Testing_for_YONAsourcepublicjavascriptscommonyobi.Markdown.js
Download as .zip file
File name
Commit message
Commit date
bin
Yona 1.16.0 Upload
02-04
lib
Yona 1.16.0 Upload
02-04
share/doc/api
Yona 1.16.0 Upload
02-04
source
Source Code Upload
02-04
README.md
Yona 1.16.0 Upload
02-04
File name
Commit message
Commit date
app
Source Code Upload
02-04
conf
Source Code Upload
02-04
docs
Source Code Upload
02-04
lib
Source Code Upload
02-04
project
Source Code Upload
02-04
public
Source Code Upload
02-04
support-script
Source Code Upload
02-04
test
Source Code Upload
02-04
.gitignore
Source Code Upload
02-04
.mailmap
Source Code Upload
02-04
.travis.yml
Source Code Upload
02-04
AUTHORS
Source Code Upload
02-04
LICENSE
Source Code Upload
02-04
NOTICE
Source Code Upload
02-04
README.md
Source Code Upload
02-04
build.sbt
Source Code Upload
02-04
dev.sh
Source Code Upload
02-04
dist.sh
Source Code Upload
02-04
is-alive-bot.sh
Source Code Upload
02-04
minify-js.sh
Source Code Upload
02-04
restart.sh
Source Code Upload
02-04
File name
Commit message
Commit date
bootstrap
Source Code Upload
02-04
help
Source Code Upload
02-04
images
Source Code Upload
02-04
javascripts
Source Code Upload
02-04
stylesheets
Source Code Upload
02-04
compiler.jar
Source Code Upload
02-04
File name
Commit message
Commit date
common
Source Code Upload
02-04
lib
Source Code Upload
02-04
service
Source Code Upload
02-04
template
Source Code Upload
02-04
yona-common.js
Source Code Upload
02-04
yona-layout.js
Source Code Upload
02-04
yona-lib.js
Source Code Upload
02-04
File name
Commit message
Commit date
yobi.Attachments.js
Source Code Upload
02-04
yobi.CodeCommentBlock.js
Source Code Upload
02-04
yobi.CodeCommentBox.js
Source Code Upload
02-04
yobi.Comment.js
Source Code Upload
02-04
yobi.CommentForm.js
Source Code Upload
02-04
yobi.Common.js
Source Code Upload
02-04
yobi.Files.js
Source Code Upload
02-04
yobi.Interval.js
Source Code Upload
02-04
yobi.LoginDialog.js
Source Code Upload
02-04
yobi.Markdown.js
Source Code Upload
02-04
yobi.Mention.js
Source Code Upload
02-04
yobi.OriginalMessage.js
Source Code Upload
02-04
yobi.Pagination.js
Source Code Upload
02-04
yobi.ShortcutKey.js
Source Code Upload
02-04
yobi.WatcherList.js
Source Code Upload
02-04
yobi.ui.Calendar.js
Source Code Upload
02-04
yobi.ui.Dialog.js
Source Code Upload
02-04
yobi.ui.Dropdown.js
Source Code Upload
02-04
yobi.ui.Mergely.js
Source Code Upload
02-04
yobi.ui.Select2.js
Source Code Upload
02-04
yobi.ui.Tabs.js
Source Code Upload
02-04
yobi.ui.Toast.js
Source Code Upload
02-04
yobi.ui.Typeahead.js
Source Code Upload
02-04
yona.CommentAttachmentsUpdate.js
Source Code Upload
02-04
yona.KeyControl.js
Source Code Upload
02-04
yona.ReceiverList.js
Source Code Upload
02-04
yona.Sha1.js
Source Code Upload
02-04
yona.SubComment.js
Source Code Upload
02-04
yona.Subtask.js
Source Code Upload
02-04
yona.Tasklist.js
Source Code Upload
02-04
yona.TitleHeadAutoCompletion.js
Source Code Upload
02-04
yona.Usermenu.js
Source Code Upload
02-04
Nell 02-04 2600fe6 Source Code Upload UNIX
Raw Open in browser Change history
/** * Yona, 21st Century Project Hosting SW * <p> * Copyright Yona & Yobi Authors & NAVER Corp. & NAVER LABS Corp. * https://yona.io **/ yobi.Markdown = (function(htOptions){ var htVar = {}; /** * initialize * @param {Hash Table} htOptions */ function _init(htOptions){ htOptions = htOptions || {}; _initVar(htOptions); _enableMarkdown(htOptions.aTarget); } /** * initialize variables * @param {Hash Table} htOptions */ function _initVar(htOptions){ htVar.sMarkdownRendererUrl = htOptions.sMarkdownRendererUrl; htVar.htMarkedOption = { "gfm" : true, "tables" : true, "pedantic" : false, "sanitize" : false, "smartLists": true, "langPrefix": '', "highlight" : function(sCode, sLang) { if(sLang) { try { return hljs.highlight(sLang.toLowerCase(), sCode).value; } catch(oException) { console.log(oException.message); } } } }; } /** * Render as Markdown document * * @require showdown.js * @require hljs.js * @param {String} sText * @return {String} */ function _renderMarkdown(sText) { return $yobi.xssClean(marked(sText, htVar.htMarkedOption)); } /** * Replace auto-link * @param welTarget * @param sContentBody * @private */ function _replaceAutoLink(welTarget, sContentBody){ /** * If this ajax request is failed, do anything. * Because, the content body not replaced is shown to user before this request. */ if(htVar.sMarkdownRendererUrl){ _render(welTarget, sContentBody); } } function _render(welTarget, sContentBody) { var source = { "body": sContentBody, "breaks": (welTarget.hasClass('readme-body') ? false : true) }; $.ajax(htVar.sMarkdownRendererUrl,{ "type": "post", "contentType":"application/json; charset=utf-8", "data": JSON.stringify(source), "success": function(data){ welTarget.html(data); $('pre code').each(function(i, block) { hljs.highlightBlock(block); }); } }); } /** * set Markdown Viewer * * @param {Wrapped Element} welTarget is not <textarea> or <input> */ function _setViewer(welTarget){ var sMarkdownText = welTarget.text(); var sContentBody = (sMarkdownText) ? _renderMarkdown(sMarkdownText) : welTarget.html(); $('.markdown-loader').remove(); welTarget.html(sContentBody).removeClass('markdown-before'); } // Deprecated. so never call this method function _postMarkdownRender(){ // Make first li font bold when multi-depth list is used var ul = $(".markdown-wrap > ul"); ul.find("> li > ul").parent().closest('ul').css('font-weight', 'bold'); //ul > ul ul.find("> li > ol").parent().closest('ul').css('font-weight', 'bold'); //ul > ol var ol = $(".markdown-wrap > ol"); ol.find("> li > ul").parent().closest('ol').css('font-weight', 'bold'); //ol > ul ol.find("> li > ol").parent().closest('ol').css('font-weight', 'bold'); //ol > ol } /** * set Markdown Editor * * @param {Wrapped Element} welTextarea */ function _setEditor(welTextarea){ var elContainer = welTextarea.parents('[data-toggle="markdown-editor"]').get(0); if(!elContainer){ return false; } $(elContainer).on("click", 'a[data-mode="preview"]', function(weEvt){ var welPreview = $(weEvt.delegateTarget).find("div.markdown-preview"); var sContentBody = welTextarea.val(); _replaceAutoLink(welPreview, sContentBody); welPreview.css({"min-height": welTextarea.height() + 'px'}); }); welTextarea.on("keydown.tabkey-event-handler", function(e) { var $this = $(this); if (e.shiftKey && e.key === 'Tab') { e.preventDefault(); _untab($this.get(0)); } else if ( e.key === 'Tab' ) { e.preventDefault(); _tab($this.get(0)); } }); } /** * enableMarkdown on target elements * * @param {String} sQuery Selector string for targets */ function _enableMarkdown(sQuery){ var waTarget = $(sQuery || "[markdown]"); // TODO: markdown=true waTarget.each(function(nIndex, elTarget){ _isEditableElement(elTarget) ? _setEditor($(elTarget)) : _setViewer($(elTarget)); }); } /** * Returns that specified element is editable * * @param {HTMLElement} elTarget * @return {Boolean} */ function _isEditableElement(elTarget){ var sTagName = elTarget.tagName.toUpperCase(); return (sTagName === "TEXTAREA" || sTagName === "INPUT" || elTarget.contentEditable == "true"); } // public interface return { "init" : _init, "enableMarkdown": _enableMarkdown, "render" : _render }; })();

          
        
    
    
Copyright Yona authors & © NAVER Corp. & NAVER LABS Supported by NAVER CLOUD PLATFORM

or
login with Google Sign in with Google
Reset password | Sign up