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

Feature request: More customizable output #44

Open
clement-moulin-frier opened this issue Sep 6, 2023 · 14 comments
Open

Feature request: More customizable output #44

clement-moulin-frier opened this issue Sep 6, 2023 · 14 comments

Comments

@clement-moulin-frier
Copy link

clement-moulin-frier commented Sep 6, 2023

Thanks for this app, which is super simple and useful and has no equivalent on the play store!
My use case is the following: I often want to capture a webpage title and url, and some selected content of the page, to share it with a markdown-based note taking app.
The ideal format would be like: [{TITLE}]({URL}) {SOME SELECTED CONTENT}
This is just my personal use case, but I guess other people would like to format the output of markdownr in other different ways.
I think there are different ways to achieve this and that it could really increase the usability of the app. From the simplest solution to more complex (but also more powerful) ones :

Simpler solutions:

  1. Similarly to allow to include or exclude front matter, url in content and excerpt as in the current version of the app, allowing to exclude the markdown translation of the page content would already make it much more flexible for my use case. (I could just include url in content and excerpt, the page title being included by default. With litlle post-editing of the output it will do the job.)
  2. Even better, if the app output could be directly edited within the app, one could just reformat it as needed before sharing it with another app. Of course this could be done in the other app instead, but in my case it does not allow it (or at least not in a usable way).

More complex, but killer solution:

  • Provide a way for the user to specify its own template of desired output. In my use case explained above, the template would be [{TITLE}]({URL}) {SOME SELECTED CONTENT}. This means that markdownr would provide a set of keywords, like those within {.} in my example, that could be arranged in various ways as a template specification. For {SOME SELECTED CONTENT}, one could take advantage on the Android feature to share selected text of a web page, encoded in a url (at least in chrome, not sure if it works in other android browsers). E.g. if I select some text in this web page and share it, I obtain a string like https://github.com/sanzoghenzo/markdownr/issues/new#:~:text=Remember%2C%20contributions%20to%20this%20repository%20should%20follow%20our. (I.e. with the selected text encoded after #:~:text=.)

The complex solution probably requires quite a lot of work, but what is your opinion on the two simpler ones?

Thanks!

@sanzoghenzo
Copy link
Owner

Hi @clement-moulin-frier, I'm glad you find this app helpful!

If you don't mind sharing, what is your target app?

To your points: solution 1 seems feasible, it would be another option to add to the menu and "just another if" (as my colleagues say when they want me to change something in my software 😅). I can give it a try as soon as I have some free time.

As for the point 2: I wanted to keep this app as simple as possible, mainly because android is not my usual/preferred development platform, but also because the apps to which I wanted to send the info already have a text editor in them, so I didn't want to reinvent the wheel.

Regarding the complex version: I like the template idea, that can also replace (and simplify to some extent, but complicate things on another level) the current settings;
the problem I see with the "some selected text" is that it is passed as plain text in the share intent, and that defeats the whole purpose of this tool (to convert html text to markdown).
To get a good result, the tool should find the (unformatted) text inside the downloaded html page and extract only that part. This is not impossible, but at the moment I can't appreciate the time I would spend implementing this feature just to avoid some editing post conversion.

@clement-moulin-frier
Copy link
Author

clement-moulin-frier commented Sep 7, 2023

Hi @sanzoghenzo , thank you for the rapid reply :)

If you don't mind sharing, what is your target app?

Sure, my target app is the mobile version of Roam Research. It is a great (although proprietary) app, but the quick capture mode (using Android sharing) is quite minimal and does not allow for easy editing within the app.

To your points: solution 1 seems feasible, it would be another option to add to the menu and "just another if" (as my colleagues say when they want me to change something in my software 😅). I can give it a try as soon as I have some free time.

This one will already be a huge game changer!

As for the point 2: I wanted to keep this app as simple as possible, mainly because android is not my usual/preferred development platform, but also because the apps to which I wanted to send the info already have a text editor in them, so I didn't want to reinvent the wheel.

