An open-source library to help with creating expandable text

Overview

🔭 Telescopic Text

An open-source library to help with creating expandable text.

Inspired by StretchText and TelescopicText.

I've been thinking a lot about creating a browsable store of knowledge that provides something useful at all distance scales (e.g. viewing the entire library, just a subcategory, a single file, etc.) and concepts like Telescopic Text are a first step in creating more information scales than just a single document level.

This library is meant to be the start for anyone to create telescopic text, including those who are non-technical.

Creating a telescopic text

To create some telescopic text, you can use your favorite note-taking app or text editor that supports bullet lists and start by writing a full sentence or two in a starting bullet:

* Texts are boundless shapeshifters, zealous freedom fighters, sacred holders of space

At any point, you can break up the full sentence into separate lines. Bullets at the same indentation level are combined into the same sentence, and any indented bullets will be used as an expansion point for the parent bullet. By default, items on the same indentation level will be combined with a space , but you can pass in a custom separator into the parsing function.

* Texts
  * Clear notes
* are boundless shapeshifters,
  * are limitless shapeshifters,
* zealous freedom fighters, sacred holders of space 

The above example would yield the following text: "Texts are boundless shapeshifters, zealous freedom fighters, sacred holders of space" where "Texts" is expandable into "Clear notes" and "are boundless shapeshifters" is expandable into "are limitless shapeshifters".

NOTE: the parsing logic is robust to different indentation levels, but for most compatible experience, you should normalize the indentations so that each nested bullet is differentiated by a standard set of spaces. We also currently only support *, -, and + bullet indicators.

Usage

Create some expandable text using the bullet list format shown above. You can then test out how your poem looks and feels and get a basic code snippet that recreates it using the test bed!

See the full instructions below:

You can load it directly via CDN as follows: Put this anywhere inside the head of your HTML file.

">
<head>
  ...
  <script src="https://unpkg.com/telescopic-text/lib/index.js">script>
  <link href="https://unpkg.com/telescopic-text/lib/index.css" rel="stylesheet">
head>

or if you prefer to do the manual way, you can include the lib/index.js and lib/index.css files in your project.

The package exports a function called createTelescopicTextFromBulletedList that parses a bulleted list and returns a HTMLNode with your telescopic text inside.

Basic usage may look something like this:

">
<head>
    <script src="https://unpkg.com/telescopic-text/lib/index.js">script>
    <link href="https://unpkg.com/telescopic-text/lib/index.css" rel="stylesheet">
head>
<body>
  <div id="text-container">div>

  <script>
      const content = `
  * I 
    * Yawning, I
  * made tea`;
      const node = createTelescopicTextFromBulletedList(content);
      const container = document.getElementById("text-container");
      container.appendChild(node);
  script>
body>

You can check out a more detailed example in demo/index.html

Types

interface Content {
  text: string          // Original string content in the line
  replacements: Line[]  // Sections of the original text to replace/expand
}

interface Line {
  og: string           // the original string to replace
  new: string          // the replacement string
  replacements: Line[] // nested replacements to apply on the resultant line afterwards
}

// Default function to create a new `
   
