Skip to content

Commit

Permalink
fix merge conf
Browse files Browse the repository at this point in the history
  • Loading branch information
jackyzha0 committed Feb 14, 2022
2 parents 5d1d09a + 298408f commit 85a5db2
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 31 deletions.
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,27 @@ I've been thinking a lot about creating a browsable store of knowledge that prov
(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 still a little sensitive to indentation of the bullets, so for most compatible experience, you should normalize the indentations so that each nested bullet is differentiated by one space.

## Usage
You can load it directly using a CDN as follows

Expand Down Expand Up @@ -59,4 +80,17 @@ interface Line {
// Default function to create a new `<div>` node containing the
// telescoping text.
function createTelescopicText(content: Content[])
```

// 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;
}
```

## Expansion Ideas
- supporting infinite expansion with `...`?
- concept of shapeshifting text in general.. these are not always expansions.
8 changes: 1 addition & 7 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,8 @@ interface TelescopeNode {
depth: number;
telescopicOut: TelescopicOutput;
}
declare function hydrate(line: Content, node: any): void;
declare function _hydrate(line: Content, node: any): void;
declare function createTelescopicText(content: Content[]): HTMLDivElement;
/**
* Parses the input string and returns the output as a structured data format.
*
* @param mdContent full string of markdown content that is formatted as a unorederd bulleted list
* @returns
*/
declare function parseMarkdown(mdContent: string): TelescopicOutput;
declare function parseOutputIntoContent(output: TelescopicOutput, separator?: string): Content;
declare function parseMarkdownIntoContent(mdContent: string, separator?: string): Content;
17 changes: 5 additions & 12 deletions lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 6 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,11 @@ function _hydrate(line: Content, node: any) {
function createTelescopicText(content: Content[]) {
const letter = document.createElement("div");
letter.id = "telescope";
content
.forEach((line) => {
const newNode = document.createElement("p");

// hydrate new p tag with content
_hydrate(line, newNode);

letter.appendChild(newNode);
});
content.forEach((line) => {
const newNode = document.createElement("p");
_hydrate(line, newNode);
letter.appendChild(newNode);
});
return letter;
}

Expand Down Expand Up @@ -214,4 +210,4 @@ function parseMarkdownIntoContent(
): Content {
const output = parseMarkdown(mdContent);
return parseOutputIntoContent(output, separator);
}
}

0 comments on commit 85a5db2

Please sign in to comment.