I totally understand that, editing should be the responsibility of the target app, not of markdownr (unless it is trivial to add that feature in markdownr, but I understand it is not the case). I should better make a feature request to the target app for this ;)

Regarding the complex version: I like the template idea, that can also replace (and simplify to some extent, but complicate things on another level) the current settings; the problem I see with the "some selected text" is that it is passed as plain text in the share intent, and that defeats the whole purpose of this tool (to convert html text to markdown). To get a good result, the tool should find the (unformatted) text inside the downloaded html page and extract only that part. This is not impossible, but at the moment I can't appreciate the time I would spend implementing this feature just to avoid some editing post conversion.

Indeed, my proposed solution would defeat the original purpose of html to markdown conversion, I didn't think about that. Yet, allowing template specification would still be super useful even without the feature of including selected text (could just be {PAGE CONTENT}instead). In particular, it will allow to format markdownr output as a standard markdown hyperlink with [{TITLE}]({URL}).

I'm sorry I can't help with a PR as I have no knowledge of neither JS or Android development :( (I'm just a humble Python developer). In case you find some time to implement something, I guess the first solution would the easiest and quickest, and would already be a super useful feature. On the other hand, the last solution is obviously the more general and flexible one, but probably requires much more work.

Thanks again!

@clement-moulin-frier
Copy link
Author

Hi @sanzoghenzo ,

Thanks a lot for the PR! As I'm new in using open-source apps on Android, I'm not sur me how to update to new version though. In F-Droid the last version is still 1.4.1.

Do you know if I should just wait that the update becomes available on F-Droid, or is there something else to be done?

Thank you

@sanzoghenzo
Copy link
Owner

I'm sorry, I didn't prepare the release yet (I thought I could add some other refactorings, but it is taking more time than I expected.
I'll do a proper release in a minute, then it will take some time (I still don't know how much) for it to be available in F-Droid...

@clement-moulin-frier
Copy link
Author

Thanks a lot, but no worries if you need more time to include more changes of course

@sanzoghenzo
Copy link
Owner

Hi @clement-moulin-frier,
I just released a fix for this feature, there was a bug (#47) hitting fresh installs.

I'm keeping this issue open to remind me and discuss more about the template solution.

I don't know if it's overkill, but using something like the jinja library allows more flexibility other than a simple replace of placeholders. The question here is: it is needed?

For the UX part, it is imperative to add a "settings" page in which configure the template.
I was thinking of a textbox in which to edit the template, and a list of ready-made templates, mostly to showcase some examples.
Another thing I am dubious about is the ability to save a custom template; I personally use only one style/template to send the article to my note-taking app, so I don't need this feature, but I'm open to suggestions.

(by the way, I'm also mostly a python programmer, but I had to learn other languages in order to survive at work and to create android apps 😅 )

@clement-moulin-frier
Copy link
Author

Hi @sanzoghenzo

Sorry for the late reply, I see your last message just now.
First of all, thanks a lot for having released the fix, this is very useful for my workflow!

The template solution would be great indeed. I think indeed that the ability of save custom templates could be useful, e.g. if the user wants to save different types of webpages in different ways. But this is more a bonus I'd say, being able to specify a single template would be already great.

All the best,

@sh0nuff
Copy link

sh0nuff commented Dec 21, 2023

waves hey guys, I thought I'd comment on this vs opening a new feature request since my needs are very similar to this one.. My target app is Obsidian, and I'd love the ability to set the number of hashtags at the beginning of the text content, or set the format to be title of page.. Right now since there's no way to remove the hash tag from the slug created from the conversion, it's added to any existing note as an H1 heading, aka massive as heck. More hashtags (usually followed by a space before the text) = smaller header, but allowing for the traditional markdown format of square brackets for the link name and round brackets for the url itself would be amazing.

I found a fork for obsidian, but it seems to refer to building the app in flutter and no information on how this would create an apk for installation on Android https://github.com/IAmStoxe/obsidian-markdownr

@sanzoghenzo
Copy link
Owner

Hi @sh0nuff, thanks for sharing your use case.

I found that we don't need templating engines, this little piece of code will suffice! As long as we don't want to perform transformation on the text returned by readability and html2md.

As of now, the available tokens to create the templates are:

  • url
  • title
  • author
  • creationDate: date formattted as yyyy-MM-ddThh:mm:ss
  • excerpt
  • content: the article translated to markdown

I kindly ask you (all of you) to provide me with the templates you need to have to be compatible with your destination applications, so that I can include them as pre-made templates along with the ability to specify a custom template.

I'll start with my preferred output (something similar to what Dendron wants):

---
title: {title}
desc: {excerpt}
created: {creationDate}
source: {url}
author: {author}
stub: false
isDir: false
---
{content}

As per the H1 heading being huge: doesn't Obsidian have the ability to set styles? the size of the texts is CSS responsibility, and starting with something different than a H1 title makes markdown linters angry. This is the equivalent to use Heading3 to style a microsoft word title instead of changing the Heading1 style font in its settings.

@sh0nuff
Copy link

sh0nuff commented Dec 21, 2023

Thanks for replying so quickly! The other fork I posted has a format much more similar to what I would want, but I think I would honestly be happy with something as simple as
[Title](URL)
But if it were possible (I am very green to all things programming language/formatting) I would also appreciate
`Title
Excerpt'
(I am not sure what markdown code would be used to insert a tab before the content, but this would auto nest the excerpt under the previous line.

In regards to the Hashtag, I would prefer to not have one at all, and since I am not savvy with the issue caused by linters (I also just learned that term and went researching!) .. I did find this post that seems to discuss the issue to some degree, at least with github links, but I am not sure if it's applicable here..
Are you saying that there's no way to escape having a single hash at the beginning? It's true that I can use CSS snippets to adjust what various hashes produce, the built in format for all things Obsidian is #(space)H1, ##(space)H2 and so on, so reassigning a single hash to a smaller heading varietal would break a million other plugins and existing notes. I only use a single H1 header in each note, at the top, and have no need for any sort of H format for each URL I share to each note, as I embed them under an H3 "Links" section.

Sorry for my lack of understanding, I am happy to learn!

@sanzoghenzo
Copy link
Owner

sanzoghenzo commented Dec 21, 2023

Sorry, I understand what you (both @sh0nuff and @clement-moulin-frier) are after only now! I never thought about using markdownr output to add to an existing note, I only create new notes and then edit them in my note-taking app, so I just assumed that a title should be inside a H1 as the heading of a page.

That having said, doesn't obsidian already support that? I read from reddit that you can share an url to Obsidian, and it asks to add it to an existing note... Or am I totally wrong?

In any case, once I got the time to implement the templating, what you're asking will be totally possible; you'll just need to use a custom template in the form of [{title}]({url}).

@sh0nuff
Copy link

sh0nuff commented Dec 21, 2023

Sharing a URL to Obsidian .. just does that. A bare url, so I'm still forced to go back into my daily note at the end of the day and go through the laborious task of opening each one and creating a title/text slug for each.

Thanks! Basically my workflow is open link, share link to Markdownr, then share from there to Obsidian in existing note :)

@smaragdus
Copy link

Hello developer,

For me unchecking Include Body option is not useful because I get this:

`# Title

`
while I need just this:

[Title](URL)

As I build lots of lists (articles, programs, web resources) getting just the Title/URL will facilitate my workflow very much.

So my suggesttion is a new option:

which will just extract the title of the webpage plus the URL in Markdown format (no spaces, no new lines, no headers, just Title).

As a workaround when I use Obsidian I have installed Obsidian URL Namer plugin. But as main notes app is not Obsidian I will greatly appreciate if this simple (in my opinion) feature would be added to Markdownr.

Regards

@sanzoghenzo
Copy link
Owner

Hi there,
unfortunately I don't use this tool anymore, so I don't have the need and will to keep maintaining it and adding features.

That may change in the future, but for the time being you would have more luck by forking the project and adding the feature yourself (or ask somebody you know to do it).

Pull requests are still welcome!

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

4 participants