backmarket-oss / github-mermaid-extension

A browser extension for Chrome, Opera & Firefox that adds Mermaid language support to Github
MIT License
239 stars 65 forks source link

Diffs on .md files trigger syntax errors #3

Closed amercier closed 5 years ago

amercier commented 5 years ago

Example

image

How to reproduce

  1. Create a PR with a .md file containing a Mermaid chart.
  2. Add a new commit that edits the chart
  3. Go to the PR, select the last commit only
  4. Click on "Display the rich diff" button

Possible solution

Handle diff situation differently. Here's the HTML:

<pre lang="mermaid" class="rich-diff-level-one" data-processed="true">
  <code>graph TD
    <ins>A[/f2/*] -&gt; B{Is the cart empty?}</ins>
    <ins>B --&gt;|Yes| C(Redirect to `/f2/cart`)</ins>
    <ins>B --&gt;|No| D(Render page)</ins>
    <del>A{Is the cart empty?}</del>
    <del>A --&gt;|Yes| B(Redirect to `/f2/cart`)</del>
    <del>A --&gt;|No| C(Render page)</del>
  </code>
</pre>