Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Markdown that doesn’t strip data attributes

  • This topic is empty.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #39770
    Chris Coyier
    Keymaster

    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?

    #109715
    Mottie
    Member

    Sorry Chris I stink at php, but have you considered asking this question on StackOverflow?

    #110167
    Mobilpadde
    Member

    So 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)

    #110168
    TabAtkins
    Member

    Do you want to allow them to embed arbitrary HTML, or still have *some* limitations, but allow data-* attributes?

    #110169
    Chris Coyier
    Keymaster

    @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.

    #110170

    The 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.

    #110171

    Here is the correct version http://pastebin.com/6fZkxNC6

    #110172
    Chris Coyier
    Keymaster

    @InerciaCreativa – Thanks for digging in! That appears twice in the file and I replaced them both but no dice.

Viewing 8 posts - 1 through 8 (of 8 total)
  • The forum ‘Back End’ is closed to new topics and replies.