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

Obsidian support #103

Open
2 tasks
kochrt opened this issue Feb 3, 2023 · 33 comments
Open
2 tasks

Obsidian support #103

kochrt opened this issue Feb 3, 2023 · 33 comments

Comments

@kochrt
Copy link
Member

kochrt commented Feb 3, 2023

I don't have any experience with Obsidian, is https://marcus.se.net/obsidian-plugin-docs/ the best place to get started?

Couple things that would need to be figured out:

  • Should markwhen be embedded in code blocks or should it expect an entire file to be markwhen?
  • Backlinking
@kochrt
Copy link
Member Author

kochrt commented Feb 11, 2023

File formats besides .md are not well supported in Obsidian... I suppose markwhen could be in code blocks, like:

\```mw
<markwhen document/>
\```

but that seems kind of inelegant

@icytree
Copy link

icytree commented Feb 11, 2023

Indeed, I would also point out that code blocks don't support wikilinks which could otherwise be a very interesting combination.

Would putting the content in a regular md file with a key in the yaml front matter indicating to the plugin it should be parsed as markwhen files a possible work around ?

Regarding the support of other file format in Obsidian, it is true that it is limited but I recall seeing some plugins managing to expand this a little. Here's a few examples I managed to find back :

@Coriakin
Copy link

code blocks don't support wikilinks

This is I think an important point. I am already feeling some pains that I cannot search globally and find text that are inside a "canvas" nor see backlinks from there.

If it was possible to retain such core functionality when using markwhen, that would be for the best I think :)

@quinn-p-mchugh
Copy link

quinn-p-mchugh commented Apr 13, 2023

Hi @kochrt, I began working on a prototype Obsidian plugin to support rendering of Markwhen syntax using a custom code block (happy to migrate this mark-when GitHub organization if you'd like!)

I'm new to Typescript and your package, so while figuring out how to parse code block content was straightforward, I'm a bit puzzled on the best way to go about taking the parsed Markwhen code and using it to generate HTML to be rendered by Obsidian preview.

I noticed the Markwhen CLI tool has a function called getInitialHtml that seems to convert parsed Markwhen code into an HTML file. I was hoping I might be able to do something like this to convert the parsed Markwhen code to HTML and inject that into the Obsidian preview, but the getInitialHtml function is not exposed outside of the CLI library.

Do you have any ideas on how one might best go about converting the parsed Markwhen code to Obsidian-friendly HTML? I'd love to better understand how Markwhen is structured and learn if there's a better approach than the one I described above.

Thank you for taking the time to create this library, by the way - it's fantastic.

@ltroj
Copy link

ltroj commented Apr 14, 2023

* [ ]  Should markwhen be embedded in code blocks or should it expect an entire file to be markwhen?

Without knowing much about the architecture of obisidian plugins, this is how some other popular plugins do it:
They have a command to switch between markdown view and the "plugin"/rendered view.

For example this is how an Excalidraw drawing looks like when opened as markdown:

---
excalidraw-plugin: parsed
---

==⚠ Switch to EXCALIDRAW VIEW in the MORE OPTIONS menu of this document. ⚠==

%%

# Text Elements
%%
# Drawing
```json
{
	"type": "excalidraw",
	"version": 2,
	"source": "https://github.com/zsviczian/obsidian-excalidraw-plugin/releases/tag/1.8.22",
	"elements": [
		{
			"id": "nsFug5LtUOGiCL_Vk_ibP",
		}
	],
	"appState": {
		"theme": "dark",
	},
	"files": {}
}
```
%%

The popular Kanban plugin does the same:

---
kanban-plugin: basic
---

## A Board

- [ ] A card

## Another Board

- [ ] Another card

%% kanban:settings
```
{"kanban-plugin":"basic"}
```
%%

Excalidraw uses a custom file extension *.excalidraw while Kanban just saves the file as *.md.

I'm extremely thrilled to see markwhen in Obsidian eventually, thanks for working at it!

@jayambede
Copy link

jayambede commented Apr 16, 2023

Maybe there is a way to make things even easier for the ordinary programming noob (like me!), by creating a dataview-like query format, that pulls the necessary dates and data form Metadata in Obsidian notes? I have been hoping for something like this for a long time and did a post in the forum HERE. And - as mentioned there - I did a respective detailed post in the obsidian-dataview forum on github. Maybe there are some ideas in there to contribute to this.
As of now there is also a continuation off this subject there below.
Thanks for considering!

@kochrt
Copy link
Member Author

kochrt commented Apr 17, 2023

@quinn-p-mchugh You can do what you're describing and it's actually relatively straightforward (if a bit heavy-handed). The html for the timeline view you can get from @markwhen/timeline (don't mind the readme, I haven't updated it).

You can append a script tag in the head with the parsed markwhen, like the CLI does, that will give you the html that you can provide to obsidian to render. I'd say it's a good place to start.

@zhuzhzh
Copy link

zhuzhzh commented Apr 21, 2023

I agree with this format.

```markwhen
<markwhen document>
```

@jayambede
Copy link

jayambede commented Apr 21, 2023

@quinn-p-mchugh:
As I tried to point out in the aforementioned Post in the Obsidian forum (here and here) this should be made easier for the "normal" Obsidian user.

I don't see why there has to be another coding language. Why not producing the relevant code for markwhen by the plugin, based on a search, done by the dataview/datacore Plugin?

My argument is this: If there is - as there seems to be - a strictly defined markdown-language used by the markwhen parser to describe every event that should be displayed, this code can also be produced by the plugin itself, based on the metadata in predefined fields of an obsidian note.

This way the user is enabled to produce any timeline, based on his notes and their content. Even the parallel display of different timelines, based on different tags in the notes would be possible. And every datapoint in the timeline could be a link to a note, explaining it.

And the codeblock might look like this:

```timeline
GANTT (or other type) "vert/hor" (mandatory for vertical or horizontal timelines) "timeline-start" "timeline-end"
FROM "tag, folder"
WHERE (field conditions)
GROUP BY (field(s))
OTHER COMMANDS

