Skip to content

Commit

Permalink
#847 fix for case texts with multiple br tags, explanation in usage d…
Browse files Browse the repository at this point in the history
…oc on how to avoid labels out of bounds.
  • Loading branch information
knsv committed Jul 16, 2019
1 parent 976d16b commit 8e27318
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
8 changes: 7 additions & 1 deletion dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Mermaid Quick Test Page</title>
<link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgo=">
<style>
div.mermaid {
/* font-family: 'trebuchet ms', verdana, arial; */
font-family: 'Courier New', Courier, monospace !important;
}
</style>
</head>
<body>
<div class="mermaid">
Expand Down Expand Up @@ -127,7 +133,7 @@
<div class="mermaid">
graph TD
A[Christmas] -->|Get money| B(Go shopping)
B --> C{Let me thinksssss<br/>ssssssssssssssssssssss<br/>sssssssssssssssssssssssssss}
B --> C{Let me thinksssssx<br/>sssssssssssssssssssuuu<br />tttsssssssssssssssssssssss}
C -->|One| D[Laptop]
C -->|Two| E[iPhone]
C -->|Three| F[Car]
Expand Down
10 changes: 8 additions & 2 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,14 @@ $(document).ready(function() {
});
```

Not doing so will most likely result in mermaid rendering graphs that have labels out of bounds. The default integration
in mermaid uses the window.load event to start rendering.
Not doing so will most likely result in mermaid rendering graphs that have labels out of bounds. The default integration in mermaid uses the window.load event to start rendering. Also note that when rendering the width of lebale sare calucated of what width it bening meassured at the time.

If your page has other fonts in its body those might be used instead of the mermaid font. Specifying the font in your styling is a workaround for this.
```
div.mermaid {
font-family: 'trebuchet ms', verdana, arial;
}
```

### Calling `mermaid.init`

Expand Down
2 changes: 1 addition & 1 deletion src/diagrams/flowchart/flowDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const sanitize = text => {
let txt = text
if (config.securityLevel === 'strict') {
txt = txt.replace(/<br>/g, '#br#')
txt = txt.replace(/<br\S*\/>/g, '#br#')
txt = txt.replace(/<br\S*?\/>/g, '#br#')
txt = txt.replace(/</g, '&lt;').replace(/>/g, '&gt;')
txt = txt.replace(/#br#/g, '<br/>')
}
Expand Down

0 comments on commit 8e27318

Please sign in to comment.