Code Monkey home page Code Monkey logo

snapdragon's People

Contributors

danez avatar doowb avatar edwardbetts avatar jonschlinkert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

snapdragon's Issues

Prev / next, or offset

app
  .use(function any () {
    var pos = this.position();
    var m = this.match(/^./);
    if (!m) return;
    return pos({
      type: 'any',
      val: m[0]
    });
  })

Idea how from one renderer to get prev and next char? I think offset in position would work for me.

edit: And btw, should mention in readme, that you should be careful with parser plugins order (will show example in other issue).

upgrade source-map-resolve to 0.6.0

source-map-resolve 0.50 uses two deprecated libs urix and resolve-url. so nstalling snapdragon via npm complains about the deprecated warning.

Please tag release release 0.11.0

According to github, the last release was 0.8.0... but there are commits saying otherwise : perhaps you forgot to tag them?

Thanks!

Monorepo

It is nice that snapdragon as well as micromatch are nicely separated into small pieces, but I really think that having all of them in separate repositories make maintaining them a big pain, especially when making a breaking change in one of them that other rely one and then trying to update the whole ecosystem.

I'm also maintaining some projects that use monorepos with yarn workspaces and lerna and it gives you the ability to have small packages, but makes bigger changes super easy as they are all in one repository and one PR. So in my opinion setting up a monorepo would be a nice addition for snapdragon and micromatch.

So I wonder what your opinions are on this? And also for the micromatch org.

I don't want to come into a new project and change everything :) but I think it could make things a lot easier for everyone.

_

_

Security Vulnerability pick up by Fortify Scan (snapdragon)

Good Afternoon snapdragon team,

We were performing a scan on the snapdragon Javascript library and the Fortify application has picked up the following items that are discovered as vulnerabilities.
(Reason being our project has imported this library as a dependency and part of our deliverable would requires the scanning of the full source code and identify/remove the vulnerable.)

(Low) Password Management: Password in Comment
No of items picked by the Fortify Scan: Less than 10
Kindly refer to the following image, scanImage1.png
scanImage1

Do give us a heads up on when the team is planning to fix these vulnerabilities and/or the possible workarounds to prevent the same items to be picked up by the Fortify Scans again.

Dedupe dependencies.

Currently, there are multiple versions of several dependencies in the dependency tree. This issue is meant to organize the deduplication of these.

Please upgrade source-map to 0.7.2 to get speed improvements

The latest source-map which is v0.7.2 got support for WebAssembly and it is 10 times faster than the old one. More info here:

https://github.com/mozilla/source-map/blob/master/CHANGELOG.md#072
http://fitzgeraldnick.com/2018/02/26/speed-without-wizardry.html
https://hacks.mozilla.org/2018/01/oxidizing-source-maps-with-rust-and-webassembly/
firefox-devtools/debugger#5598

Please update so you would get 10 times speed improvements for your library in Firefox, 9 times in Safari and 5 times in Chrome.

Browser support?

I'm trying to work with this for building a parser for use in the browser, and it's failing on the source-maps inclusion, specifically webpack is dying because it's calling in fs and path modules.

Is there a configuration that will work for in the browser? Or is that something you're looking at adding in the future? Or maybe is that something I could help with adding?

[readme] - explain more for new-comers

Current iteration of Readme doesn't tell what exactly does snapdragon do.

It is stated it is "a factory", but there's no link to explanation what "a factory" is.

I wrote a few libraries that work with parsed HTML AST's and I'm somewhat familiar with the subject, yet I find the Readme file too steep and unfriendly.

Here are the simple questions that are still unanswered by the current Readme:

  • What does this library achieve by compiling and parsing?
  • Does snapdragon work on HTML (parsed or raw strings)? Or external CSS file's (parsed or raw string)?
  • How does snapdragon compare to, let's say a combination of PostHTML-parser and PostHTML-render? Can all be used together?

If you would lower the barrier for new-comers you would attract more contributors and win promoters for this library.

TypeError: expected an object, function, or array

I got this error using latest version of snapdragon

/home/remi/app/node_modules/snapdragon/node_modules/define-property/index.js:18
    throw new TypeError('expected an object, function, or array');
    ^

