toolness / p5.js-widget

A reusable widget for embedding editable p5 sketches in web pages.
https://toolness.github.io/p5.js-widget/
GNU Lesser General Public License v2.1
161 stars 44 forks source link

unwanted html in the code/ wordpress #56

Closed tchoi8 closed 8 years ago

tchoi8 commented 8 years ago

This widget has been incredibly helpful for the signing coders workshop. Much thanks to Atul. One problem I've been having is specific to use in wordpress blog. I think this might be wordpress-specific issue, with a reasonable workaround. However, I think it's worth pointing out for future use.

My use cas scenario has been: write some code in the p5 desktop editor and paste it in the wordpress Text mode.

image

and the

and

shows up in side of the widget. image

I've been able to manage so far by manually deleting it, but it's hard to find out where they are. Not having full control over the code results in some awkward code structures. This is related to the previous issue.

toolness commented 8 years ago

Oh! I just found out this can be avoided by using the <pre> tag in Wordpress. So for example, the following works on my Wordpress installation:

<pre>
<script type="text/p5">
var result;

function preload() {
  results = loadStrings('assets/beforeSleep.txt');
}

function setup() {
  background(200);
  createCanvas(500, 500);
  txt = join(result, '\n');
}

/* And so on... */
</script>
</pre>

Because the <script> content is wrapped in a <pre>, Wordpress won't auto-format any of it.

There's some ways I can address this:

Thoughts?

tchoi8 commented 8 years ago

Superb. Thanks so much. pre works for the sketches I had. I think first documenting and suggesting the workaround, or have FAQ section with it, would be a first good step. Also, it will be great to note the possible behaviors and edge case scenarios.