Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commitd347c2ee4c941419cf75d252cf04fcbda2c6286a (patch)
Author
 Syndamia <kamen@syndamia.com>
2025-01-01 11:37:23 +0200
Committer
 Syndamia <kamen@syndamia.com>
2025-01-01 11:39:43 +0200
Filesc46cc3e986380de1b477e905f74262253a44f2db
csg-d347c2ee4c941419cf75d252cf04fcbda2c6286a.tar
csg-d347c2ee4c941419cf75d252cf04fcbda2c6286a.tar.gz
csg-d347c2ee4c941419cf75d252cf04fcbda2c6286a.zip
Parent900605617766f143877bb54e7763ef045fe1a8c4 (diff)
feat(single): Support for original markdown specification
2 files changed, 153 insertions, 35 deletions
-rw-r--r--demo/src/index.md147
-rw-r--r--single.awk41
diff --git a/demo/src/index.md b/demo/src/index.md
index 523a9c3..446763c 100644
--- a/demo/src/index.md
+++ b/demo/src/index.md
@@ -4,15 +4,44 @@ This is a demo webpage, made with [csg](https://gitlab.com/Syndamia/csg).
This is a regular paragraph.
+
+Lorem ipsum dolor sit amet, consectetur adipiscing elit.
+Aliquam sed erat velit.
+Curabitur eu interdum libero, ac porttitor mi.
+Aliquam tempor sem at nunc pharetra euismod.
+In finibus euismod lacus, a gravida lectus egestas eu.
+Etiam molestie lacus sit amet elementum scelerisque.
+In id venenatis justo.
+Fusce feugiat vestibulum venenatis.
+Curabitur vitae lacinia enim.
+
+Nullam vel ultrices turpis.
+Suspendisse ut tempor ligula.
+Suspendisse eu orci mattis odio vulputate laoreet ac accumsan tortor.
+Vestibulum et tristique enim.
+Vestibulum aliquam elit at massa tristique maximus eu rutrum neque.
+<table>
+ <tr>
+ <td>Foo</td>
+ </tr>
+</table>
+Curabitur placerat, dui eu laoreet ultrices, ante massa consectetur erat, non lacinia est augue a justo.
+Sed euismod viverra turpis in auctor.
+
<table>
<tr>
<td>Foo</td>
</tr>
</table>
+
+Curabitur placerat, dui eu <b>laoreet</b> ultrices, ante *massa* consectetur **erat**, non *<b>lacinia</b>* est augue a justo.
+
This is another regular paragraph.
-&copy; AT&T 4 < 5
+&copy; AT&T 4 < 5 4 <5 4< 5
+
+ &copy; AT&T 4 < 5 4 <5 4< 5
This is an H1
=============
@@ -40,6 +69,8 @@ This is an H2
> > a
+> >a
+
> This is the first level of quoting.
>
> > This is nested blockquote.
@@ -62,6 +93,43 @@ id sem consectetuer libero luctus adipiscing.
>
> return shell_exec("echo $input | $markdown_script");
+ ## Header
+
+ *Emphasis* line with **bold** text too.
+
+ * Item 1
+ * Item 2
+
+ > Quote here
+
+ Header 1
+ ========
+
+Text
+
+ ## Header
+text
+
+ <div class="footer">
+ &copy; 2004 Foo Corporation
+ </div>
+
+---
+
+- - -
+
+- - - -
+
+-- -
+
+***
+
+* * *
+
+___
+
+_ _ _
+
*single asterisks*
_single underscores_
@@ -88,24 +156,85 @@ un*frigging*believable
**World**
++ One
+
+- Two
+ <div class="footer">
+ &copy; 2004 Foo Corporation
+ </div>
+
+* Three
+
+* Three1
+* Three 2
+
+* Three 3
+ A
+ B
+
+ C
+ D
+* Three 4
+
+Paragraph here
+
+* List item starts here
+and continues here
+ + sublist start
+ with continuation
+ + and second
+ addition
+
+101. Similarly starts here
+ and continues here
+ But stops here
+
+
++ List item
+
+ Code block is inside the list!
+
+ + Sublist
+ + Subsublist
+ Code block is inside the subsublist
+
+ * List item starts here
+ and continues here
+ and continues here
+ and continues here
+
+Stop lists
+
+1986. What a great season.
+
+1986\. What a great season.
+
This is [an example](http://example.com/ "Title") inline link.
[This link](http://example.net/) has no title attribute.
See my [About](/about/) page for details.
-This is __a__ itali__cised__ text
+This is __an__ itali__cised__ text
+Equation a * b * c _ d _ e * f * g _ h _ i
-x~2~^e^ = y^някоя си^~търсно то~
+x~2~^e^ = y^някоя си^~~търсно то~~
: **Common** [programmer](https://wikipedia.org "Me") phrase
+some
+: def
+
Lorem `ipsum` dolor tiada ad;l ``kfj `skigj`` jjsa
![](https://syndamia.com/favicon.ico) ![](https://syndamia.com/favicon.ico "Hello") ![World](https://syndamia.com/favicon.ico) ![Hello](https://syndamia.com/favicon.ico "World")
+- [ ] Standalone 1
+
- [ ] *A*
- [x] **B**
+- [ ] Standalone 2
+
[me]: https://syndamia.com
Some links: [Google][], [this is a page about me][me]
@@ -114,4 +243,16 @@ Some links: [Google][], [this is a page about me][me]
![Picture of me][mepic]
+ ![Picture of me][mepic]
+
[mepic]: https://syndamia.com/img/face.jpeg (Photo of myself)
+
+[[a](/a)](/b)
+
+Escapes: \\ \` \* \_ \{ \} \[ \] \( \) \# \+ \- \. \!
+Normal text: \a \K \9 \, \@
+*em* \*nonem\* [Hello]\(world)
+
+Test <google.com> <http://example.com> <me@mail.com>
+
+Some esoteric mails: <"Hello World"@something.co.uk> <anything@[1.2.3.4]> <long.john@[2001:0db8:85a3:0000:0000:8a2e:0370:7334]>
diff --git a/single.awk b/single.awk
index 1e48ce7..7698bca 100644
--- a/single.awk
+++ b/single.awk
@@ -1,26 +1,10 @@
-# Status:
-# [.] Inline HTML
-# [x] Autoescape
-# [x] Block elements
-# [x] Paragraph
-# [x] Line break
-# [x] Headers (atx and setex)
-# [x] Blockquotes
-# [x] Lists
-# [x] Code blocks
-# [x] Horizontal rules
-# [x] Span elements
-# [x] Links
-# [x] Inline
-# [x] Reference
-# [x] Emphasis
-# [x] Code
-# [x] Images
-# [x] Inline
-# [x] Reference
-# [x] Other
-# [x] Autolinks
-# [x] Escapes
+# Almost the entire canonical Markdown specification is supported
+# https://daringfireball.net/projects/markdown/syntax
+# Notable behavioural exceptions are:
+# - Block-level HTML elements needn't be separated with blank lines
+# - Lists are identation-aware. List items begin and continue after the same
+# identation with which the list beginning (e.g. "* " or "5. ") was written.
+# The benefit is that all Markdown is parsed as normal inside an item.
#
# [ ] Non-standard features
# [ ] Strikethrough ~~...~~
@@ -36,15 +20,8 @@
# [ ] Links
# [ ] Link destination (<link> inside anchors)
# [ ] Nested links
-# No character classes, since they aren't supported on every system
#
-# Limitations:
-# - definition lists always contain one element, i.e. multiple definitions
-# aren't merged into the same list
-# - emphasis which isn't surrounded by blanks is still treated as emphasis
-# e.g. "some_text_here" will become "some<em>text</em>here"
-# - emphasis inside inline code block is still converted to HTML
-# - backticks inside `` emphasis blocks aren't escaped
+# No character classes have been used, since they aren't supported on every system
function empty(value) {
return value == ""
@@ -108,7 +85,7 @@ BEGIN {
}
# Output is buffered on multiple lines, held in these variables:
-# P2 = previous non-empty line
+# P2 = last non-empty line before the previous line
# P1 = previous line
# $0 = current line
# N1 = next new line (N1 is always set by the user)