mirror of
				https://github.com/mermaid-js/mermaid.git
				synced 2025-10-31 10:54:15 +01:00 
			
		
		
		
	fix: remove right padding when a label contains HTML entities
Decode the HTML entities from the label text before adding them to the HTML this prevents a miss-calculation of the label text length
This commit is contained in:
		| @@ -509,4 +509,16 @@ stateDiagram-v2 | ||||
|       expect(svg).to.not.have.attr('style'); | ||||
|     }); | ||||
|   }); | ||||
|  | ||||
|   it('v2 should render a state diagram and set the correct length of the labels', () => { | ||||
|     imgSnapshotTest( | ||||
|       ` | ||||
|       stateDiagram-v2 | ||||
|       [*] --> 1 | ||||
|       1 --> 2: test({ foo#colon; 'far' }) | ||||
|       2 --> [*] | ||||
|     `, | ||||
|       { logLevel: 0, fontFamily: 'courier' } | ||||
|     ); | ||||
|   }); | ||||
| }); | ||||
|   | ||||
| @@ -2,6 +2,7 @@ import { select } from 'd3'; | ||||
| import { log } from '../logger'; // eslint-disable-line | ||||
| import { getConfig } from '../config'; | ||||
| import { sanitizeText, evaluate } from '../diagrams/common/common'; | ||||
| import { decodeEntities } from '../mermaidAPI'; | ||||
|  | ||||
| const sanitizeTxt = (txt) => sanitizeText(txt, getConfig()); | ||||
|  | ||||
| @@ -52,7 +53,7 @@ const createLabel = (_vertexText, style, isTitle, isNode) => { | ||||
|     log.info('vertexText' + vertexText); | ||||
|     const node = { | ||||
|       isNode, | ||||
|       label: vertexText.replace( | ||||
|       label: decodeEntities(vertexText).replace( | ||||
|         /fa[lrsb]?:fa-[\w-]+/g, | ||||
|         (s) => `<i class='${s.replace(':', ' ')}'></i>` | ||||
|       ), | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Lorens León
					Lorens León