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

Prepare initial release #1

Closed
5 tasks done
paulrobertlloyd opened this issue Mar 28, 2023 · 11 comments
Closed
5 tasks done

Prepare initial release #1

paulrobertlloyd opened this issue Mar 28, 2023 · 11 comments

Comments

@paulrobertlloyd
Copy link
Owner

paulrobertlloyd commented Mar 28, 2023

Following Cédric Aellen’s initial idea, a plugin for markdown-it that converts handles into links to user profile pages.

For example, given this Markdown:

@paulrobertlloyd@micro.blog, @paulrobertlloyd@twitter.com and @paulrobertlloyd@mastodon.social.

using this plugin will generate the following HTML markup (lines wrapped for clarity):

<p>
  <a href="https://micro.blog/paulrobertlloyd" rel="external">@paulrobertlloyd</a>,
  <a href="https://twitter.com/paulrobertlloyd" rel="external">@paulrobertlloyd</a> and
  <a href="https://mastodon.social/@paulrobertlloyd" rel="external">@paulrobertlloyd</a>.
</p>

Currently there are 2 options; you can change the link behaviour for given hosts (i.e Flickr username URLs don’t use the @ symbol, but are proceeded by /photos/), and the attributes used on the link (for example, class, rel, etc.) can be altered. Need to think how these are handled; do options override defaults, or get merged with them? That said, let’s not overthink this!

@alienlebarge - you’ve inspired me! Do you want to give this a try on your site (and would you like to contribute to this project?)

To do

  • Consider plugin options, and how user options are combined with defaults
  • Test on a website
  • Add more tests
  • Complete test coverage
  • Documentation
@alienlebarge
Copy link
Contributor

Thanks for the mention and the offer to collaborate.
I may try it out tonight.

@paulrobertlloyd
Copy link
Owner Author

Fixed a pretty gnarly bug (no text would be output in bare text strings!), have now got full test coverage, added a number of different tests, and written up some documentation.

Take a look and let me know if this all makes sense, and that I’ve covered everything!

@paulrobertlloyd
Copy link
Owner Author

paulrobertlloyd commented Mar 29, 2023

Baring any other issues, looks like this package is ready to be published. Two questions:

  1. Would you like to be add to the contributors field in package.json? If so, with what details?

  2. What do you think to the name of this package? I note your function was called socialHandle, maybe it should be that? Here are some options I’ve considered:

    • markdown-it-social-mention
    • markdown-it-federated-mention
    • markdown-it-handle
    • markdown-it-social-handle
    • markdown-it-user-handle
    • markdown-it-username-handle
    • markdown-it-account-handle

    Including ‘handle’ is perhaps a better option. I don’t know if there’s a more specific name for the @username@host format. Mentions may happen as a result of using this plugin, but not necessarily, so maybe that shouldn’t be included in the name?

@paulrobertlloyd
Copy link
Owner Author

Nope… found another bug… need to add some more tests for strings that contain links, but not with a matching string.

@paulrobertlloyd
Copy link
Owner Author

Fixed!

@alienlebarge
Copy link
Contributor

  1. Would you like to be add to the contributors field in package.json? If so, with what details?

Nope thanks. You are the personne who does the job ;)

  1. What do you think to the name of this package? I note your function was called socialHandle, maybe it should be that? Here are some options I’ve considered:
  • markdown-it-social-mention
  • markdown-it-federated-mention
  • markdown-it-handle
  • markdown-it-social-handle
  • markdown-it-user-handle
  • markdown-it-username-handle
  • markdown-it-account-handle

Including ‘handle’ is perhaps a better option. I don’t know if there’s a more specific name for the @username@host format. Mentions may happen as a result of using this plugin, but not necessarily, so maybe that shouldn’t be included in the name?

I agree with you.
For me, the mention is the whole post: the handle and the content.

I have done some researche and "handle" seems to be the most common word to describe @username@host.

As this plugin converts the handle and not the mention, using the word "handle" in the name seems more appropriate than "mention".
I won't use the word social. The site is not always a social network. Vimeo (user@vimeo.com) is not really a social network.

For me markdown-it-user-handle and markdown-it-username-handle are the two best one.

@alienlebarge
Copy link
Contributor

I get errors with the plugin. Apparently it's due to something in the markdown's front matter.
alienlebarge/alienlebargech-v3#178

@paulrobertlloyd
Copy link
Owner Author

I’ve added an additional check for children before checking for children[0].type, which may fix this.

Also note I’ve updated the package name to markdown-it-handle.

@alienlebarge
Copy link
Contributor

I’ve added an additional check for children before checking for children[0].type, which may fix this.

Nice !
Sadly, I have updated the plugin but still get the error. Will investigate when I get time

Also note I’ve updated the package name to markdown-it-handle.

👌 perfect

@alienlebarge
Copy link
Contributor

I Found the problem alienlebarge/alienlebargech-v3#178 (comment)

Everything is ok for me now 😅

@paulrobertlloyd
Copy link
Owner Author

Released!

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

2 participants