- This topic is empty.
-
AuthorPosts
-
September 10, 2012 at 2:14 pm #39770Chris CoyierKeymaster
My goal on the forums is for you to be able to embed CodePens if you want.
All that you need to do is:
But… Vanilla forums strips the data attributes which is what makes this work. It leaves classes and ID’s alone, so there is hope.
This is the Markdown file that it uses to process the text : https://gist.github.com/3692655
Any ideas?
September 10, 2012 at 4:38 pm #109715MottieMemberSorry Chris I stink at php, but have you considered asking this question on StackOverflow?
September 16, 2012 at 11:30 am #110167MobilpaddeMemberSo it just return something like this?
<pre><code></code></pre>
I think it have something to do with these
function doCodeBlocks($text) {
$text = preg_replace_callback('{
(?:nn|An?)
( # $1 = the code block -- one or more lines, starting with a space/tab
(?>
[ ]{'.$this->tab_width.'} # Lines must start with a tab or a tab-width of spaces
.*n+
)+
)
((?=^[ ]{0,'.$this->tab_width.'}S)|Z) # Lookahead for non-space at line-start, or end of doc
}xm',
array(&$this, '_doCodeBlocks_callback'), $text);
return $text;
}function _doCodeBlocks_callback($matches) {
$codeblock = $matches[1];
$codeblock = $this->outdent($codeblock);
$codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES);
# trim leading newlines and trailing newlines
$codeblock = preg_replace('/An+|n+z/', '', $codeblock);
$codeblock = "<pre><code>$codeblockn</code></pre>";
return "nn".$this->hashBlock($codeblock)."nn";
}
Anyway, I agree with @Mottie, ask [StackOverflow](http://stackoverflow.com/questions/tagged/php)
September 16, 2012 at 11:35 am #110168TabAtkinsMemberDo you want to allow them to embed arbitrary HTML, or still have *some* limitations, but allow data-* attributes?
September 16, 2012 at 11:39 am #110169Chris CoyierKeymaster@TabAtkins I guess either way would be fine.
I have no real problem with arbitrary HTML being posted – with the exception of security problems like script tags and such, but this forum software like strips that stuff.
@Mottie @Mobilpadde I will ask there, thanks.September 16, 2012 at 12:17 pm #110170InerciaCreativaMemberThe problem lies in regexp used to parse the HTML blocks: search for
(?=[s"'/a-zA-Z0-9])
and replace with(?=[s"'/a-zA-Z0-9-])
and it should work.September 16, 2012 at 12:21 pm #110171InerciaCreativaMemberHere is the correct version http://pastebin.com/6fZkxNC6
September 16, 2012 at 12:22 pm #110172Chris CoyierKeymaster@InerciaCreativa – Thanks for digging in! That appears twice in the file and I replaced them both but no dice.
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.