TypeError: expected an object, function, or array
    at defineProperty (/home/remi/app/node_modules/snapdragon/node_modules/define-property/index.js:18:11)
    at Parser.eos (/home/remi/app/node_modules/snapdragon/lib/parser.js:434:9)
    at Parser.parse (/home/remi/app/node_modules/snapdragon/lib/parser.js:536:20)
    at Object.<anonymous> (/home/remi/app/src/lib/index.js:15:20)
    at Module._compile (module.js:652:30)
    at loader (/home/remi/app/node_modules/babel-register/lib/node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (/home/remi/app/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)

using this parser:

function parser () {
  const pos = this.position()
  const match = this.match(/^\s*(if)\s*\(\s*(.*?)\s*\)\s*(?=then)/)
  const prev = this.prev()

  if (!match) return

  const ifNode = pos(this.node({
    type: 'ConditionnalState.if',
    val: match[1],
    condition: match[2]
  }))

  const conditionnalStateNode = pos(this.node({
    type: 'ConditionnalState',
    nodes: [ifNode]
  }))

  this.push('ConditionnalState', conditionnalStateNode)
  prev.nodes.push(conditionnalStateNode)
}

but if I change it for the following

function parser () {
  const pos = this.position()
  const match = this.match(/^\s*(if)\s*\(\s*(.*?)\s*\)\s*(?=then)/)
    // const prev = this.prev()

    if (!match) return

    const ifNode = pos(this.node({
      type: IfConditionnalStateParser.type,
      val: match[1],
      condition: match[2]
    }))

    // const conditionnalStateNode = pos(this.node({
    //   type: 'ConditionnalState',
    //   nodes: [ifNode]
    // }))

    // this.push('ConditionnalState', conditionnalStateNode)
    // prev.nodes.push(conditionnalStateNode)

    return ifNode
}

Here, there is no error.

I can't understand why that error.

It is the bundled eos() parser that throw TypeError because prev.parent is undefined.

define(prev.parent, 'escaped', true);

But I don't know why/when node should/must have a parent property.

I see that the condition for that line is hasOpenAndClose(prev) but I dont know hat to do with that.

I'm trying to create an AST to parse plantuml files (for activity diagrams only for now).

Here is the actual tree I get (when I use the second version of the mentionned parser, the first make eos() throw

Node {
  type: 'root',
  errors: [],
  nodes:
   [ Node { type: 'bos', val: '' },
     Node {
       type: 'Uml',
       title: 'Activité Eolienne',
       nodes:
        [ Node {
            type: 'Activity',
            nodes:
             [ Node { type: 'StaticState', val: 'Je veux installer une éolienne' },
               Node {
                 type: 'ConditionnalState.if',
                 val: 'if',
                 condition: 'Hauteur >= 12m (mât + nacelle)' },
               Node { type: 'ConditionnalState.then', val: 'then' },
               Node { type: 'Space', val: ' ' },
               Node { type: 'ConditionnalState.condition.open', val: '(' },
               Node { type: 'All', val: 'OUI)' },
               Node { type: 'NewLine', val: '\n' },
               Node { type: 'StaticState', val: 'CERFA = PC' },
               Node { type: 'Space', val: '  ' },
               Node { type: 'Activity.stop', val: 'stop' },
               Node { type: 'NewLine', val: '\n' },
               Node { type: 'ConditionnalState.else', val: 'else' },
               Node { type: 'Space', val: ' ' },
               Node { type: 'ConditionnalState.condition.open', val: '(' },
               Node { type: 'All', val: 'NON)' },
               Node { type: 'NewLine', val: '\n' },
               Node {
                 type: 'ConditionnalState.if',
                 val: 'if',
                 condition: 'Secteur protégé' },
               Node { type: 'ConditionnalState.then', val: 'then' },
               Node { type: 'Space', val: ' ' },
               Node { type: 'ConditionnalState.condition.open', val: '(' },
               Node { type: 'All', val: 'OUI)' },
               Node { type: 'NewLine', val: '\n' },
               Node { type: 'StaticState', val: 'CERFA = DP' },
               Node { type: 'Space', val: '    ' },
               Node { type: 'Activity.stop', val: 'stop' },
               Node { type: 'NewLine', val: '\n' },
               Node { type: 'Space', val: '  ' },
               Node { type: 'ConditionnalState.else', val: 'else' },
               Node { type: 'Space', val: ' ' },
               Node { type: 'ConditionnalState.condition.open', val: '(' },
               Node { type: 'All', val: 'NON)' },
               Node { type: 'NewLine', val: '\n' },
               Node { type: 'StaticState', val: 'Aucune autorisation nécessaire' },
               Node { type: 'StaticState', val: 'Retour au début de l\'assistant' },
               Node { type: 'Space', val: '    ' },
               Node { type: 'DetachPuml', val: 'detach' },
               Node { type: 'NewLine', val: '\n' },
               Node { type: 'All', val: 'endif' },
               Node { type: 'NewLine', val: '\n' } ],
            val: '\\undefined' },
          Node { type: 'All', val: '' } ] },
     Node { type: 'eos', val: '' } ] }

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.