Javascript library that parses SWTF into JSON
⚠️ This project is created to meet the needs of our development team. Our main focus currently won't be on maintainig this project.
Install swtf-parser
via npm:
npm i swtf-parser
Using CDN:
<script src="https://cdn.jsdelivr.net/npm/swtf-parser@latest/dist/bundle.js"></script>
or
<script src="https://unpkg.com/swtf-parser@1.0.6/dist/bundle.js"></script>
Here's an simple example:
const { parseSwtf } = require('swtf-parser');
const tasks = parseSwtf('- Define format that can be so simple and used acrossed devices\n');
console.log(JSON.stringify(tasks, null, 4));
This code should output:
[
{
"text": "Define format that can be so simple and used acrossed devices",
"attributes": [],
"subTasks": [],
"level": 0
}
]
Here's an example of task with attributes:
const { parseSwtf } = require('swtf-parser');
const tasks = parseSwtf('- Define format that can be so simple and used acrossed devices [member: 👽][⚡]\n');
console.log(JSON.stringify(tasks, null, 4));
This code should output:
[
{
"text": "Define format that can be so simple and used acrossed devices",
"attributes": [
{
"name": "member",
"index": 0,
"value": "👽"
},
{
"name": null,
"index": 1,
"value": "⚡"
}
],
"subTasks": [],
"level": 0
}
]
An example of task list:
const { parseSwtf } = require('swtf-parser');
const rawTasks = `
- Daily tasks 😐:
- store: [borring]
- food [😅]
- coffee [✅]
- work: [borring]
- include e2e testing mechanism [p: medium][😅]
- improve load testing [p: high][😅]
- write today's tasks in SWTF [cool][✅]
`;
const tasks = parseSwtf(rawTasks);
console.log(JSON.stringify(tasks, null, 4));
This code should have same output as simple-task-list.json