Giter Site home page Giter Site logo

Comments (5)

jaime-olivares avatar jaime-olivares commented on August 19, 2024

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.

ttrider avatar ttrider commented on August 19, 2024

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.

chezwicker avatar chezwicker commented on August 19, 2024

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.

chezwicker avatar chezwicker commented on August 19, 2024

Replaced the PR by an improved #19. Sorry, have to edit from a web terminal...

from vscode-yuml.

jaime-olivares avatar jaime-olivares commented on August 19, 2024

Already solved in PR #19

from vscode-yuml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.