fabiospampinato / vscode-todo-plus

Manage todo lists with ease. Powerful, easy to use and customizable.
MIT License
903 stars 228 forks source link

Export to HTML #185

Open spmeesseman opened 5 years ago

spmeesseman commented 5 years ago

Great great great extension, I really see value in this, especially if I could export the marked up file to HTML to send to co workers and superiors. Any chance for this in the future? I'd take a stab at it myself if you think its not worth your time, as soon as I can get some time myself haha. But thanks again for a great tool in any case

fabiospampinato commented 5 years ago

If you'd like to submit a PR for this I'd be happy to consider it.

It shouldn't be too difficult to implement, but I'm not sure how "cancelled" todos should be translated to HTML, since there's no concept of a "cancelled" checkbox 🤔

pzmarzly commented 5 years ago

Maybe indeterminate checkboxes could be used? They display as [-] in modern browsers (not sure about Safari though).

fabiospampinato commented 5 years ago

@pzmarzly Maybe 🤷‍♂️ Maybe we could get a nice output if we styled those via CSS to make them appear more like "cancelled" todos rather than indeterminate.

spmeesseman commented 5 years ago

was going to take a poke at this. i need a little help though i am not too familiar with ts, just started using it a few weeks ago, why do I get these 5 errors like this when trying to build a base branch? I mean, its obvious, but the way you wrote that it seems to be like the compiler is supposed to handle that, checking the instance types of the variable and coding accordingly. WHat am I missing?

`ERROR in C:\Projects\vscode-todo-plus\src\todo\document.ts ./src/todo/document.ts [tsl] ERROR in C:\Projects\vscode-todo-plus\src\todo\document.ts(23,7) TS2322: Type 'string | TextDocument | TextEditor' is not assignable to type 'string'. Type 'TextDocument' is not assignable to type 'string'.

ERROR in C:\Projects\vscode-todo-plus\src\todo\document.ts ./src/todo/document.ts [tsl] ERROR in C:\Projects\vscode-todo-plus\src\todo\document.ts(27,26) TS2361: The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.

ERROR in C:\Projects\vscode-todo-plus\src\utils\time.ts ./src/utils/time.ts [tsl] ERROR in C:\Projects\vscode-todo-plus\src\utils\time.ts(125,15) TS2339: Property 'replace' does not exist on type 'string | number'. Property 'replace' does not exist on type 'number'.

ERROR in C:\Projects\vscode-todo-plus\src\utils\time.ts ./src/utils/time.ts [tsl] ERROR in C:\Projects\vscode-todo-plus\src\utils\time.ts(126,15) TS2339: Property 'replace' does not exist on type 'string | number | Date'. Property 'replace' does not exist on type 'number'.

ERROR in C:\Projects\vscode-todo-plus\src\utils\time.ts ./src/utils/time.ts [tsl] ERROR in C:\Projects\vscode-todo-plus\src\utils\time.ts(128,33) TS2345: Argument of type 'string | number | Date' is not assignable to parameter of type 'string'. Type 'number' is not assignable to type 'string'.`

fabiospampinato commented 5 years ago

why do I get these 5 errors like this when trying to build a base branch?

@spmeesseman I'm not sure what that means, did you clone the repo? How are you building the extension? Those look like some type errors, I'm not sure why I'm not seeing them (maybe you've got a different TS version, or downloaded different types for vscode).

the way you wrote that it seems to be like the compiler is supposed to handle that

I'm not sure what this means either, the way I wrote what? What's the compiler supposed to handle?

spmeesseman commented 5 years ago

Yes the repo is cloned with no modification, yes they are type errors and Im not sure how its compiling for you, I am using ts 2.9.8 which is max version semantically you have defined in package.json.

If I cast, the errors go away. example, document.ts:

if ( _.isString ( res ) ) { this.text = res as string; }

time.ts:

to = (to as string).replace ( / and /gi, ' ' ); to = (to as string).replace ( /(\d)(ms|s|m|h|d|w|y)(\d)/gi, '$1$2 $3' );

works fine

fabiospampinato commented 5 years ago

Yeah but that's just like telling the type checker to shut up. I'm not sure why you're getting those errors, if I run npm run compile I don't get any 🤔

spmeesseman commented 5 years ago

yeah, weird. It runs fine and I can debug the extension though. Gonna try to spend some time trying to figure out how it works this weekend. Do you have any suggestions on where to start looking to see how you color the tags and text and time calculations in the underlying todo document of the active editor?

fabiospampinato commented 5 years ago

Do you have any suggestions on where to start looking to see how you color the tags and text and time calculations in the underlying todo document of the active editor?

All the supported decorations are defined here, each one of those files basically maps regexes to decorations.

Most of the logic regarding individual todos is here.

But if you want to implement an export to HTML feature you just have to retrieve the current editor, check that it is of a supported language, and then basically transform each line to HTML, you can walk the document via this function.

teterkin commented 5 years ago

It shouldn't be too difficult to implement, but I'm not sure how "cancelled" todos should be translated to HTML, since there's no concept of a "cancelled" checkbox 🤔

You can try this: ✘ Test (25-04-19 16:56)

spmeesseman commented 5 years ago

Thanks... I have a little something done, when I have some more time I'll check back in with you to see what you think. It needs some work and I have some questions but wanted to drop a note so you knew i didn;t disappear, just really busy at work