How to use xml-formatter - 10 common examples

To help you get started, we’ve selected a few xml-formatter examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mermaidjs / ariel-diagrams / src / index.js View on Github external
const rootNode = createNode(root, layoutOptions)
  rootNode.delete(['x', 'y'])
  rootNode.update({ xmlns: 'http://www.w3.org/2000/svg' })

  // remove rect for root node
  rootNode.shift()

  // arrow marker def
  const markers = uniqMarkers(root)
  if (!R.isEmpty(markers)) {
    rootNode.prepend(new X('defs', null, markers.map(m => defaultMarkers[m])))
  }

  const svg = rootNode.toString()
  if (log.getLevel() <= log.levels.DEBUG) {
    console.log(xmlFormat(svg))
  }
  return svg
}
github mermaidjs / ariel-diagrams / test / node / basic.spec.js View on Github external
test('one node', async () => {
    const graph = {
      id: 'root',
      children: [
        {
          id: 'n1',
          width: 100,
          height: 100
        }
      ]
    }
    const svg = await graph2svg(graph)
    fs.writeFileSync(path.join(__dirname, 'output', 'one-node.svg'), xmlFormat(svg))
    expect(onml.parse(svg)).toEqual(
      ['svg', { xmlns: 'http://www.w3.org/2000/svg', width: '150', height: '150' },
        ['svg', { x: '25', y: '25', width: '100', height: '100' },
          ['rect', { x: '1', y: '1', width: '98', height: '98', stroke: 'black', fill: 'none' }]
        ]
      ])
  })
github mermaidjs / ariel-diagrams / test / demo / index.spec.js View on Github external
test('hello world', async () => {
    const graph = {
      id: 'root',
      width: 100,
      height: 100
    }
    const svg = await graph2svg(graph)
    fs.writeFileSync(path.join(__dirname, 'output', 'hello-world.svg'), xmlFormat(svg))
    expect(onml.parse(svg)).toEqual(
      ['svg', { xmlns: 'http://www.w3.org/2000/svg', width: '100', height: '100' }])
  })
github mermaidjs / ariel-diagrams / test / node / label.spec.js View on Github external
}]
            },
            {
              id: 'n2',
              width: 100,
              height: 100,
              labels: [{
                text: 'ccc🤓'
              }]
            }
          ]
        }
      ]
    }
    const svg = await graph2svg(graph)
    fs.writeFileSync(path.join(__dirname, 'output', 'nested-node-labels.svg'), xmlFormat(svg))
    expect(onml.parse(svg)).toEqual(
      ['svg', { xmlns: 'http://www.w3.org/2000/svg', width: '325', height: '200' },
        ['svg', { x: '25', y: '25', width: '275', height: '150' },
          ['rect', { x: '1', y: '1', width: '273', height: '148', stroke: 'black', fill: 'none' }],
          ['svg', { width: '275', height: '25' },
            ['text', { x: '50%', y: '50%', stroke: 'black', 'text-anchor': 'middle', 'dominant-baseline': 'central' }, 'aaa']
          ],
          ['svg', { x: '25', y: '25', width: '100', height: '100' },
            ['rect', { x: '1', y: '1', width: '98', height: '98', stroke: 'black', fill: 'none' }],
            ['text', { x: '50%', y: '50%', stroke: 'black', 'text-anchor': 'middle', 'dominant-baseline': 'central' }, 'bbb']
          ],
          ['svg', { x: '150', y: '25', width: '100', height: '100' },
            ['rect', { x: '1', y: '1', width: '98', height: '98', stroke: 'black', fill: 'none' }],
            ['text', { x: '50%', y: '50%', stroke: 'black', 'text-anchor': 'middle', 'dominant-baseline': 'central' }, 'ccc🤓']
          ]
        ]
github mermaidjs / ariel-diagrams / test / demo / compact.spec.js View on Github external
expr: 'n3 ==> n4',
          label: 'One'
        },
        {
          expr: 'n3 ==> n5',
          label: 'Two'
        },
        {
          expr: 'n3 ==> n6',
          label: 'Three'
        }
      ]
    }
    const svg = await graph2svg(graph)
    expect(xmlFormat(svg)).toBe(fs.readFileSync(path.join(__dirname, 'output', 'classic.svg'), 'utf-8'))
    fs.writeFileSync(path.join(__dirname, 'output', 'compact.svg'), xmlFormat(svg))
  })
})
github mermaidjs / ariel-diagrams / test / demo / compact.spec.js View on Github external
{
          expr: 'n3 ==> n4',
          label: 'One'
        },
        {
          expr: 'n3 ==> n5',
          label: 'Two'
        },
        {
          expr: 'n3 ==> n6',
          label: 'Three'
        }
      ]
    }
    const svg = await graph2svg(graph)
    expect(xmlFormat(svg)).toBe(fs.readFileSync(path.join(__dirname, 'output', 'classic.svg'), 'utf-8'))
    fs.writeFileSync(path.join(__dirname, 'output', 'compact.svg'), xmlFormat(svg))
  })
})
github mermaidjs / ariel-diagrams / test / index.spec.js View on Github external
],
      edges: [
        {
          id: 'e1',
          sources: [ 'n1' ],
          targets: [ 'n2' ]
        },
        {
          id: 'e2',
          sources: [ 'n2' ],
          targets: [ 'n1' ]
        }
      ]
    }
    const svg = await graph2svg(graph)
    fs.writeFileSync(path.join(__dirname, 'output', 'two-edges.svg'), xmlFormat(svg))
    expect(onml.parse(svg)).toEqual(
      ['svg', { xmlns: 'http://www.w3.org/2000/svg', width: '244', height: '124' },
        ['rect', { x: '12', y: '12', width: '100', height: '100', stroke: 'black', fill: 'white' }],
        ['rect', { x: '132', y: '12', width: '100', height: '100', stroke: 'black', fill: 'white' }],
        ['path', { d: 'M 112 78.66666666666666 L 132 78.66666666666666', stroke: 'black' }],
        ['path', { d: 'M 132 45.33333333333333 L 112 45.33333333333333', stroke: 'black' }]
      ])
  })