See also here

This would be much easier to use for the average User ...

Thanks for considering!

@ltroj
Copy link

ltroj commented Apr 21, 2023

This would be much easier to use for the average User ...

That would make the plugin completely useless to me, as it takes out all the benefits of markwhen.

The whole point of GANTT charts is that events can be dependent on each other (like Event 2 starts after Event 1 is finished). This is easily possible with the markwhen syntax.

Why should dataview come into play at all?

With a dataview query like you describe, the plugin would have to search for everything that meets the conditions and somehow looks like a date and build a timeline from that? I think that would be a feature request for dataview, but not what I expect from a markwhen plugin.

@quinn-p-mchugh
Copy link

quinn-p-mchugh commented Apr 21, 2023

My argument is this: If there is - as there seems to be - a strictly defined markdown-language used by the markwhen parser to describe every event that should be displayed, this code can also be produced by the plugin itself, based on the metadata in predefined fields of an obsidian note.

Hey @jayambede, thanks for sharing your perspective.

This could be done in the following way:

  1. Dataview aggregates notes + metadata
  2. Some intermediary script translates Dataview note objects to Markwhen-compatible objects
  3. Markwhen-compatible objects get rendered in Obsidian

I still think an MVP for a Markwhen Obsidian plugin should be simply rendering Markwhen code inside Obsidian, but I think functionality you're describing would be great to explore in the future.

@quinn-p-mchugh
Copy link

quinn-p-mchugh commented Apr 21, 2023

Why should dataview come into play at all?

With a dataview query like you describe, the plugin would have to search for everything that meets the conditions and somehow looks like a date and build a timeline from that? I think that would be a feature request for dataview, but not what I expect from a markwhen plugin.

@ltroj The idea is to leverage the Dataview API to aggregate note data into JavaScript objects. These objects could then be translated into the same format that's outputted by the Markwhen parser, which could then be rendered into whichever Markwhen view is desired by the user.

The major challenges here would be:

  1. Maintaining compatibility between this feature and dataview (i.e. continually updating this feature as the dataview API changes)
  2. Accounting for the numerous different types of dataview queries the user could try to render using this functionality.

@kochrt
Copy link
Member Author

kochrt commented Apr 21, 2023

I wouldn't recommend the triple backtick syntax to try to embed into a markdown document. While code blocks aren't supported in markwhen yet, I think they will be eventually, and even in the meantime backticks are not illegal in markwhen, so you could have difficulty determining where markwhen ends and markdown begins.

The expectation is that markwhen documents are their own files (with the .mw file extension).

As far as the dataview and querying goes, that seems like a separate topic. @jayambede you might consider opening a new issue to discuss dataview/querying in order to generate a timeline view. I've been thinking about something similar myself recently. If something comes out of that discussion maybe it could be looped back into other user interfaces, including an obsidian plugin.

@jayambede
Copy link

jayambede commented Apr 21, 2023

@ltroj: Oooooh, how silly of me, I totally forgot about the "project management guys"! ;-)

  1. This is only a mockup of a timeline-query, which could, based on the first trigger-word, also be "PROJECT" or "PROJECT-GANTT", with all the bells and whistles that are needed for that.
  2. I am not talking about reducing the options of markwhen here, I am talking about making a tool/Plugin for all users of obsidian, who are challenged, when it comes to creating a timeline regularly.
  3. Just a sidenote on dataview: It does not work by searching every note every time, it works either on the index of the content of notes that obsidian itself , or dataview produces to function. Every search function works like that. Would you think that Google search visits all the billions of webpages every time there is a query?
    So the relevant data (see 5.) would also be in the index. Dataview would only be the agent to produce a dataset.
  4. In the end all comes down to data efficiency. My proposal would place the relevant data of every timeline-event (be it historic, fictional or a project task) where it belongs: into the note that describes the event itself. It is there, where the dates need to be changed. Only one place - less room for error.
  5. All this would certainly depend on a number of metadata fields inside the respective note, that can be defined by the plugin (which means: markwhen), and placed in the event-notes (could be a template). An (incomplete) list might be:
    a. timeline-tag (either as separate field or within the tags of the note), which would then be the timeline name.
    b. start-date (also for single dates)
    c. end-date (empty in case of single dates)
    d. duration (for events without a fixed enddate)
    e. fields for conditional relations between events (e.g. for project-gantt-charts)
    f. eventually further fields for contitioning or grouping.
    In case of a Project-Gantt chart, start- and end-date could also be defined to contain a link to a related note, thus representing the conditionality between those events. But that's to the creator of the plugin to decide.
  6. And I shamefully admit that I originally posted this as a dataview feature request (the link to which is in my previous post). But I don't see this will be realized there soon, and admit it would imply using an external library like markwhen (oh yeah!), which I doubt, the developer would consider, if there is a better option for users.
  7. And it could also have been a request to the db folder plugin.

@jayambede
Copy link

@quinn-p-mchugh
What you are describing is exactly, what I was thinking of. A similar approach seems to me the base of the db-folder-plugin, though with a different purpose. Maybe the dataview aggregation part can be found somewhere in there (since it is open source).
The intermediary transformation script certainly is the tricky part, considering that markwhen would serve as the rendering part.
In respect to the dataview API, there should be a secure way to backward compatibility, since the author, blacksmithgu, is currently working on an overhaul of dataview towards a new "datacore"- plugin, which would require such a maintenance channel.
I know that the different uses of timelines would require a number of different queries, but these could imho handled by different triggers in the query, directing to different threads of the intermediary script (but, I am no programmer, so this is way over my head ...).

I do very well understand, though, that a plugin that omits the things I was describing, for the time being is the easier and faster project. And I am grateful that at least someone is up to the challenge. But to me that only is an intermediate goal, for it requires much handywork for each timeline, which is one of the reasons I am not using the existing obsidian-timeline Plugins.

Thanks for your hard work!!

@jayambede
Copy link

@kochrt
If there is a problem with the backtick-syntax, there is even more reason to "wrap" the markwhen-part into a plugin with a query syntax in Obsidian. Two reasons:

  1. I do very well understand why you are insisting on the .mw extension. But displaying such files in Obsidian "seamlessly" would require Obsidian to "recognize" them, which I doubt, the obsidian team would add to the Obsidian code. They are very protective, when it comes to the used filetypes .
    So insisting on the .mw extension would not help in this respect (though I really, really understand the reasons!)

  2. Other Obsidian plugins, e.g. the Kanban-plugin, work on .md files, in which a YAML-field designates them as files to be interpreted by (e.g.) the Kanban-Plugin.
    In case of markwhen, this could be accomplished by such a process: (a) place a markwhen-field in the frontmatter (maybe even with some more fields containing information concerning name or the rendering of the timeline), (b) adding the markwhen code after the frontmatter.

This is the common way to handle this in Obsidian.

Moreover, this would certainly work, but (though it makes sense for the kanban plugin) would still pose the question, if you have to "wrap" it anyway in an .md file, why not make the plugin in a way that you can display a timeline in a codeblock limited by backticks in any note?

Sorry, if I have overruled your request of opening a new issue with this post, but I just couldn't help it ... I can still do that (though not today), and pull over my part of the discussion for a beginning ...

Anyway: Thanks a lot for making this possible!!

@quinn-p-mchugh
Copy link

quinn-p-mchugh commented Apr 21, 2023

I wouldn't recommend the triple backtick syntax to try to embed into a markdown document. While code blocks aren't supported in markwhen yet, I think they will be eventually, and even in the meantime backticks are not illegal in markwhen, so you could have difficulty determining where markwhen ends and markdown begins.

Good point @kochrt - thanks for mentioning. Will have to do some more thinking on this to prevent future conflicts with Markwhen codeblock support.

@kochrt The expectation is that markwhen documents are their own files (with the .mw file extension).

@jayambede But displaying such files in Obsidian "seamlessly" would require Obsidian to "recognize" them, which I doubt, the obsidian team would add to the Obsidian code. They are very protective, when it comes to the used filetypes .
So insisting on the .mw extension would not help in this respect (though I really, really understand the reasons!)

Fortunately, supporting .mw files inside Obsidian would not require support from the Obsidian team. See here: Text-based file formats | Obsidian Plugin Developer Docs

I do like the idea of supporting .mw files inside of Obsidian (instead of adding support for Markwhen code within codeblocks). Though, this is based on the assumption that .mw files would be able to be embedded within Obsidian notes. Currently, I don't have a good sense for (1) if this is possible and (2) the magnitude of effort required.

In my case, I'd to be able to view Markwhen timelines inside an Obsidian note - whether that's achieved by writing Markwhen code inside a codeblock or an embedded .mw file is less important.

@Friedolito
Copy link

Just came across your conversation. If you could get markwhen working in obsidian, it would be incredible awesome!!! 🤯 :D

@quinn-p-mchugh
Copy link

Hey folks - quick update here. I haven't really done anything with the prototype Obsidian plugin since early April. Please feel free to fork if you have time to help develop.

@FeralFlora
Copy link

What is the status of the plugin as is?

@quinn-p-mchugh
Copy link

quinn-p-mchugh commented Aug 7, 2023

@MSBack Just a couple lines of code written. See commit history here.

@Acylation
Copy link

I'd like to help with the Obsidian API. *.mw files can be regocnized if the plugin registers the extension. And all we need to do are

  • Build a cutom view to render the file 'as is'
  • Provide a embed renderer to support ![[*.mw]] syntax and render them in the note. The embed could either be interactive or just a snapshot of the view

The excalidraw plugin of obsidian could be a good reference. https://github.com/zsviczian/obsidian-excalidraw-plugin

@quinn-p-mchugh
Copy link

quinn-p-mchugh commented Aug 8, 2023

Thanks @Acylation!

Please see these comments some relevant resources and commentary:

Specifically:

You can do what you're describing and it's actually relatively straightforward (if a bit heavy-handed). The html for the timeline view you can get from @markwhen/timeline (don't mind the readme, I haven't updated it).

You can append a script tag in the head with the parsed markwhen, like the CLI does, that will give you the html that you can provide to obsidian to render. I'd say it's a good place to start.

@FeralFlora
Copy link

The excalidraw plugin of obsidian could be a good reference. https://github.com/zsviczian/obsidian-excalidraw-plugin

The Dataloom plugin (previously called Notion-like tables) might also be useful as a reference. It adds a .loom filetype (tables), and you can embed and resize them using the `![[some_table.loom]] syntax.

@Acylation
Copy link

Thanks for the suggestion @MSBack ! I will check them out.

@quinn-p-mchugh Thanks for the info, I will go through the comments carefully. I checked your prototype and decided to create a new one, because your repo is a fork of the sample plugin template (which means your fork is also a template) rather than a plugin repo based on the template. Nevertheless thanks for your efforts on calling the mw package!

image

Also, Obsidian have published the official developer doc mostly based on marcus.se.net. The link above is redirected, and the tutorial is not included in the official one. To access the tutorial, check here https://github.com/marcusolsson/obsidian-plugin-docs/blob/2b61554e995560036b1789648f46379b76664e3b/docs/tutorials/text-based-file-formats.md#L4

@quinn-p-mchugh
Copy link

I checked your prototype and decided to create a new one, because your repo is a fork of the sample plugin template (which means your fork is also a template) rather than a plugin repo based on the template.

Sounds good to me. Thanks! 👍

In response to some of the thoughts shared above:

FWIW, I'm a fan of Obsidian Projects design philosophy. I love that the Excalidraw plugin provides the ability to auto-export drawing files in the standard Excalidraw format, which means that if the Exalidraw plugin dies, I can still use the drawings. I think it'd be worthwhile to adopt a similar sort of philosophy for creating the proposed Markwhen plugin.

@Fleker
Copy link

Fleker commented Mar 26, 2024

Hey folks, I hope this project hasn't been dropped. I have quickly become a fan of using Markwhen to plan out different trips and having it synchronize with my Obsidian vault would definitely help keep things organized.

@AbyssalSoda
Copy link

I second that just came here after searching for similar timeline functionality and integration.

@crimson-med
Copy link

Hey! Is anyone working on this? If yes is there a dedicated repo for the plugin or branch or list of tasks? happy to work on some tasks.

@Acylation
Copy link

Acylation commented Apr 4, 2024

@crimson-med you may check out my repo here. https://github.com/Acylation/obsidian-markwhen

I’m iterating through multiple projects and this is postponed for a while. Unlike the VSCode plugin that provides a webview, Obsidian prefers a standalone component that not yet implemented by markwhen.

Current workaround aims to host markwhen locally, and we want to interact with it via iframe or similar methods. Some information are recorded in discord subtopic.

Another worry is on the text format. We need to implement our own lsp or register markwhen as plain text to allow markwhen file being recognized or display properly by Obsidian text editor.

I’m dealing with my thesis lately and not sure when can I come back to solve some heavy tasks. But please don’t hesitate to reach out if you need help in Obsidian api and repo stuffs. I’m active in these basic affairs.

@kochrt kochrt pinned this issue Apr 4, 2024
@kochrt
Copy link
Member Author

kochrt commented Apr 4, 2024

@crimson-med also look at kochrt/obsidian-markwhen, I attempted to make some progress but I don't know/remember how successful I was (mostly in MarkwhenView.ts)

@kochrt
Copy link
Member Author

kochrt commented Apr 28, 2024

https://github.com/mark-when/obsidian-plugin is the new repo for the obsidian plugin. You can try it out manually by downloading the latest release and dropping the files in your .obsidian/plugins folder.

There's a lot that's wrong with it but it gets the basics done.

Someone feel free to submit the plugin for review, I haven't done that. Just make sure no one else is trying to submit it before you do.

@Acylation
Copy link

Someone feel free to submit the plugin for review

I'll do. Before that we need to update the docs, manifests, releases and other repo stuffs.

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