Medium.js icon indicating copy to clipboard operation
Medium.js copied to clipboard

Semantic's not correct

Open lh84 opened this issue 10 years ago • 4 comments
trafficstars

Hey there, just looked around and found medium.js. On the example pages it says all the html behind the scenes are always correct. that's not true. e.g. in the example "Rich with Insert Html". If I wrote some text and pressed the button "Insert" afterwords a few time, it produces invalid html.

html result:

<div id="rich_with_insert_html" class="article demo Medium Medium-rich" contenteditable="true">sad asdasd
<p style="background-color: yellow;">   Happy day!  I can work with buttons too!
  <p style="background-color: yellow;"> Happy day!  I can work with buttons too!
    <p style="background-color: yellow;">   Happy day!  I can work with buttons too!
      <p style="background-color: yellow;"> Happy day!  I can work with buttons too!
      </p>
    </p>
   </p>
</p>
</div>

lh84 avatar Mar 18 '15 08:03 lh84

Seems it's because of tags: null in the Medium instance config, which means no (or less?) control over tags inserted/created.

bonfish avatar Apr 05 '15 11:04 bonfish

Shift + Enter in the "Rich" example (which otherwise seems the closest to my desired results of all the examples) causes un-marked up text() nodes, unwrapped with p tags.

This is possibly up for debate but I'd say a paragraph of text not marked up with a paragraph tag is non-semantic. Indeed many of the examples generate divs and i'm struggling to think of a use for Medium where you'd ever want that, but still, you don't want to be too prescriptive.

Either way, from an styling perspective since p usually gets specific margin/padding in most designers' typesetting systems, the non-p nodes would be problematic to style.

davecranwell avatar Apr 09 '15 10:04 davecranwell

@bonfish was right. What you are seeing is a special use case where we are using tags: null turns off clean up. I think for the docs I should probably correct this so it isn't so confusing. Thanks for the find!

robertleeplummerjr avatar Apr 09 '15 21:04 robertleeplummerjr

I noticed that when I insert html that is block into a paragraph, it does in fact break the semantics, so that will need to be handled. A link on how it has been solved: http://jsbin.com/efegiz/2/edit?html,js,output

robertleeplummerjr avatar Apr 14 '15 20:04 robertleeplummerjr