github mermaidjs / ariel-diagrams / test / edge / basic.spec.js View on Github external
{
          id: 'n2',
          width: 100,
          height: 100
        }
      ],
      edges: [
        {
          id: 'e1',
          sources: [ 'n1' ],
          targets: [ 'n2' ]
        }
      ]
    }
    const svg = await graph2svg(graph)
    fs.writeFileSync(path.join(__dirname, 'output', 'one-edge.svg'), xmlFormat(svg))
    expect(onml.parse(svg)).toEqual(
      ['svg', { xmlns: 'http://www.w3.org/2000/svg', width: '275', height: '150' },
        ['svg', { x: '25', y: '25', width: '100', height: '100' },
          ['rect', { x: '1', y: '1', width: '98', height: '98', stroke: 'black', fill: 'none' }]
        ],
        ['svg', { x: '150', y: '25', width: '100', height: '100' },
          ['rect', { x: '1', y: '1', width: '98', height: '98', stroke: 'black', fill: 'none' }]
        ],
        ['path', { d: 'M 125 75 L 150 75', stroke: 'black', fill: 'none' }]
      ])
  })
github mermaidjs / ariel-diagrams / test / demo / classic.spec.js View on Github external
{
          id: 'e5',
          sources: ['n3'],
          targets: ['n6'],
          markers: [
            {
              id: '>',
              position: 'end'
            }
          ],
          labels: [{ width: 60, height: 20, text: 'Three' }]
        }
      ]
    }
    const svg = await graph2svg(graph)
    fs.writeFileSync(path.join(__dirname, 'output', 'classic.svg'), xmlFormat(svg))
  })
})
github itsezc / CycloneIO / source / utils / swf / furnidata.ts View on Github external
Download(Config.furniDataURL).then((newData: Buffer) => 
			{	
				var options = { 
					collapseContent: true 
				}

				var newStringData = newData.toString()
				var formattedXML = Format(newStringData, options)

				if (!IO.existsSync(destination)) 
				{
					IO.mkdirSync(destination)
				}

				if (data && data !== formattedXML || !exists)
				{
					IO.writeFileSync(filePath, formattedXML, 'utf8')

					this.parse(newStringData)
				}
				
				else 
				{
					Logger.info(`Furnidata has no changes, everything is ${Chalk.green('up-to-date')}`)

xml-formatter

Converts a XML string into a human readable format (pretty print) while respecting the xml:space attribute

MIT
Latest version published 5 months ago

Package Health Score

75 / 100
Full package analysis

Popular xml-formatter functions