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

sources.markdown: add extract_from_text helper #234

Merged
merged 1 commit into from
Apr 20, 2021

Conversation

seanbreckenridge
Copy link
Contributor

related #233

even if the strategy of converting markdown into HTML on the backend
isn't merged, can see this being useful for other people
writing their own sources for promnesia (e.g. me, for my discord module)

@seanbreckenridge
Copy link
Contributor Author

seanbreckenridge commented Apr 20, 2021

Have integrated this with the sources.github as well, but not sure if you wanted to merge that here, or if you wanted to do something to render it in JS instead

As an example:

This random comment from HPI renders like this in the sidebar when converted from markdown to HTML:

Also worth mentioning that the <pre> blocks break the horizontal scrolling

image)

@seanbreckenridge
Copy link
Contributor Author

Wasnt sure where to add tests for this, so just to show it works;

In [1]: from promnesia.sources.markdown import extract_from_text

In [2]: import itertools

In [4]: import my.github.all
In [5]: for x in itertools.islice(my.github.all.events(),3):
   ...:     if x.body is not None:
   ...:         for url in extract_from_text(x.body):
   ...:             print(url)
   ...:
Parsed(url='https://github.com/seanbreckenridge/dotfiles/commit/4c57fd97cbb2605e63d0cf5d2af37039fe6e6d35', context='!html <p>Note: This is used for <a href="https://github.com/seanbreckenridge/dotfiles/commit/4c57fd97cbb2605e63d0cf5d2af37039fe6e6d35">gitopen</a></p>\n')

@karlicoss
Copy link
Owner

karlicoss commented Apr 20, 2021

Nice, thanks!

Also worth mentioning that the pre blocks break the horizontal scrolling

Ah yeah -- I guess what I meant 'something like pre' -- it should be tweakable with an ad-hoc style maybe like nowrap or something like that.

@karlicoss karlicoss merged commit 08bd031 into karlicoss:master Apr 20, 2021
@seanbreckenridge seanbreckenridge deleted the markdown-text branch April 20, 2021 08:41
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

Successfully merging this pull request may close these issues.

2 participants