Skip to content

Instantly share code, notes, and snippets.

@calacitizen
Last active April 12, 2016 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save calacitizen/588f3b67c3d02b205128b9fbcd263efd to your computer and use it in GitHub Desktop.
Save calacitizen/588f3b67c3d02b205128b9fbcd263efd to your computer and use it in GitHub Desktop.

####Линеаризация AST

Разбор HTML вёрстки:

//  html:
var html = '<div class="oh"><p>hi</p></div>';

Пример разложения на линейное AST:

[
  {
    type: 'tag',
    name: 'div',
    attrs: {
      class: data {
        type: 'text',
        value: 'oh'
      }
    },
    open: true,
    selfclosing: false,
  },
    {
    type: 'tag',
    name: 'p',
    attrs: {},
    open: true,
    selfclosing: false,
  },
  {
    type: 'text',
    data: {
      type: 'text',
      value: 'hi',
    }
    raw: 'hi'
  },
  {
    type: 'tag',
    name: 'p',
    attrs: {},
    open: false,
    selfclosing: false,
  },
  {
    type: 'tag',
    name: 'div',
    attrs: {},
    open: false,
    selfclosing: false,
  }
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment