svelte-parse
Version:
An increidbly relaxed svelte-parser
979 lines (978 loc) • 18.1 kB
JSON
{
"type": "root",
"children": [
{
"type": "svelteScript",
"tagName": "script",
"properties": [],
"selfClosing": false,
"children": [
{
"type": "text",
"value": "\n\timport Comment from './Comment.svelte';\n\n\texport let item;\n\texport let returnTo;\n\n\t$: url = !item.domain ? `https://news.ycombinator.com/${item.url}` : item.url;\n",
"position": {
"start": {
"line": 1,
"column": 9,
"offset": 8
},
"end": {
"line": 8,
"column": 1,
"offset": 172
}
}
}
],
"position": {
"start": {
"line": 1,
"column": 1,
"offset": 0
},
"end": {
"line": 8,
"column": 10,
"offset": 181
}
}
},
{
"type": "text",
"value": "\n\n",
"position": {
"start": {
"line": 8,
"column": 10,
"offset": 181
},
"end": {
"line": 10,
"column": 1,
"offset": 183
}
}
},
{
"type": "svelteStyle",
"tagName": "style",
"properties": [],
"selfClosing": false,
"children": [
{
"type": "text",
"value": "\n\tarticle {\n\t\tmargin: 0 0 1em 0;\n\t}\n\n\ta {\n\t\tdisplay: block;\n\t\tmargin: 0 0 1em 0;\n\t}\n\n\th1 {\n\t\tfont-size: 1.4em;\n\t\tmargin: 0;\n\t}\n",
"position": {
"start": {
"line": 10,
"column": 8,
"offset": 190
},
"end": {
"line": 24,
"column": 1,
"offset": 317
}
}
}
],
"position": {
"start": {
"line": 10,
"column": 1,
"offset": 183
},
"end": {
"line": 24,
"column": 9,
"offset": 325
}
}
},
{
"type": "text",
"value": "\n\n",
"position": {
"start": {
"line": 24,
"column": 9,
"offset": 325
},
"end": {
"line": 26,
"column": 1,
"offset": 327
}
}
},
{
"type": "svelteElement",
"tagName": "a",
"properties": [
{
"type": "svelteProperty",
"name": "href",
"value": [
{
"type": "svelteDynamicContent",
"position": {
"start": {
"line": 26,
"column": 9,
"offset": 335
},
"end": {
"line": 26,
"column": 19,
"offset": 345
}
},
"expression": {
"type": "svelteExpression",
"value": "returnTo",
"position": {
"start": {
"line": 26,
"column": 10,
"offset": 336
},
"end": {
"line": 26,
"column": 18,
"offset": 344
}
}
}
}
],
"modifiers": [],
"shorthand": "none",
"position": {
"start": {
"line": 26,
"column": 4,
"offset": 330
},
"end": {
"line": 26,
"column": 19,
"offset": 345
}
}
}
],
"selfClosing": false,
"children": [
{
"type": "text",
"value": "« back",
"position": {
"start": {
"line": 26,
"column": 20,
"offset": 346
},
"end": {
"line": 26,
"column": 32,
"offset": 358
}
}
}
],
"position": {
"start": {
"line": 26,
"column": 1,
"offset": 327
},
"end": {
"line": 26,
"column": 36,
"offset": 362
}
}
},
{
"type": "text",
"value": "\n\n",
"position": {
"start": {
"line": 26,
"column": 36,
"offset": 362
},
"end": {
"line": 28,
"column": 1,
"offset": 364
}
}
},
{
"type": "svelteElement",
"tagName": "article",
"properties": [],
"selfClosing": false,
"children": [
{
"type": "text",
"value": "\n\t",
"position": {
"start": {
"line": 28,
"column": 10,
"offset": 373
},
"end": {
"line": 29,
"column": 2,
"offset": 375
}
}
},
{
"type": "svelteElement",
"tagName": "a",
"properties": [
{
"type": "svelteProperty",
"name": "href",
"value": [
{
"type": "svelteDynamicContent",
"position": {
"start": {
"line": 29,
"column": 10,
"offset": 383
},
"end": {
"line": 29,
"column": 15,
"offset": 388
}
},
"expression": {
"type": "svelteExpression",
"value": "url",
"position": {
"start": {
"line": 29,
"column": 11,
"offset": 384
},
"end": {
"line": 29,
"column": 14,
"offset": 387
}
}
}
}
],
"modifiers": [],
"shorthand": "none",
"position": {
"start": {
"line": 29,
"column": 5,
"offset": 378
},
"end": {
"line": 29,
"column": 15,
"offset": 388
}
}
}
],
"selfClosing": false,
"children": [
{
"type": "text",
"value": "\n\t\t",
"position": {
"start": {
"line": 29,
"column": 16,
"offset": 389
},
"end": {
"line": 30,
"column": 3,
"offset": 392
}
}
},
{
"type": "svelteElement",
"tagName": "h1",
"properties": [],
"selfClosing": false,
"children": [
{
"type": "svelteDynamicContent",
"position": {
"start": {
"line": 30,
"column": 7,
"offset": 396
},
"end": {
"line": 30,
"column": 19,
"offset": 408
}
},
"expression": {
"type": "svelteExpression",
"value": "item.title",
"position": {
"start": {
"line": 30,
"column": 8,
"offset": 397
},
"end": {
"line": 30,
"column": 18,
"offset": 407
}
}
}
}
],
"position": {
"start": {
"line": 30,
"column": 3,
"offset": 392
},
"end": {
"line": 30,
"column": 24,
"offset": 413
}
}
},
{
"type": "text",
"value": "\n\t\t",
"position": {
"start": {
"line": 30,
"column": 24,
"offset": 413
},
"end": {
"line": 31,
"column": 3,
"offset": 416
}
}
},
{
"type": "svelteBranchingBlock",
"name": "if",
"branches": [
{
"type": "svelteBranch",
"name": "if",
"expression": {
"type": "svelteExpression",
"value": "item.domain",
"position": {
"start": {
"line": 31,
"column": 8,
"offset": 421
},
"end": {
"line": 31,
"column": 19,
"offset": 432
}
}
},
"children": [
{
"type": "svelteElement",
"tagName": "small",
"properties": [],
"selfClosing": false,
"children": [
{
"type": "svelteDynamicContent",
"position": {
"start": {
"line": 31,
"column": 27,
"offset": 440
},
"end": {
"line": 31,
"column": 40,
"offset": 453
}
},
"expression": {
"type": "svelteExpression",
"value": "item.domain",
"position": {
"start": {
"line": 31,
"column": 28,
"offset": 441
},
"end": {
"line": 31,
"column": 39,
"offset": 452
}
}
}
}
],
"position": {
"start": {
"line": 31,
"column": 20,
"offset": 433
},
"end": {
"line": 31,
"column": 48,
"offset": 461
}
}
}
],
"position": {
"start": {
"line": 31,
"column": 3,
"offset": 416
},
"end": {
"line": 31,
"column": 48,
"offset": 461
}
}
}
],
"position": {
"start": {
"line": 31,
"column": 3,
"offset": 416
},
"end": {
"line": 31,
"column": 53,
"offset": 466
}
}
},
{
"type": "text",
"value": "\n\t",
"position": {
"start": {
"line": 31,
"column": 53,
"offset": 466
},
"end": {
"line": 32,
"column": 2,
"offset": 468
}
}
}
],
"position": {
"start": {
"line": 29,
"column": 2,
"offset": 375
},
"end": {
"line": 32,
"column": 6,
"offset": 472
}
}
},
{
"type": "text",
"value": "\n\n\t",
"position": {
"start": {
"line": 32,
"column": 6,
"offset": 472
},
"end": {
"line": 34,
"column": 2,
"offset": 475
}
}
},
{
"type": "svelteElement",
"tagName": "p",
"properties": [
{
"type": "svelteProperty",
"name": "class",
"value": [
{
"type": "text",
"value": "meta",
"position": {
"start": {
"line": 34,
"column": 12,
"offset": 485
},
"end": {
"line": 34,
"column": 17,
"offset": 490
}
}
}
],
"modifiers": [],
"shorthand": "none",
"position": {
"start": {
"line": 34,
"column": 5,
"offset": 478
},
"end": {
"line": 34,
"column": 17,
"offset": 490
}
}
}
],
"selfClosing": false,
"children": [
{
"type": "text",
"value": "submitted by ",
"position": {
"start": {
"line": 34,
"column": 18,
"offset": 491
},
"end": {
"line": 34,
"column": 31,
"offset": 504
}
}
},
{
"type": "svelteDynamicContent",
"position": {
"start": {
"line": 34,
"column": 31,
"offset": 504
},
"end": {
"line": 34,
"column": 42,
"offset": 515
}
},
"expression": {
"type": "svelteExpression",
"value": "item.user",
"position": {
"start": {
"line": 34,
"column": 32,
"offset": 505
},
"end": {
"line": 34,
"column": 41,
"offset": 514
}
}
}
},
{
"type": "text",
"value": " ",
"position": {
"start": {
"line": 34,
"column": 42,
"offset": 515
},
"end": {
"line": 34,
"column": 43,
"offset": 516
}
}
},
{
"type": "svelteDynamicContent",
"position": {
"start": {
"line": 34,
"column": 43,
"offset": 516
},
"end": {
"line": 34,
"column": 58,
"offset": 531
}
},
"expression": {
"type": "svelteExpression",
"value": "item.time_ago",
"position": {
"start": {
"line": 34,
"column": 44,
"offset": 517
},
"end": {
"line": 34,
"column": 57,
"offset": 530
}
}
}
}
],
"position": {
"start": {
"line": 34,
"column": 2,
"offset": 475
},
"end": {
"line": 34,
"column": 62,
"offset": 535
}
}
},
{
"type": "text",
"value": "\n",
"position": {
"start": {
"line": 34,
"column": 62,
"offset": 535
},
"end": {
"line": 35,
"column": 1,
"offset": 536
}
}
}
],
"position": {
"start": {
"line": 28,
"column": 1,
"offset": 364
},
"end": {
"line": 35,
"column": 11,
"offset": 546
}
}
},
{
"type": "text",
"value": "\n\n",
"position": {
"start": {
"line": 35,
"column": 11,
"offset": 546
},
"end": {
"line": 37,
"column": 1,
"offset": 548
}
}
},
{
"type": "svelteElement",
"tagName": "div",
"properties": [
{
"type": "svelteProperty",
"name": "class",
"value": [
{
"type": "text",
"value": "comments",
"position": {
"start": {
"line": 37,
"column": 13,
"offset": 560
},
"end": {
"line": 37,
"column": 22,
"offset": 569
}
}
}
],
"modifiers": [],
"shorthand": "none",
"position": {
"start": {
"line": 37,
"column": 6,
"offset": 553
},
"end": {
"line": 37,
"column": 22,
"offset": 569
}
}
}
],
"selfClosing": false,
"children": [
{
"type": "text",
"value": "\n\t",
"position": {
"start": {
"line": 37,
"column": 23,
"offset": 570
},
"end": {
"line": 38,
"column": 2,
"offset": 572
}
}
},
{
"type": "svelteBranchingBlock",
"name": "each",
"branches": [
{
"type": "svelteBranch",
"name": "each",
"expression": {
"type": "svelteExpression",
"value": "item.comments as comment",
"position": {
"start": {
"line": 38,
"column": 9,
"offset": 579
},
"end": {
"line": 38,
"column": 33,
"offset": 603
}
}
},
"children": [
{
"type": "text",
"value": "\n\t\t",
"position": {
"start": {
"line": 38,
"column": 34,
"offset": 604
},
"end": {
"line": 39,
"column": 3,
"offset": 607
}
}
},
{
"type": "svelteComponent",
"tagName": "Comment",
"properties": [
{
"type": "svelteProperty",
"name": "comment",
"value": [
{
"type": "svelteDynamicContent",
"expression": {
"type": "svelteExpression",
"value": "comment",
"position": {
"start": {
"line": 39,
"column": 13,
"offset": 617
},
"end": {
"line": 39,
"column": 20,
"offset": 624
}
}
},
"position": {
"start": {
"line": 39,
"column": 12,
"offset": 616
},
"end": {
"line": 39,
"column": 20,
"offset": 624
}
}
}
],
"modifiers": [],
"shorthand": "expression",
"position": {
"start": {
"line": 39,
"column": 12,
"offset": 616
},
"end": {
"line": 39,
"column": 20,
"offset": 624
}
}
}
],
"selfClosing": true,
"children": [],
"position": {
"start": {
"line": 39,
"column": 3,
"offset": 607
},
"end": {
"line": 39,
"column": 24,
"offset": 628
}
}
},
{
"type": "text",
"value": "\n\t",
"position": {
"start": {
"line": 39,
"column": 24,
"offset": 628
},
"end": {
"line": 40,
"column": 2,
"offset": 630
}
}
}
],
"position": {
"start": {
"line": 38,
"column": 2,
"offset": 572
},
"end": {
"line": 40,
"column": 2,
"offset": 630
}
}
}
],
"position": {
"start": {
"line": 38,
"column": 2,
"offset": 572
},
"end": {
"line": 40,
"column": 9,
"offset": 637
}
}
},
{
"type": "text",
"value": "\n",
"position": {
"start": {
"line": 40,
"column": 9,
"offset": 637
},
"end": {
"line": 41,
"column": 1,
"offset": 638
}
}
}
],
"position": {
"start": {
"line": 37,
"column": 1,
"offset": 548
},
"end": {
"line": 41,
"column": 7,
"offset": 644
}
}
}
],
"position": {
"start": {
"column": 1,
"line": 1,
"offset": 0
},
"end": {
"line": 41,
"column": 7,
"offset": 644
}
}
}