fix bug with spaces at the end of links
This commit is contained in:
parent
427bcecefd
commit
ae1ae05246
12
example.gmi
12
example.gmi
|
@ -22,9 +22,9 @@ but even simpler
|
|||
```
|
||||
|
||||
### inline media
|
||||
=> video.mp4 video
|
||||
=> image.jpg image
|
||||
=> audio.mp3 audio
|
||||
=> video-no-title.mp4
|
||||
=> image-no-title.mp4
|
||||
=> audio-no-title.mp4
|
||||
=> video.mp4 video with title prop
|
||||
=> image.jpg image with title prop
|
||||
=> audio.mp3 audio with title prop
|
||||
=> video-with-no-title.mp4
|
||||
=> image-with-no-title.jpg
|
||||
=> audio-with-no-title.mp3
|
||||
|
|
2
html.js
2
html.js
|
@ -3,7 +3,7 @@ import map from "map-stream";
|
|||
import escape from "escape-html";
|
||||
import * as CSS from "./css.js";
|
||||
|
||||
export const GMI_REGEX = /^((=>\s?(?<href>[^\s]+)(\s(?<title>.+))?)|(?<pre>```\s?(?<alt>.+)?)|(###\s?(?<h3>.+))|(##\s?(?<h2>.+))|(#\s?(?<h1>.+))|(\*\s?(?<li>.+))|(>\s?(?<quote>.+))|(?<text>(.+)?))$/;
|
||||
export const GMI_REGEX = /^((=>\s?(?<href>[^\s]+)\s?(?<title>.+)?)|(?<pre>```\s?(?<alt>.+)?)|(###\s?(?<h3>.+))|(##\s?(?<h2>.+))|(#\s?(?<h1>.+))|(\*\s?(?<li>.+))|(>\s?(?<quote>.+))|(?<text>(.+)?))$/;
|
||||
export const tokenize = (gemtext) =>
|
||||
JSON.parse(JSON.stringify(gemtext.split("\n").map((line) => GMI_REGEX.exec(line).groups)));
|
||||
|
||||
|
|
60
spec.js
60
spec.js
|
@ -32,12 +32,12 @@ test("--body", () => {
|
|||
</pre>
|
||||
<p></p>
|
||||
<h3 style=\\"margin-top:0;margin-bottom:0;overflow-wrap:break-word;\\">inline media</h3>
|
||||
<a href=\\"video.mp4\\" style=\\"display:block;\\">video</a>
|
||||
<a href=\\"image.jpg\\" style=\\"display:block;\\">image</a>
|
||||
<a href=\\"audio.mp3\\" style=\\"display:block;\\">audio</a>
|
||||
<p style=\\"margin-top:0;margin-bottom:0;overflow-wrap:break-word;\\">=> video-no-title.mp4 </p>
|
||||
<p style=\\"margin-top:0;margin-bottom:0;overflow-wrap:break-word;\\">=> image-no-title.mp4 </p>
|
||||
<p style=\\"margin-top:0;margin-bottom:0;overflow-wrap:break-word;\\">=> audio-no-title.mp4 </p>"
|
||||
<a href=\\"video.mp4\\" style=\\"display:block;\\">video with title prop</a>
|
||||
<a href=\\"image.jpg\\" style=\\"display:block;\\">image with title prop</a>
|
||||
<a href=\\"audio.mp3\\" style=\\"display:block;\\">audio with title prop</a>
|
||||
<a href=\\"video-with-no-title.mp4\\" style=\\"display:block;\\">video-with-no-title.mp4</a>
|
||||
<a href=\\"image-with-no-title.jpg\\" style=\\"display:block;\\">image-with-no-title.jpg</a>
|
||||
<a href=\\"audio-with-no-title.mp3\\" style=\\"display:block;\\">audio-with-no-title.mp3</a>"
|
||||
`);
|
||||
expect(toHTML(gemtext, { body: true, css: "none" })).toMatchInlineSnapshot(`
|
||||
"<h1>gmi-web</h1>
|
||||
|
@ -66,12 +66,12 @@ test("--body", () => {
|
|||
</pre>
|
||||
<p></p>
|
||||
<h3>inline media</h3>
|
||||
<a href=\\"video.mp4\\">video</a>
|
||||
<a href=\\"image.jpg\\">image</a>
|
||||
<a href=\\"audio.mp3\\">audio</a>
|
||||
<p>=> video-no-title.mp4 </p>
|
||||
<p>=> image-no-title.mp4 </p>
|
||||
<p>=> audio-no-title.mp4 </p>"
|
||||
<a href=\\"video.mp4\\">video with title prop</a>
|
||||
<a href=\\"image.jpg\\">image with title prop</a>
|
||||
<a href=\\"audio.mp3\\">audio with title prop</a>
|
||||
<a href=\\"video-with-no-title.mp4\\">video-with-no-title.mp4</a>
|
||||
<a href=\\"image-with-no-title.jpg\\">image-with-no-title.jpg</a>
|
||||
<a href=\\"audio-with-no-title.mp3\\">audio-with-no-title.mp3</a>"
|
||||
`);
|
||||
});
|
||||
|
||||
|
@ -121,12 +121,12 @@ test("--html en", () => {
|
|||
</pre>
|
||||
<p></p>
|
||||
<h3>inline media</h3>
|
||||
<a href=\\"video.mp4\\">video</a>
|
||||
<a href=\\"image.jpg\\">image</a>
|
||||
<a href=\\"audio.mp3\\">audio</a>
|
||||
<p>=> video-no-title.mp4 </p>
|
||||
<p>=> image-no-title.mp4 </p>
|
||||
<p>=> audio-no-title.mp4 </p>
|
||||
<a href=\\"video.mp4\\">video with title prop</a>
|
||||
<a href=\\"image.jpg\\">image with title prop</a>
|
||||
<a href=\\"audio.mp3\\">audio with title prop</a>
|
||||
<a href=\\"video-with-no-title.mp4\\">video-with-no-title.mp4</a>
|
||||
<a href=\\"image-with-no-title.jpg\\">image-with-no-title.jpg</a>
|
||||
<a href=\\"audio-with-no-title.mp3\\">audio-with-no-title.mp3</a>
|
||||
</body>
|
||||
</html>
|
||||
"
|
||||
|
@ -168,12 +168,12 @@ test("--image, --audio, --video", () => {
|
|||
</pre>
|
||||
<p></p>
|
||||
<h3 style=\\"margin-top:0;margin-bottom:0;overflow-wrap:break-word;\\">inline media</h3>
|
||||
<video controls src=\\"video.mp4\\" title=\\"video\\"></video>
|
||||
<img src=\\"image.jpg\\" title=\\"image\\"></img>
|
||||
<audio controls src=\\"audio.mp3\\" title=\\"audio\\"></audio>
|
||||
<p style=\\"margin-top:0;margin-bottom:0;overflow-wrap:break-word;\\">=> video-no-title.mp4 </p>
|
||||
<p style=\\"margin-top:0;margin-bottom:0;overflow-wrap:break-word;\\">=> image-no-title.mp4 </p>
|
||||
<p style=\\"margin-top:0;margin-bottom:0;overflow-wrap:break-word;\\">=> audio-no-title.mp4 </p>"
|
||||
<video controls src=\\"video.mp4\\" title=\\"video with title prop\\"></video>
|
||||
<img src=\\"image.jpg\\" title=\\"image with title prop\\"></img>
|
||||
<audio controls src=\\"audio.mp3\\" title=\\"audio with title prop\\"></audio>
|
||||
<video controls src=\\"video-with-no-title.mp4\\"></video>
|
||||
<img src=\\"image-with-no-title.jpg\\"></img>
|
||||
<audio controls src=\\"audio-with-no-title.mp3\\"></audio>"
|
||||
`);
|
||||
});
|
||||
|
||||
|
@ -256,24 +256,24 @@ test("tokenize", () => {
|
|||
},
|
||||
Object {
|
||||
"href": "video.mp4",
|
||||
"title": "video",
|
||||
"title": "video with title prop",
|
||||
},
|
||||
Object {
|
||||
"href": "image.jpg",
|
||||
"title": "image",
|
||||
"title": "image with title prop",
|
||||
},
|
||||
Object {
|
||||
"href": "audio.mp3",
|
||||
"title": "audio",
|
||||
"title": "audio with title prop",
|
||||
},
|
||||
Object {
|
||||
"text": "=> video-no-title.mp4 ",
|
||||
"href": "video-with-no-title.mp4",
|
||||
},
|
||||
Object {
|
||||
"text": "=> image-no-title.mp4 ",
|
||||
"href": "image-with-no-title.jpg",
|
||||
},
|
||||
Object {
|
||||
"text": "=> audio-no-title.mp4 ",
|
||||
"href": "audio-with-no-title.mp3",
|
||||
},
|
||||
Object {
|
||||
"text": "",
|
||||
|
|
Loading…
Reference in a new issue