Skip to content

Commit

Permalink
Support code blocks;
Browse files Browse the repository at this point in the history
  • Loading branch information
jerone committed Dec 7, 2014
1 parent 02e0498 commit 98986e1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions js/bootstrap-markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -1164,11 +1164,19 @@
}

// transform selection and set the cursor into chunked text
if (content.substr(selected.start-1,1) == '`'
&& content.substr(selected.end,1) == '`' ) {
if (content.substr(selected.start-4,4) === '```\n'

This comment has been minimized.

Copy link
@Martii

Martii Dec 7, 2014

Contributor

Does this work with syntax highlighted lines at all? e.g. ``` javascript and so forth.

This comment has been minimized.

Copy link
@jerone

jerone Dec 7, 2014

Author Contributor

@Martii commented on 7 dec. 2014 17:35 CET:

Does this work with syntax highlighted lines at all? e.g. ````javascript` and so forth.

Probably not.
Is this supported by the marked parsers?

This comment has been minimized.

Copy link
@Martii

Martii Dec 7, 2014

Contributor

Well the preview button never shows the highlighting on OUJS but users can enter it in their code and on application it does highlight. Since I haven't examined much here on this package I am not sure how this is/can be fully implemented.

&& content.substr(selected.end,4) === '\n```') {
e.setSelection(selected.start-4, selected.end+4)
e.replaceSelection(chunk)
cursor = selected.start-4
} else if (content.substr(selected.start-1,1) === '`'
&& content.substr(selected.end,1) === '`') {
e.setSelection(selected.start-1,selected.end+1)
e.replaceSelection(chunk)
cursor = selected.start-1
} else if (content.indexOf('\n') > -1) {
e.replaceSelection('```\n'+chunk+'\n```')
cursor = selected.start+4
} else {
e.replaceSelection('`'+chunk+'`')
cursor = selected.start+1
Expand Down

0 comments on commit 98986e1

Please sign in to comment.