mirror of
https://github.com/tailormade-eu/obsidian-task-export-plugin.git
synced 2026-07-22 06:41:42 +00:00
Compare commits
4 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fcc0c3f4f0 | ||
|
|
6fdae87c5a | ||
|
|
5c98896917 | ||
|
|
01a5d99d0b |
9 changed files with 79 additions and 26 deletions
21
CHANGELOG.md
Normal file
21
CHANGELOG.md
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## [1.0.5] - 2025-11-21
|
||||
### Added
|
||||
- Include folder subfolders as hierarchical `Level1..LevelN` CSV columns. Folder segments under the configured `Customers` folder are now emitted as Level columns before the project filename and markdown headers.
|
||||
- README examples updated to use generic placeholders (`<CustomerName>`, `<Subfolder>`, `<ProjectName>`, `<Task>`).
|
||||
|
||||
### Changed
|
||||
- CSV header format changed to: `CustomerName,Level1,Level2,...,Task` (project filename moved into `Level` columns to maintain consistent hierarchical ordering).
|
||||
- CSV writer now uses a canonical `levels` array on parsed tasks which contains: folder segments, project filename, document headers, and parent task text.
|
||||
|
||||
### Notes
|
||||
- The plugin bundle (`main.js`) should be rebuilt after the version bump. Run `npm run build` locally before publishing.
|
||||
- If you distribute the plugin via GitHub Releases, create a release tagged `v1.0.5` and attach the rebuilt `main.js`, `manifest.json`, and `styles.css`.
|
||||
|
||||
---
|
||||
|
||||
## Previous releases
|
||||
- See repository history for older versions.
|
||||
16
README.md
16
README.md
|
|
@ -169,14 +169,26 @@ Standard Markdown task checkboxes:
|
|||
CSV with dynamic columns (comma-separated by default, configurable to semicolon):
|
||||
|
||||
```csv
|
||||
CustomerName,ProjectName,Header1,Header2,Header3,Task
|
||||
CustomerName,Level1,Level2,Level3,Task
|
||||
Customer A,Project 1,Section,Outstanding task
|
||||
Customer A,Project 1,Section,Task with sub-items
|
||||
Customer A,Project 1,Section,Sub-task (nested)
|
||||
Customer A,Project 1,Section,Subsection,Another task
|
||||
```
|
||||
|
||||
The delimiter can be changed to semicolon (`;`) in the plugin settings for better compatibility with European Excel versions.
|
||||
Notes:
|
||||
- **Level columns**: The plugin uses generic `Level1..LevelN` columns for hierarchical path data. These contain, in order: any subfolder segments under the customer folder, then the project (markdown file) name, followed by markdown header segments and parent task text as present.
|
||||
- **Compression**: When `Compress Levels` is enabled the CSV will omit empty trailing `Level` columns for each row; when disabled rows are padded to the maximum level depth.
|
||||
- The delimiter can be changed to semicolon (`;`) in the plugin settings for better compatibility with European Excel versions.
|
||||
|
||||
Example
|
||||
|
||||
For a file under the `Customers` folder such as `Customers/<CustomerName>/<Subfolder...>/<ProjectName>.md` containing a top-level task in a `Section`, a produced CSV row will look like:
|
||||
|
||||
```csv
|
||||
CustomerName,Level1,Level2,Task
|
||||
<CustomerName>,<Subfolder>,<ProjectName>,Section - Outstanding task
|
||||
```
|
||||
|
||||
## Technical Details
|
||||
|
||||
|
|
|
|||
19
main.js
19
main.js
|
|
@ -107,7 +107,7 @@ var _MarkdownParser = class {
|
|||
/**
|
||||
* Parses a markdown file and extracts all outstanding tasks.
|
||||
*/
|
||||
parseFile(content, customerName, projectName) {
|
||||
parseFile(content, customerName, projectName, folderSegments = []) {
|
||||
const tasks = [];
|
||||
const lines = content.split("\n");
|
||||
const headers = [];
|
||||
|
|
@ -155,6 +155,12 @@ var _MarkdownParser = class {
|
|||
levels: []
|
||||
};
|
||||
const levels = [];
|
||||
if (folderSegments && folderSegments.length > 0) {
|
||||
levels.push(...folderSegments);
|
||||
}
|
||||
if (projectName && projectName.length > 0) {
|
||||
levels.push(projectName);
|
||||
}
|
||||
levels.push(...headers);
|
||||
if (parentTaskStack.length > 0) {
|
||||
const parents = [...parentTaskStack].reverse();
|
||||
|
|
@ -216,7 +222,7 @@ var CsvWriter = class {
|
|||
const maxLevelDepth = compressLevels ? this.determineMaxCompressedLevelDepth(tasks) : this.determineMaxLevelDepth(tasks);
|
||||
let csv = "";
|
||||
if (includeHeader) {
|
||||
csv += `CustomerName${this.delimiter}ProjectName`;
|
||||
csv += `CustomerName`;
|
||||
for (let i = 1; i <= maxLevelDepth; i++) {
|
||||
csv += `${this.delimiter}Level${i}`;
|
||||
}
|
||||
|
|
@ -225,8 +231,6 @@ var CsvWriter = class {
|
|||
}
|
||||
for (const task of tasks) {
|
||||
csv += this.escapeField(task.customerName);
|
||||
csv += this.delimiter;
|
||||
csv += this.escapeField(task.projectName);
|
||||
if (compressLevels) {
|
||||
const nonEmptyLevels = task.levels.filter((l) => l !== "");
|
||||
for (const level of nonEmptyLevels) {
|
||||
|
|
@ -313,7 +317,7 @@ var TaskExporter = class {
|
|||
(file) => file.path.startsWith(normalizedPath + "/")
|
||||
);
|
||||
for (const file of customerFiles) {
|
||||
const { customerName, projectName } = this.extractCustomerAndProject(file, normalizedPath);
|
||||
const { customerName, projectName, folderSegments } = this.extractCustomerAndProject(file, normalizedPath);
|
||||
if (customerName.startsWith(".")) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -322,7 +326,7 @@ var TaskExporter = class {
|
|||
}
|
||||
try {
|
||||
const content = await this.app.vault.read(file);
|
||||
const tasks = this.parser.parseFile(content, customerName, projectName);
|
||||
const tasks = this.parser.parseFile(content, customerName, projectName, folderSegments);
|
||||
if (tasks.length > 0) {
|
||||
allTasks.push(...tasks);
|
||||
if (verbose) {
|
||||
|
|
@ -354,7 +358,8 @@ var TaskExporter = class {
|
|||
const parts = relativePath.split("/");
|
||||
const customerName = parts[0];
|
||||
const projectName = file.basename;
|
||||
return { customerName, projectName };
|
||||
const folderSegments = parts.length > 2 ? parts.slice(1, parts.length - 1) : [];
|
||||
return { customerName, projectName, folderSegments };
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "task-export-to-csv",
|
||||
"name": "Task Export Tool",
|
||||
"version": "1.0.4",
|
||||
"version": "1.0.5",
|
||||
"minAppVersion": "1.0.0",
|
||||
"description": "Export outstanding tasks to CSV for time tracking integration (e.g. ManicTime).",
|
||||
"author": "Raoul Jacobs",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "obsidian-task-export-plugin",
|
||||
"version": "1.0.4",
|
||||
"version": "1.0.5",
|
||||
"description": "Export outstanding tasks from Obsidian vault to CSV for ManicTime integration",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@ export class CsvWriter {
|
|||
|
||||
// Build header row based on max level depth
|
||||
if (includeHeader) {
|
||||
csv += `CustomerName${this.delimiter}ProjectName`;
|
||||
// Emit CustomerName, then Level columns (first level may be project name or a subfolder), then Task
|
||||
csv += `CustomerName`;
|
||||
for (let i = 1; i <= maxLevelDepth; i++) {
|
||||
csv += `${this.delimiter}Level${i}`;
|
||||
}
|
||||
|
|
@ -38,9 +39,7 @@ export class CsvWriter {
|
|||
// Write data rows
|
||||
for (const task of tasks) {
|
||||
csv += this.escapeField(task.customerName);
|
||||
csv += this.delimiter;
|
||||
csv += this.escapeField(task.projectName);
|
||||
|
||||
|
||||
if (compressLevels) {
|
||||
// Compressed mode: only output non-empty levels, skipping empty slots
|
||||
const nonEmptyLevels = task.levels.filter(l => l !== '');
|
||||
|
|
@ -59,7 +58,6 @@ export class CsvWriter {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
csv += this.delimiter;
|
||||
csv += this.escapeField(task.task);
|
||||
csv += '\n';
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ export class TaskExporter {
|
|||
|
||||
// Process each file
|
||||
for (const file of customerFiles) {
|
||||
// Extract customer name and project name from file path
|
||||
const { customerName, projectName } = this.extractCustomerAndProject(file, normalizedPath);
|
||||
// Extract customer name, project name and folder segments from file path
|
||||
const { customerName, projectName, folderSegments } = this.extractCustomerAndProject(file, normalizedPath);
|
||||
|
||||
// Skip files in hidden directories
|
||||
if (customerName.startsWith('.')) {
|
||||
|
|
@ -57,7 +57,8 @@ export class TaskExporter {
|
|||
|
||||
try {
|
||||
const content = await this.app.vault.read(file);
|
||||
const tasks = this.parser.parseFile(content, customerName, projectName);
|
||||
// Pass folderSegments into parser so levels can include folder hierarchy
|
||||
const tasks = this.parser.parseFile(content, customerName, projectName, folderSegments);
|
||||
|
||||
if (tasks.length > 0) {
|
||||
allTasks.push(...tasks);
|
||||
|
|
@ -96,7 +97,7 @@ export class TaskExporter {
|
|||
* Customer name is the first folder under customersFolder.
|
||||
* Project name is the filename without extension.
|
||||
*/
|
||||
private extractCustomerAndProject(file: TFile, customersFolder: string): { customerName: string, projectName: string } {
|
||||
private extractCustomerAndProject(file: TFile, customersFolder: string): { customerName: string, projectName: string, folderSegments: string[] } {
|
||||
// Remove the customers folder prefix from the path
|
||||
let relativePath = file.path.substring(customersFolder.length + 1);
|
||||
|
||||
|
|
@ -108,7 +109,11 @@ export class TaskExporter {
|
|||
|
||||
// Project name is the filename without extension
|
||||
const projectName = file.basename;
|
||||
|
||||
return { customerName, projectName };
|
||||
|
||||
// Folder segments are the intermediate path parts between the customer folder and the file name
|
||||
// parts = [ customer, sub1, sub2, ..., filename ] so folderSegments should be parts.slice(1, parts.length - 1)
|
||||
const folderSegments = parts.length > 2 ? parts.slice(1, parts.length - 1) : [];
|
||||
|
||||
return { customerName, projectName, folderSegments };
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ export class MarkdownParser {
|
|||
/**
|
||||
* Parses a markdown file and extracts all outstanding tasks.
|
||||
*/
|
||||
parseFile(content: string, customerName: string, projectName: string): TaskItem[] {
|
||||
parseFile(content: string, customerName: string, projectName: string, folderSegments: string[] = []): TaskItem[] {
|
||||
const tasks: TaskItem[] = [];
|
||||
const lines = content.split('\n');
|
||||
|
||||
|
|
@ -91,9 +91,19 @@ export class MarkdownParser {
|
|||
levels: []
|
||||
};
|
||||
|
||||
// Add document headers - keep all levels including empty ones for proper structure
|
||||
// Build levels with folder segments first, then document headers
|
||||
const levels: string[] = [];
|
||||
|
||||
|
||||
// Insert folder segments (subfolders under the customer folder)
|
||||
if (folderSegments && folderSegments.length > 0) {
|
||||
levels.push(...folderSegments);
|
||||
}
|
||||
|
||||
// Insert the project name as a level after folder segments (so it appears after subfolders)
|
||||
if (projectName && projectName.length > 0) {
|
||||
levels.push(projectName);
|
||||
}
|
||||
|
||||
// Copy all header levels (including empty ones) to preserve hierarchy
|
||||
levels.push(...headers);
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ export const DEFAULT_SETTINGS: TaskExportSettings = {
|
|||
export interface TaskItem {
|
||||
customerName: string;
|
||||
projectName: string;
|
||||
levels: string[]; // Hierarchical headers and parent tasks
|
||||
// `levels` contains folder segments (subfolders under the customer),
|
||||
// followed by document header levels (##, ###, ...), then parent task texts.
|
||||
levels: string[];
|
||||
task: string; // The actual task text
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue