From 3381903775183ca10039f416c250e86278233642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrique=20Ariz=C3=B3n=20Benito?= Date: Sat, 16 Dec 2023 13:53:45 +0100 Subject: [PATCH] pre: remove extra right whitespace --- lightmarkdown.js | 7 +++++-- test.md | 47 +++++++++++++++++++++++++++++++++++++---------- 2 files changed, 42 insertions(+), 12 deletions(-) diff --git a/lightmarkdown.js b/lightmarkdown.js index 14fe205..0234d92 100644 --- a/lightmarkdown.js +++ b/lightmarkdown.js @@ -20,7 +20,7 @@ function _00_documentCleaning(md, relative_path){ .replaceAll('º[' ,'<' ) .replaceAll(']º' ,'>' ) .replaceAll(/^[-] /mg,'* ' ) - .replaceAll(/ $/mg,'
' ) + // .replaceAll(/ $/mg,'
' ) <·· Commented. return md } @@ -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; } @@ -192,6 +194,7 @@ function _01_standardMarkdownParsing(p/*aragraph*/, relative_path){ p = handleLinks(p); p = handleFontStyles(p); p = handleBlockQuotes(p); + p = p.replaceAll(/ $/mg,'
' ) return p.length>0 ? "\n

"+p+"

" : ""; } diff --git a/test.md b/test.md index 1b863d2..2b768d8 100644 --- a/test.md +++ b/test.md @@ -29,7 +29,7 @@ # Ordered/Unordered (ul) list mix -1. Ordered +11. Ordered 11. a
line continuation. 111. a 111
@@ -38,7 +38,7 @@ line continuation a112 12. b 13. c -2. Lists +22. Lists * a 20. a1 21. a2 @@ -92,22 +92,49 @@ Non strikethrough ~~strikethrough~~ non strikethrough ~~strikethrough~~
~~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]]


- ![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);} + 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}]]