bbcode

Specifically convert only YouTube urls to iframe tags while converting BBCode urls to html elements

你离开我真会死。 提交于 2019-12-02 08:02:53
问题 I'm trying to convert youtube video links into iframes to embed them onto my website but I'm having a problem as I am already converting urls to anchor tags and it's conflicting with the youtube url. Here is my code: $string = 'https://www.google.com and https://www.youtube.com/watch?v=umFQckeDwEE'; $url = '~(\s|^)(https?://.+?)(\s|$)~im'; $string = preg_replace($url, '[url=$0]$0[/url]', $string); $youtubeURL = '/\s*[a-zA-Z\/\/:\.]*youtu(be.com\/watch\?v=|.be\/)([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\

Skip parsing the BBCode inside the CODE tag

时光总嘲笑我的痴心妄想 提交于 2019-12-02 07:41:46
I'm parsing the BBCode using the regex in order to replace it into the HTML. I'm stuck right now because of the [code] tags parsing. Basically, when you do [code][b]this is bb[/b] [u]code in[/u] [i]code[/i][/code] it shouldnt replace the [b] , [u] , [i] and similar tags that are INSIDE of the [code] tag. Unfortunately, using the preg_replace: $this->_text = preg_replace('/\[i](.+?)\[\/i]/i', '<em>\1</em>', $this->_text); $this->_text = preg_replace('/\[code](.+?)\[\/code]]/i', '<code>\1</code>', $this->_text); will cause replacing them all, and the code inside of the [code] tag will become

how do I make a bbcode to parse url tags into links?

空扰寡人 提交于 2019-12-02 06:31:34
How should I go about parsing a url in php? I wanna make it so it goes [url=http://www.google.com]Google[/url] Turns into: <a href="http://www.google.com">Google</a> This is the code I'm using for my other bb codes: function postparser($post){ $post = str_replace("\n",'END_OF_LINE',$post); $post = str_replace("[line]",'HORIZONTAL_LINE',$post); $post = str_replace("[bold]",'BOLD_TEXT_START',$post); $post = str_replace("[/bold]",'BOLD_TEXT_END',$post); $post = str_replace("[yt]",'YOUTUBE_START',$post); $post = str_replace("[/yt]",'YOUTUBE_END',$post); $post = sanitize($post); $post = str_replace

Javascript Not Parsing Nested Bbcode

一个人想着一个人 提交于 2019-12-02 05:18:38
I have coded a Javascript bbcode similar to the one I'm using to write this message. It also incorporates a live preview box like the one I see below. The only problem I'm facing at the moment is that some nested bbcode is not parsing. For example: [quote] [quote][/quote] [/quote] Is not parsing correctly. This is my Javascript currently. function preview() { var txt = $('#editor').val(); txt = txt.replace(/</g,'<'); txt = txt.replace(/>/g,'>'); txt = txt.replace(/[\r\n]/g,'%lb%'); var find = [ /\[quote\](.*?)\[\/quote\]/gi, /\[quote author="(.*?)" date="(.*?)"\](.*?)\[\/quote\]/gi, /\[b\](.*?

Parsing BBCode in Javascript

梦想与她 提交于 2019-12-02 04:34:00
问题 I am using this (http://coursesweb.net/javascript/convert-bbcode-html-javascript_cs) as my script for parsing BBCode. I have extended the BBCodes that it can process, however I am encountering a problem when a newline immediately follows an opening tag, e.g. [code] code.... [/code] The problem does not occur if the code is 'inline' [code]code.... [/code]` The regex being used to match what's inside these tags is (.*?) which I know does not match newlines. I have tried ([^\r\n]) to match

Specifically convert only YouTube urls to iframe tags while converting BBCode urls to html elements

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 03:27:05
I'm trying to convert youtube video links into iframes to embed them onto my website but I'm having a problem as I am already converting urls to anchor tags and it's conflicting with the youtube url. Here is my code: $string = 'https://www.google.com and https://www.youtube.com/watch?v=umFQckeDwEE'; $url = '~(\s|^)(https?://.+?)(\s|$)~im'; $string = preg_replace($url, '[url=$0]$0[/url]', $string); $youtubeURL = '/\s*[a-zA-Z\/\/:\.]*youtu(be.com\/watch\?v=|.be\/)([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i'; $string = preg_replace($youtubeURL, '<iframe width=\"420\" height=\"315\" src=

Parsing BBCode in Javascript

三世轮回 提交于 2019-12-02 01:21:54
I am using this ( http://coursesweb.net/javascript/convert-bbcode-html-javascript_cs ) as my script for parsing BBCode. I have extended the BBCodes that it can process, however I am encountering a problem when a newline immediately follows an opening tag, e.g. [code] code.... [/code] The problem does not occur if the code is 'inline' [code]code.... [/code]` The regex being used to match what's inside these tags is (.*?) which I know does not match newlines. I have tried ([^\r\n]) to match newlines but this hasn't worked either. I imagine it's a simple issue but I have little experience with

Regex for removing a specific BBCode from a string

核能气质少年 提交于 2019-12-02 01:03:40
问题 I'm trying to write a simple method for removing specific BBCodes from an input string. For example, where I have an input of: string input = "[b]Hello World![/b]"; I would want to be able to do: Remove(input, "b"); And get an output of: "Hello World!" Regex really isn't my strong suit. I've managed to piece together the following from google: public static string Remove(string input, string code) { string pattern = string.Format(@"\[{0}\].*?\[\/{1}\]", code, code); return Regex.Replace(input

Remove BBCode tags and their content in PHP [duplicate]

你。 提交于 2019-12-01 19:11:15
Possible Duplicates: Recursive BBCode Parsing Strip BBCode via RegEx What is the best way to remove all BBCode tags of a string and their content in PHP? <?php function stripBBCode($text_to_search) { $pattern = '|[[\/\!]*?[^\[\]]*?]|si'; $replace = ''; return preg_replace($pattern, $replace, $text_to_search); } echo stripBBCode($text_to_search); ?> demo 来源: https://stackoverflow.com/questions/6777257/remove-bbcode-tags-and-their-content-in-php

How change the CKEditor text using jQuery?

痴心易碎 提交于 2019-12-01 18:01:35
I have a textarea with CKEditor (bbCode Plugin). <textarea id="editor1" name="conteudo" class="form-control" rows="3" required></textarea> This is my CKEditor instance: $( document ).ready( function() { $( 'textarea#editor1' ).ckeditor(); } ); I'm making a JSON request that takes a value and I want this value to be modified in this textarea , I tried with jQuery but not worked ! Below is my attempt: video_id = "lLi1Lx2xTKI"; $.getJSON('http://gdata.youtube.com/feeds/api/videos/'+video_id+'?v=2&alt=jsonc',function(data,status,xhr){ description = data.data.description; // Attempt here $("