Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplest "view-only" behavior for publishing on vanilla HTML sites? #107

Open
shah opened this issue Feb 20, 2023 · 14 comments
Open

Simplest "view-only" behavior for publishing on vanilla HTML sites? #107

shah opened this issue Feb 20, 2023 · 14 comments

Comments

@shah
Copy link

shah commented Feb 20, 2023

@kochrt this is a fantastic project, thanks for putting it together! We're using the VS Code extension for editing but we have a (seemingly) simple need: publishing a read-only interactive web version for in use in browsers. Similar to Mermaid and Markmap others that allow text to HTML/Js visualizations does Markwhen support creating browsable output for vanilla HTML sites (this is not the same as export/SVG).

For example, Mermaid and Markmap have an easy integration by just using <div class="mermaid">...content...</div>. How could we do something similar to make Markwhen markdown browsable?

@hikrr
Copy link

hikrr commented Feb 21, 2023

I also want to ask whether it is possible to have a timeline renderer support for react.
Or any examples or existing projects using react with markwhen to learn from.
(I found there are parser and view-client on npm, but no UI renderer components)

(Btw, this is a really great project, the good-looking style, the idea, etc.)

@kochrt
Copy link
Member

kochrt commented Feb 23, 2023

@shah HTML output is a good idea... the timeline, like all views, is framed, so it's already well encapsulated. The only problem is that it expects some outside input to know what to render. Which would normally be given to it by the app (markwhen.com or the VS Code extension).

I guess if all assets were inlined (css and js), one could simply download the page 🤔 🤔. I will investigate this further.

@hikrr If you implement the view orchestrator stuff in your react site you could host the timeline component. In fact I'm kind of doing the reverse thing - the calendar view is a react component and I am running it with the ViewOrchestrator which is in vue.

useLpc is just a wrapper around postMessage, and useStateSerializer puts the app state into a nice JSON object that we can send via postMessage. So if you hosted the timeline view you could more or less send a "state" update and the timeline would be rendered: lpc.postRequest("state", toRaw(stateSerializer.value));

@shah
Copy link
Author

shah commented Feb 24, 2023

Thanks for the elaboration @kochrt - seems like Markwhen would be a perfect fit for static site generators. Currently we're using Mermaid's Gantt and Timeline views in our Astro-based SSG but Markwhen is easier to write, more feature-packed and nicer to look at so we look forward to reading about the results of your investigation.

@kochrt
Copy link
Member

kochrt commented Mar 13, 2023

@kochrt should probably be a vite plugin like https://github.com/antfu/vite-plugin-md

@kochrt
Copy link
Member

kochrt commented Mar 24, 2023

@shah I just published @markwhen/mw on npm (repo).

With it you can do something like

mw my-timeline-file.mw timeline.html

from a terminal to convert a markwhen file to the timeline html. The html is fully contained (all js/css is inlined and no external scripts). It outputs an entire document, so if you wanted it as just a view on a page (as opposed to an entire page) you'd have to put it in an iframe.

If you try it, please let me know how it goes or if you have suggestions for improvement.

@shah
Copy link
Author

shah commented Mar 24, 2023

That's great news @kochrt - I appreciate the note and will give it a shot this weekend, thanks!

@shah
Copy link
Author

shah commented Mar 26, 2023

Thanks for this great feature @kochrt - it worked well for me.

Potential bug:

  • When I used npx @markwhen/mw -o timeline -d my_name.html it did not seem to work but when I used npx @markwhen/mw timeline.html it did work.

Suggestions:

  • Allow passing in additional arguments for showing "now" line, expand/collapse all, etc.

@kochrt
Copy link
Member

kochrt commented Mar 30, 2023

@shah Did you provide an input file in both cases? npx @markwhen/mw input.mw -o timeline -d my_name.html

@shah
Copy link
Author

shah commented Apr 1, 2023

Yes I tried a couple of variations, @kochrt it's pretty strange -- in my Node project, if I do this (my MarkWhen file is public/roadmap-prime.mw):

npx @markwhen/mw public/roadmap-prime.mw -o timeline -d public/roadmap-prime_timeline.html

The content in public/roadmap-prime_timeline.html is JSON but when I do this:

npx @markwhen/mw public/roadmap-prime.mw -d public/roadmap-prime_timeline.html

The content in public/roadmap-prime_timeline.html is HTML.

I run the commands directly from my NodeJS root and I have a package.json task defined so I can run it conveniently from there, too.

@kochrt
Copy link
Member

kochrt commented Apr 4, 2023

Sorry about that, should be fixed in 1.1.1, just published it

@shah
Copy link
Author

shah commented Apr 4, 2023

Excellent, thanks @kochrt I'll check it out soon and report back.

@shah
Copy link
Author

shah commented Apr 5, 2023

@kochrt should npx automatically pick up the latest version? When I used this a few minutes ago:

$ npx @markwhen/mw public/roadmap-prime.mw -o timeline -d public/roadmap-prime.html

My public/roadmap-prime.html output file contains JSON. If you can refine the CLI I should use to get the latest that would be helpful.

Thanks!

@kochrt
Copy link
Member

kochrt commented Apr 5, 2023

Hm can you try adding @latest?

npx @markwhen/mw@latest ...

@shah
Copy link
Author

shah commented Apr 5, 2023

Perfect, that did the trick @kochrt - thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants