Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content
Snip-python documentation
Light Logo Dark Logo
Snip-python documentation
  • Quickstart
  • Command Line Interface (CLI)
    • Token Management
    • Snippets
  • Snippets
    • Image Snippet Guide
    • Text Snippet Guide
    • Combining different snippets
    • Link Snippet Guide
  • Access Tokens
  • WebApi Wrapper
    • Book Endpoints
    • Account Endpoints
  • Reference
    • snip.token
      • snip.token.storage
        • snip.token.storage.file_store
        • snip.token.storage.keyring_store
      • snip.token.token
        • snip.token.token.AccountToken
        • snip.token.token.BookToken
        • snip.token.token.Token
    • snip.snippets
      • snip.snippets.array
        • snip.snippets.array.ArraySnip
      • snip.snippets.base
        • snip.snippets.base.BaseSnip
      • snip.snippets.factory
      • snip.snippets.image
        • snip.snippets.image.ImageSnip
      • snip.snippets.link
        • snip.snippets.link.IconStyle
        • snip.snippets.link.LinkSnip
      • snip.snippets.text
        • snip.snippets.text.TextSnip
        • snip.snippets.text.TextStyles
    • snip.api
      • snip.api.account
        • snip.api.account.Group
        • snip.api.account.GroupMember
        • snip.api.account.MemberRoleUpdate
      • snip.api.books
        • snip.api.books.BasePermissionTypedDict
        • snip.api.books.BookTypedDict
        • snip.api.books.GroupPermissionTypedDict
        • snip.api.books.UserPermissionTypedDict
      • snip.api.exceptions
      • snip.api.request
      • snip.api.schemas
      • snip.api.snippets
      • snip.api.token
        • snip.api.token.TokenMetadata
Back to top
View this page

Link Snippet Guide¶

Links allow you as the name already suggests to reference external resources or websites in your notebook. This can be helpful to provide additional information or to give credit to the original source of a dataset or image.

This guide expects you have a basic understanding of text and or image snippets.

Constructing a Link¶

To create a link you need two parts, for once the a snippet (text, image, etc.) that will be displayed in the notebook and the actual link that will be opened when the user clicks on the snippet.

Let’s assume we have a simple text snippet that should be displayed in the notebook and a link that should be opened when the user clicks on the snippet.

from snip.snippets import LinkSnip, TextSnip

text = "Hello, reference!"
text_snip = TextSnip(text)
link_snip = LinkSnip(text_snip, "https://example.com")
link_snip.x = 100
link_snip.y = 200
link_snip
../_images/75567e08c465ec55b41bd7102f88a947f55803e6ebab302eb6f8214158d1a7ff.png

If you want to modify the inner snip i.e. the text in this example, you may access it with the .inner property.

link_snip.inner.text = "Hello, updated reference!"
link_snip.inner.font_size = 50
link_snip
../_images/573a8a17825731d203b838e593bfae88cf4e4cefe00c60ef85cb558046373921.png

You can also change the styling of the icon, at the moment we only allow you to change the position of the icon. Allowed positions are

    pos_x: float | Literal["right", "left", "center"]
    pos_y: float | Literal["top", "bottom", "center"]
link_snip.icon_style["pos_x"] = "left"
link_snip.icon_style["pos_y"] = "top"
link_snip
../_images/b485f6078f65359313bdb04897435408790d30aaaf3a2205e957004c9adc5d81.png

To upload the link including the nested snippet you can use the typical upload function.

link_snip.upload(book_id=1)
Next
Access Tokens
Previous
Combining different snippets
Copyright © 2024, Sebastian B. Mohr
On this page
  • Link Snippet Guide
    • Constructing a Link