` node containing the // telescoping text from bullet points function createTelescopicTextFromBulletedList(content: string) // This is the fundamental data structure for parsing native bullet lists into telescoping text. interface NewContent { text: string; expansions?: NewContent[]; // This is always a space right now, but could be extended to use any // separator between content. separator?: string; }

Future Work

  • Supporting infinite expansion with ...
  • Concept of shapeshifting text in general... these are not always expansions.
Comments
  • add optional text expansion on mouseover

    add optional text expansion on mouseover

    This PR introduces a boolean flag that can be passed to createTelescopicTextFromBulletedList, false by default, that turns on the ability to expand text when the text is moused over. Notably, the text is not expanded recursively when moused over; we use a very short time delay to ensure this doesn't happen

    (if there is a better way to do this, let me know! this might be dependent on browser performance)

    Usage is fairly self-explanatory, but please let me know if and how you'd like it to be documented! Happy to add a demo as well if you'd like - please try it out!

    opened by jakeisnt 6
  • add local test file and support html parsing

    add local test file and support html parsing

    Add textMode parameter which has text as the default param and uses normal behavior and offers html for custom HTML to give control to the end-user on how to render things and interact.

    Also added a local-test.html file for local testing that is set up to pull from the locally built lib. Imagining we can add a list of both examples and test cases for new functionality there

    https://user-images.githubusercontent.com/14796580/156900586-91f37114-2fa6-43fb-a1c1-f7ba6b1fae2d.mov

    opened by spencerc99 2
  • Support special character handling as optional

    Support special character handling as optional "expansions"

    similar to how markdown has different flavor expansions, we could support different special character handling extensions.

    current ideas:

    • @Q at beginning toggles block quote styling
    • ... at the end of a text leaf node enables infinite expansion
    • ... what else?
    opened by spencerc99 1
  • WCAG Accessibility

    WCAG Accessibility

    Thank you for the wonderful script! I've wanted to do something with telescopic text for ages, but it wasn't so easy to implement before this.

    Is anybody up for collaborating on making this plugin WCAG accessible? I might need some help navigating the JS side but am happy to do any research/translation needed on the accessibility requirements and test things out.

    From what I gather: the script currently renders a bunch of <span> elements for links instead of <a> with descriptive titles. I wonder if it could also be more semantic by rendering nested <ul> elements (mirroring the semantic meaningfulness of the editor syntax!), and then just using CSS to preserve "inline text" formatting.

    Here's a WCAG checklist that I started to look through. Some of the key issues I found are:

    • Lack of keyboard navigation
    • Non-semantic elements, e.g. links are currently <span> instead <a>
      • Missing link descriptions (could say something like "expands so-and-so..."?)
    opened by caseyg 2
  • expand text alongside existing text without replacing it

    expand text alongside existing text without replacing it

    ie, expand

    *a
        *b
           *c
    

    to a -> a b -> a b c

    instead of a -> b -> c

    this should be local syntax rather than a global configuration option - using '+' as a bullet point to express this feels fitting:

    * a
      + b
         + c
    
    opened by jakeisnt 0
  • Support unexpanding text

    Support unexpanding text

    Should be able to export unexpanding text. Maybe holding alt/option shows borders around telescopic groups on hover and upon clicking with alt/option held down it unexpands text.

    opened by spencerc99 4
Releases(v1.2.4)
  • v1.2.4(Mar 16, 2022)

    What's Changed

    • fix html bug for the base line text and support diff spacing bullet list inputs by @spencerc99 in https://github.com/jackyzha0/telescopic-text/pull/9
    • Add rich text support by @jackyzha0 in https://github.com/jackyzha0/telescopic-text/pull/11

    Full Changelog: https://github.com/jackyzha0/telescopic-text/compare/v1.2.2...v1.2.4

    Source code(tar.gz)
    Source code(zip)
  • v1.2.2(Mar 8, 2022)

    • add html container tag de112f5
    • add local test file and support html feba96b

    https://github.com/jackyzha0/telescopic-text/compare/v1.2.1...v1.2.2

    Source code(tar.gz)
    Source code(zip)
  • v1.2.1(Feb 26, 2022)

    https://github.com/jackyzha0/telescopic-text/compare/v1.2.1...v1.2.0

    What's Changed

    • add optional text expansion on mouseover by @jakeisnt in https://github.com/jackyzha0/telescopic-text/pull/1

    New Contributors

    • @jakeisnt made their first contribution in https://github.com/jackyzha0/telescopic-text/pull/1 !!

    Full Changelog: https://github.com/jackyzha0/telescopic-text/compare/v1.2.0...v1.2.1

    Source code(tar.gz)
    Source code(zip)
  • v1.2.0(Feb 14, 2022)

  • v1.1.2(Feb 14, 2022)

    • readme bump on badge f82d64b
    • oops use the actual library 781adfc
    • doc strings! and simplify library usage 98f33c0

    https://github.com/jackyzha0/telescopic-text/compare/v1.1.1...v1.1.2

    Source code(tar.gz)
    Source code(zip)
  • v1.1.1(Feb 14, 2022)

  • v1.0.2(Feb 11, 2022)

  • v1.0.1(Feb 11, 2022)

Owner
Jacky Zhao
writes code, words, and sometimes climbs rocks
Jacky Zhao
Reference for How to Write an Open Source JavaScript Library - https://egghead.io/series/how-to-write-an-open-source-javascript-library

Reference for How to Write an Open Source JavaScript Library The purpose of this document is to serve as a reference for: How to Write an Open Source

Sarbbottam Bandyopadhyay 175 Dec 24, 2022
An Open-Source Platform to certify open-source projects.

OC-Frontend This includes the frontend for Open-Certs. ?? After seeing so many open-source projects being monetized ?? without giving any recognition

Open Certs 15 Oct 23, 2022
Shikhar 4 Oct 9, 2022
This is a project for open source enthusiast who want to contribute to open source in this hacktoberfest 2022. 💻 🎯🚀

HACKTOBERFEST-2022-GDSC-IET-LUCKNOW Beginner-Hacktoberfest Need Your first pr for hacktoberfest 2k22 ? come on in About Participate in Hacktoberfest b

null 8 Oct 29, 2022
There can be more than Notion and Miro. Affine is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

AFFiNE.PRO The Next-Gen Knowledge Base to Replace Notion & Miro. Planning, Sorting and Creating all Together. Open-source, Privacy-First, and Free to

Toeverything 12.1k Jan 9, 2023
Incredible resources (with links) to help up-skill yourselves on various fields. Resources like programming, designing, engineering and much more and completely Open Source.

Shiryoku Incredible resources (with links) to help up-skill yourselves on various fields. Resources like programming, designing, engineering and much

Kunal Keshan 22 Dec 15, 2022
A lightweight JavaScript library that renders text in a brilliant style by displaying strings of random characters before the actual text.

cryptoWriter.js A lightweight javascript library which creates brilliant text animation by rendering strings of random characters before the actual te

Keshav Bajaj 2 Sep 13, 2022
Omnivore - a complete, open source read-it-later solution for people who like text

Omnivore Omnivore is a complete, open source read-it-later solution for people who like text. We built Omnivore because we love reading and we want it

Omnivore 597 Jan 1, 2023
Calculator Notepad is an open source, free-form text calculator, Chrome extension.

Calculator Notepad Calculator Notepad is an open source, free-form text calculator, Chrome extension. Installation Download and uncompress zip. In Chr

null 3 Mar 26, 2022
Simple format that serves it's one and only purpose and that's creating simple task list everywhere where you can write plain text

SWTF (Simple Worklog Task Format) Simple format that serves it's one and only purpose and that's creating simple task list everywhere where you can wr

null 4 Apr 4, 2022
Twitter Text Libraries. This code is used at Twitter to tokenize and parse text to meet the expectations for what can be used on the platform.

twitter-text This repository is a collection of libraries and conformance tests to standardize parsing of Tweet text. It synchronizes development, tes

Twitter 2.9k Jan 8, 2023
Obsidian text generator Plugin Text generator using GPT-3 (OpenAI)

is a handy plugin for Obsidian that helps you generate text content using the powerful language model GP

null 356 Dec 29, 2022
Obsidian plugin: Type text shortcuts that expand into javascript generated text.

Obsidian Plugin - Text Expander JS (open beta) This Obsidian plugin allows the user to type text shortcuts that are replaced by (or "expanded into") j

Jon Heard 79 Dec 27, 2022
Easiest 1-click way to install and use Stable Diffusion on your own computer. Provides a browser UI for generating images from text prompts and images. Just enter your text prompt, and see the generated image.

Stable Diffusion UI Easiest way to install and use Stable Diffusion on your own computer. No dependencies or technical knowledge required. 1-click ins

null 3.5k Dec 30, 2022
A recreation of a startpage posted on Reddit without the source, so I rewrote it in Next.js + Tailwind for the open source community.

Startpage "Figma Balls" Rewrite Why Did I Make This I saw a startpage posted on the subreddit r/startpages that I thought looked nice, but when I look

Thomas Leon Highbaugh 5 Mar 29, 2022
Let's participate in Hacktoberfest and contribute to open-source. Star the repo and open a PR to get accepted.

Let's Contribute To Open-source First Contributions This project aims to simplify and guide the way, beginners can make their first contribution towar

Ehmad Saeedâš¡ 5 Dec 3, 2022
This package will help parse OData strings (only the Microsoft Dataverse subset). It can be used as a validator, or you can build some javascript library which consumes the output of this library.

@albanian-xrm/dataverse-odata This package will help parse OData strings (only the Microsoft Dataverse subset). It can be used as a validator, or you

AlbanianXrm 3 Oct 22, 2022
Obsidian plugin to open a note of your choice when creating a new tab, like in the browser.

New Tab Default Page Obsidian plugin to open a note of your choice when creating a new tab, like in the browser. Usage Set the note to open in new tab

pseudometa 20 Dec 27, 2022