Fork of Scribe - an alternative Medium frontend
Find a file
Edward Loveall 09995cde5c
Overlapping refactor
Example:

* Text: "strong and emphasized only"
* Markups:
  * Strong: 0..10
  * Emphasis: 7..21

First, get all the borders of the markups, including the start (0) and
end (text.size) indexes of the text in order:

```
[0, 7, 10, 21, 26]
```

Then attach markups to each range. Note that the ranges are exclusive;
they don't include the final number:

* 0...7: Strong
* 7...10: Strong, Emphasized
* 10...21: Emphasized
* 21...26: N/A

Bundle each range and it's related markups into a value object
RangeWithMarkup and return the list.

Loop through that list and recursively apply each markup to each
segment of text:

* Apply a `Strong` markup to the text "strong "
* Apply a `Strong` markup to the text "and"
  * Wrap that in an `Emphasis` markup
* Apply an `Emphasis` markup to the text " emphasized"
* Leave the text " only" as is

---

This has the side effect of breaking up the nodes more than they need
to be broken up. For example right now the algorithm creates this HTML:

```
<strong>strong </strong><em><strong>and</strong></em>
```

instead of:

```
<strong>strong <em>and</em></strong>
```

But that's a task for another day.
2021-08-08 15:08:43 -04:00
.github/workflows Initial app 2021-05-01 17:03:38 -04:00
config Add basic response (except images) 2021-05-01 17:39:05 -04:00
db/migrations Initial app 2021-05-01 17:03:38 -04:00
public Initial app 2021-05-01 17:03:38 -04:00
script Add test script 2021-07-04 16:03:25 -04:00
spec Overlapping refactor 2021-08-08 15:08:43 -04:00
src Overlapping refactor 2021-08-08 15:08:43 -04:00
tasks Initial app 2021-05-01 17:03:38 -04:00
.crystal-version Initial app 2021-05-01 17:03:38 -04:00
.editorconfig Initial app 2021-05-01 17:03:38 -04:00
.gitignore Add .nova to gitignore 2021-08-08 14:22:34 -04:00
.tool-versions Initial app 2021-05-01 17:03:38 -04:00
bs-config.js Initial app 2021-05-01 17:03:38 -04:00
package.json Initial app 2021-05-01 17:03:38 -04:00
Procfile Initial app 2021-05-01 17:03:38 -04:00
Procfile.dev Initial app 2021-05-01 17:03:38 -04:00
README.md Initial app 2021-05-01 17:03:38 -04:00
shard.lock Initial app 2021-05-01 17:03:38 -04:00
shard.yml First step rendering a page 2021-07-04 16:28:03 -04:00
tasks.cr Initial app 2021-05-01 17:03:38 -04:00
webpack.mix.js Initial app 2021-05-01 17:03:38 -04:00
yarn.lock Initial app 2021-05-01 17:03:38 -04:00

scribe

This is a project written using Lucky. Enjoy!

Setting up the project

  1. Install required dependencies
  2. Update database settings in config/database.cr
  3. Run script/setup
  4. Run lucky dev to start the app

Learning Lucky

Lucky uses the Crystal programming language. You can learn about Lucky from the Lucky Guides.