Skip to content

Commit

Permalink
pre: remove extra right whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
earizon committed Dec 16, 2023
1 parent fdeeda5 commit 3381903
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 12 deletions.
7 changes: 5 additions & 2 deletions lightmarkdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function _00_documentCleaning(md, relative_path){
.replaceAll('º[' ,'<' )
.replaceAll(']º' ,'>' )
.replaceAll(/^[-] /mg,'* ' )
.replaceAll(/ $/mg,'<br/>' )
// .replaceAll(/ $/mg,'<br/>' ) <·· Commented.
return md
}

Expand Down Expand Up @@ -87,7 +87,9 @@ function handlePre(p/*aragraph*/) {
return result
})
let result = md_l.join("")
result = result.replaceAll(/[\n]^[^|\n]*[|]/gm,"\n ");
result = result
.replaceAll(/[\n]^[^|\n]*[|]/gm,"\n ")
.replaceAll(/[|]\s*$/gm,"") ;
return result;

}
Expand Down Expand Up @@ -192,6 +194,7 @@ function _01_standardMarkdownParsing(p/*aragraph*/, relative_path){
p = handleLinks(p);
p = handleFontStyles(p);
p = handleBlockQuotes(p);
p = p.replaceAll(/ $/mg,'<br/>' )
return p.length>0 ? "\n<p>"+p+"</p>" : "";
}

Expand Down
47 changes: 37 additions & 10 deletions test.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

# Ordered/Unordered (ul) list mix <!-- { -->

1. Ordered
11. Ordered
11. a <br/>
line continuation.
111. a 111<br/>
Expand All @@ -38,7 +38,7 @@
line continuation a112
12. b
13. c
2. Lists
22. Lists
* a
20. a1
21. a2
Expand Down Expand Up @@ -92,22 +92,49 @@ Non strikethrough ~~strikethrough~~ non strikethrough ~~strikethrough~~<br/>
~~Wrongly closed strikethrough must be automatically fixed

```
| Font Styles respect white-space
| (column alignment) in monospace/pre blocks.
| ┌─────────────────────┬───────────────────────┬──────────────────────┐
| │_This is a paragraph_│__This is a paragraph__│~~This is an strike~~ │
| │_ with style italic_ │__with style bold__ │~~through paragraph~~ │
| └─────────────────────┴───────────────────────┴──────────────────────┘
| Font Styles respect white-space |
| (column alignment) in monospace/pre blocks. |
| ┌─────────────────────┬───────────────────────┬──────────────────────┐|
| │_This is a paragraph_│__This is a paragraph__│~~This is an strike~~ │|
| │_ with style italic_ │__with style bold__ │~~through paragraph~~ │|
| └─────────────────────┴───────────────────────┴──────────────────────┘|
└─────┘ └────┘
|
| The Pipe symbol (|) can be used to eliminate whitespace columns to left and right. |
| (Markdown extension, recommended). Pipe symbol itself will be eliminated. |
| |
| Notice that preformated text is a 2 dimensional graph, allowing for diagramatic |
| content (information with arbitrary read/walk-over order, while standard text is |
| 1-dimensional with a well defined read/walk-over order. |
| **Mathematically, they are completly different** !!!. Brain likes reading and |
| learning in 1 dimension, but real world and real problems are not unidimensional.|
```

[[{doc_has.image]]
<br/> <br/> <br/>
![image](./test.svg){width:10ch;}

Let's embbed an svg image with 30ch width ...
![image](./test.svg){width:30ch;}
* Let's embbed it again inside a list
![image](./test.svg){width:20ch;}
![image](./test.svg){width:30ch;transform: rotate(90deg);}
1. Let's do it again:
![image](./test.svg){width:10ch;transform: rotate(90deg);}
<!-- └───────────────────┬────────────────┘
Markdown TXT World domination extension to bring
enemy images under control ah, Ah, Ah!!!! -->
11. And again!!!!!
```
| ![image](./test.svg){width:10ch;}
```

**You hate images, don't you? Let's trap them in a table**!!

| Column 1 | Column 2 |
|----------------------------------|:---------|
| ![image](./test.svg){width:5ch;} | |
| |![image](./test.svg){width:5ch;transform: rotate(270deg);} |

Now images are under the control of TXT!!! ah, Ah, ah!!!
[[doc_has.image}]]


Expand Down

0 comments on commit 3381903

Please sign in to comment.