最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - tinymcebundle return markdown - Stack Overflow

programmeradmin0浏览0评论

I would like to return a Markdown instead of HTML.

(My project it's write with Symfony 2 with stfalcon/TinymceBundle)

I find this, but it doesn't work... (I don't see any change with or without) (/)

I use a dispatcher for the JavaScript. This is my file :

;(function(dispatcher, window) {
    dispatcher.addScript('global', function() {
        tinymce.init({
            selector: "textarea",  // change this value according to your HTML
            plugin: 'textpattern',
            textpattern_patterns: [
                {start: '*', end: '*', format: 'italic'},
                {start: '**', end: '**', format: 'bold'},
                {start: '#', format: 'h1'},
                {start: '##', format: 'h2'},
                {start: '###', format: 'h3'}
            ]
        });
    });
})($dispatcher, window);

I think to call :

{{ tinymce_init() }}

On my twig file.

Now I lost... beacause the

var_dump($form->getData());

returns me the HTML code, but I would like the Markdown code...

It's possible ? If yes how ?

Thank you.

I would like to return a Markdown instead of HTML.

(My project it's write with Symfony 2 with stfalcon/TinymceBundle)

I find this, but it doesn't work... (I don't see any change with or without) (https://www.tinymce./docs/plugins/textpattern/)

I use a dispatcher for the JavaScript. This is my file :

;(function(dispatcher, window) {
    dispatcher.addScript('global', function() {
        tinymce.init({
            selector: "textarea",  // change this value according to your HTML
            plugin: 'textpattern',
            textpattern_patterns: [
                {start: '*', end: '*', format: 'italic'},
                {start: '**', end: '**', format: 'bold'},
                {start: '#', format: 'h1'},
                {start: '##', format: 'h2'},
                {start: '###', format: 'h3'}
            ]
        });
    });
})($dispatcher, window);

I think to call :

{{ tinymce_init() }}

On my twig file.

Now I lost... beacause the

var_dump($form->getData());

returns me the HTML code, but I would like the Markdown code...

It's possible ? If yes how ?

Thank you.

Share Improve this question asked Jan 31, 2017 at 17:39 KisaWKisaW 531 silver badge3 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

TinyMCE is an HTML editor so when you ask for data from TinyMCE you will get HTML.

The textpattern plugin allows someone to type in Markdown and the editor will convert it to HTML on the fly.

For example if you type in

# heading

...you will get

<h1>heading</h1>

...in the editor after you press the enter key. Once the conversion is done there is no more Markdown.

If you need Markdown as the end result you need to find a tool that converts HTML into Markdown and you can perform that conversion once the form is posted.

Note: Markdown is more limited than HTML in its constructs so if you want this to work well you will likely need to limit what HTML tags you allow in the editor and you may need to limit what toolbar buttons and menu options you make available to your users.

发布评论

评论列表(0)

  1. 暂无评论