Comments (5)
hi Vladimir, I think that's the case, but I will review it, something like this shall work:
[This is a note about item \\[123\\] in array]
from vscode-yuml.
Unfortunately, neither [ nor [ worksL
I looked at the code and I think that the splitYumlExpr function needs to be improved to support this scenario.
I was playing with idea of the ‘universal’ regex to split the string into parts, but I couldn’t build one because of the vanilla Javascript implementation of the regex (I needed a positive lookbehind feature).
The easiest way to solve it, but not an elegant one, I’m afraid, is to replace special characters prepended with ‘\’ before parsing and restore them after.
Kind of like this:
this.splitYumlExpr = function(line, separators) {
var word = "";
var lastChar = null;
var parts = [];
// a special handling for the ( ) < > | [ ]
// we are going to replace them with special characters and restore after
// the parsing
line = line
.replace(/(/g, '&&op&&')
.replace(/)/g, '&&cp&&')
.replace(/[/g, '&&osp&&')
.replace(/]/g, '&&csp&&')
.replace(/</g, '&&oap&&')
.replace(/>/g, '&&cap&&')
.replace(/|/g, '&&pp&&');
for (var i = 0; i < line.length; i++) {
c = line[i];
if (separators.indexOf(c) >= 0 && lastChar === null) {
if (word.length > 0) {
parts.push(word.trim());
word = "";
}
switch (c) {
case '[':
lastChar = ']';
break;
case '(':
lastChar = ')';
break;
case '<':
lastChar = '>';
break;
case '|':
lastChar = '|';
break;
default:
lastChar = null;
break;
}
word = c;
} else if (c === lastChar) {
lastChar = null;
parts.push(word.trim() + c);
word = "";
} else {
word += c;
}
}
if (word.length > 0)
parts.push(word.trim());
// replace back
for (var p = 0; p < parts.length; p++) {
parts[p] = parts[p]
.replace(/&&op&&/g, '(')
.replace(/&&cp&&/g, ')')
.replace(/&&osp&&/g, '[')
.replace(/&&csp&&/g, ']')
.replace(/&&oap&&/g, '<')
.replace(/&&cap&&/g, '>')
.replace(/&&pp&&/g, '|');
}
return parts;
}
As I said, not an elegant, but workable solution….
Thank You,
Vladimir
From: Jaime Olivares [email protected]
Reply-To: jaime-olivares/vscode-yuml [email protected]
Date: Wednesday, November 16, 2016 at 8:41 PM
To: jaime-olivares/vscode-yuml [email protected]
Cc: Vladimir Yangurskiy [email protected], Author [email protected]
Subject: Re: [jaime-olivares/vscode-yuml] Better handling of the '[' and ']' characters in the body of the object (#15)
hi Vladimir, I think that's the case, but I will review it, something like this shall work:
[This is a note about item [123] in array]
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
from vscode-yuml.
Created #18 with another idea for a fix. Please have a look.
Not sure how to link the PR to this issue, thought it might be about the title - unfortunately not... Please advise.
from vscode-yuml.
Replaced the PR by an improved #19. Sorry, have to edit from a web terminal...
from vscode-yuml.
Already solved in PR #19
from vscode-yuml.
Related Issues (20)
- No preview HOT 3
- Dark color theme for sequence diagram is wrong HOT 3
- Same rendering as Yuml.me HOT 1
- Chinese character shows out of the box when type is sequence HOT 1
- snippets not working in markdown HOT 2
- Make TopBar optional
- Wiki copy error of the example code from package diagram HOT 1
- Object node is showed incorrectly HOT 4
- Need help with YUML and Mediawiki extension HOT 1
- Extension issue HOT 1
- Feature: override theme background color on preview
- Editor window becomes unresponsive HOT 3
- Extension causes high cpu load HOT 2
- Allow the preview window to Zoom In and Zoom Out
- Allow to save diagrams as an image HOT 3
- Can not use yuml in vscode 1.60.2 HOT 1
- Preview is not consistent with the official website
- Add possibility to export generated yUML HOT 2
- Export .yuml file to other formats like .png, jpg, pdf,...
- store svg in dark and light mode variants
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vscode-yuml.