allow mml2json to work even if the mml does not use entities
This commit is contained in:
parent
ba05eec550
commit
f4b1e434ff
@ -14,10 +14,13 @@ fs.readFile(process.ARGV[2], 'utf-8', function(err, data) {
|
||||
|
||||
// Replace entities.
|
||||
var entities = {};
|
||||
data.match(/<!ENTITY([^>]|"([^"]|\\")*")+>/g).forEach(function(entity) {
|
||||
var parts = entity.match(/^<!ENTITY\s+(\w+)\s+"(.+)">$/);
|
||||
entities['&' + parts[1] + ';'] = parts[2];
|
||||
});
|
||||
var match = data.match(/<!ENTITY([^>]|"([^"]|\\")*")+>/g)
|
||||
if (match != null) {
|
||||
match.forEach(function(entity) {
|
||||
var parts = entity.match(/^<!ENTITY\s+(\w+)\s+"(.+)">$/);
|
||||
entities['&' + parts[1] + ';'] = parts[2];
|
||||
});
|
||||
}
|
||||
data = data.replace(/&\w+;/g, function(entity) {
|
||||
return entities[entity];
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user