mirror of
https://git.sr.ht/~edwardloveall/scribe
synced 2026-01-10 03:41:34 +00:00
09995cde5c63fae559d6b988ff8dd5c46e3cca8e
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.
scribe
This is a project written using Lucky. Enjoy!
Setting up the project
- Install required dependencies
- Update database settings in
config/database.cr - Run
script/setup - Run
lucky devto start the app
Learning Lucky
Lucky uses the Crystal programming language. You can learn about Lucky from the Lucky Guides.
Languages
Crystal
83.9%
Nix
8.6%
Shell
4.6%
JavaScript
1.4%
Dockerfile
1%
Other
0.5%