Giter Club home page Giter Club logo

Comments (9)

rgbkrk avatar rgbkrk commented on August 20, 2024

Thanks for reporting this.

I'll have to do some thinking about how to handle ansiFilter.

from atom-script.

rgbkrk avatar rgbkrk commented on August 20, 2024

I'd like it to be as simple as escaping brackets like you did above, but we're going to run into issues on other entities that should be escaped as well (&, etc.). Rather than escaping them ourselves, I'd like to rely on good libraries/jQuery/spacepen to do it for us.

from atom-script.

ciarand avatar ciarand commented on August 20, 2024

Underscore has a great one to handle that. _.escape

from atom-script.

hansrodtang avatar hansrodtang commented on August 20, 2024

The way underscore does it is pretty much the exact same thing I did just with added ",' and & added in. Wouldn't it be a little bloated to add a library for that when adding those characters to my hack would be an identical fix?

from atom-script.

hansrodtang avatar hansrodtang commented on August 20, 2024

The way Mustache.js does it pretty clean and trivial to port to CoffeeScript. Since HTML is the only thing that would risk being rendered in the Atom browser environment it should be enough.

var entityMap = {
    "&": "&",
    "<": "&lt;",
    ">": "&gt;",
    '"': '&quot;',
    "'": '&#39;',
    "/": '&#x2F;'
  };

  function escapeHtml(string) {
    return String(string).replace(/[&<>"'\/]/g, function (s) {
      return entityMap[s];
    });
  }

from atom-script.

ciarand avatar ciarand commented on August 20, 2024

There's a huge number of packages that rely on the Atom version of underscore, but I can understand the hesitation. @rgbkrk?

from atom-script.

hansrodtang avatar hansrodtang commented on August 20, 2024

Ah, it slipped my mind that it might be included in Atom. If it is there is no reason not to use it.

from atom-script.

rgbkrk avatar rgbkrk commented on August 20, 2024

I thought for sure underscore-plus was included as part of Atom, but even vim-mode includes it as a dependency.

from atom-script.

rgbkrk avatar rgbkrk commented on August 20, 2024

I'm honestly fine with either having our own escape function or using underscore's. Either way, I've tested this out and am quite happy:

  display: (css, line) ->
    line = _.escape(line)
    line = @ansiFilter.toHtml(line)

    @output.append("<pre class='line #{css}'>#{line}</pre>")

from atom-script.

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.