mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-19 23:39:50 +02:00
Added support for entity codes for sequence diagrams so that it for instance is possible to represent a " with #quot; and a heart with #9829;. This as referenced in issue #74 and issue #193.
This commit is contained in:
49
dist/mermaidAPI.js
vendored
49
dist/mermaidAPI.js
vendored
@@ -37341,6 +37341,45 @@ exports.version = function(){
|
||||
return require('../package.json').version;
|
||||
};
|
||||
|
||||
exports.encodeEntities = function(text){
|
||||
var txt = text;
|
||||
|
||||
txt = txt.replace(/#\w*;?/g,function(s,t,u){
|
||||
var innerTxt = s.substring(1,s.length-1);
|
||||
|
||||
var isInt = /^\+?\d+$/.test(innerTxt);
|
||||
if(isInt){
|
||||
return 'fl°°'+innerTxt+'¶ß';
|
||||
}else{
|
||||
return 'fl°'+innerTxt+'¶ß';
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
//txt = txt.replace(/fa:fa[\w\-]+/g,function(s,t,u){
|
||||
// return 'fa:¢';
|
||||
//});
|
||||
|
||||
return txt;
|
||||
};
|
||||
|
||||
exports.decodeEntities = function(text){
|
||||
var txt = text;
|
||||
|
||||
txt = txt.replace(/\fl\°\°/g,function(s,t,u){
|
||||
return '&#';
|
||||
});
|
||||
txt = txt.replace(/\fl\°/g,function(s,t,u){
|
||||
return '&';
|
||||
});
|
||||
txt = txt.replace(/¶ß/g,function(s,t,u){
|
||||
return ';';
|
||||
});
|
||||
|
||||
|
||||
|
||||
return txt;
|
||||
};
|
||||
/**
|
||||
* ##render
|
||||
* Function that renders an svg with a graph from a chart definition. Usage example below.
|
||||
@@ -37385,6 +37424,11 @@ var render = function(id, txt, cb, container){
|
||||
.append('g');
|
||||
}
|
||||
|
||||
|
||||
txt = exports.encodeEntities(txt);
|
||||
//console.warn('mermaid encode: ');
|
||||
//console.warn(txt);
|
||||
|
||||
var element = d3.select('#d'+id).node();
|
||||
var graphType = utils.detectType(txt);
|
||||
var classes = {};
|
||||
@@ -37430,6 +37474,11 @@ var render = function(id, txt, cb, container){
|
||||
// Fix for when the base tag is used
|
||||
var svgCode = d3.select('#d'+id).node().innerHTML.replace(/url\(#arrowhead/g,'url('+ window.location.protocol+'//'+location.host+location.pathname +'#arrowhead','g');
|
||||
|
||||
svgCode = exports.decodeEntities(svgCode);
|
||||
//console.warn('mermaid decode: ');
|
||||
//console.warn(svgCode);
|
||||
//var he = require('he');
|
||||
//svgCode = he.decode(svgCode);
|
||||
if(typeof cb !== 'undefined'){
|
||||
cb(svgCode,graph.bindFunctions);
|
||||
}else{
|
||||
|
Reference in New Issue
Block a user