Embed php js html code in tinymce, posible?

I searched a lot, but did not find anithing ...

(I want some -i editor to know that this is hard to do - like the one I use now, where I can share my code on my blog) (My own CMS)

So,

I guess someone went through this earlier, can I embed code using tinyMce ?

any conclusion?

Thank you very much

PD: I saw that stackoverflow uses a fork from WMD , which is not online, but on github, who has a usage example? (there are only .js files there)

PD2: thanks a lot, again!

EDIT

Ok, after some answers hit prettyprint -> here

which needs to be loaded only on $ (document) .ready () And there will be a prefix (lol) of any of them:

<pre class="prettyprint"> code here </pre> 

So, I'm trying to add this format to tinimce with:

 style_formats : [ {title : 'Bold text', inline : 'b'}, {title : 'Blue text', inline : 'span', styles : {color : '#006'}}, {title : 'Blue header', block : 'h1', styles : {color : '#006'}}, --> {title : 'Codigo fuente', inline : 'pre', classes : 'prettyprint'}, {title : 'Example 2', inline : 'span', classes : 'example2'}, {title : 'Table styles'}, {title : 'Table row 1', selector : 'tr', classes : 'tablerow1'} ], 

But if I use it, then it turns into <p> on $ _POST, why?

Change two

works: {title : 'Codigo fuente', block : 'pre', classes : 'prettyprint'},

Problem i get

 <pre ..>line 1</pre> <pre ..>line 2</pre> 

..

and I would like to apply:

 <pre..> line1 line2 </pre> 

how can i solve this? if I change block to inline , just a style that he didn't even apply :?

Gracias!

+2
source share
2 answers

EDIT: sorry for the incorrect placement, still new. As far as I know, you can skip the code directly in tinymce and it will not interpret it. When he stores it, he should add all the necessary escape sequences, so when it appears on your blog or something that will look like lek code. What he does not will automatically format it in a readable form and add coloring and the like. I suppose there must be a plugin or some alternative for this ... bbiam: P

EDIT2: this -> http://www.maclovin.de/syntaxhl-editor/ seems like a good option.

download → https://github.com/RichGuk/syntaxhl

EDIT3: it can also be nice → http://code.google.com/p/google-code-prettify/ Makes the code nice and beautiful for everyone, hence the name.

ORIGINAL: I'm a little confused, do you want the code you put in the tiny MCE to be active code, or do you want it to be code samples?

 <A href="www.google.com">google</a> 

or http://www.google.com

+1
source

Perhaps you can use this: SyntaxHighlighter or some other syntax shortcut ...

And use the tinymce forum / site because your question is related to tinymce. Read the manual. Look for plugins and their implementation.

Hint: Search the Developer Resources first or use Google ... Google Results

+1
source

Source: https://habr.com/ru/post/1346233/


All Articles