чување e631ee2468d46abbe491eab2fbc4a338e9af26c1
родитељ a4239c8ebcdba060879516a3d5b2556b8295f305
Аутор: Страхиња Радић <contact@strahinja.org>
Датум: Tue, 8 Dec 2020 22:44:54 +0100
Added blockquotes, fixed some bugs with paragraphs
Signed-off-by: Страхиња Радић <contact@strahinja.org>
Diffstat:
измењених датотека: 5, додавања: 105(+), брисања: 9(-)
diff --git a/Makefile b/Makefile
@@ -1,5 +1,5 @@
-SLWVERSION = v0.2.6-beta
-SLWDATE = 7 Dec 2020
+SLWVERSION = v0.2.7-beta
+SLWDATE = 8 Dec 2020
BINDIR = /usr/local/bin
MANDIR = /usr/local/share/man/man1
BROWSER = surf
diff --git a/examples/includes/examples.slw b/examples/includes/examples.slw
@@ -5,7 +5,7 @@ Given the file `index.slw` in the current directory:
```
site-name: Test website
site-desc: My first website in slweb
----
+\---
\
\{main}
\# Hello world
diff --git a/index.html b/index.html
@@ -9,7 +9,6 @@
<link rel="stylesheet" href="index.css" />
</head>
<body>
-
<main>
<h1>slweb</h1>
diff --git a/slweb.1.in b/slweb.1.in
@@ -87,7 +87,11 @@ Text inside \fC*asterisks*\fR or \fC_underlines_\fR will be put inside
.BR Backticks .
Text inside \fC`backticks`\fR will be put inside \fC<code></code>\fR (one per
line, both backticks need to be on the same line).
-
+.
+.IP \[bu]
+.BR "Blockquotes" .
+Starting the line with \fC>\fR will surround it with a \fC<blockquote>\fR tag.
+Multiple lines are supported.
.
.IP \[bu]
.BR "Links (limited)" .
@@ -247,6 +251,11 @@ The contents of this variable will be treated as a
.sm CSS
file name to be included using the \fC<link rel="stylesheet" />\fR tag.
.
+.IP \[bu] 4
+.BR title .
+If present, contents of this variable will be prepended to the body as a second
+level heading (\fCtitle: Some title\fR becomes \fC## Some title\fR).
+.
.SH "SEE ALSO"
.BR sed (1)
.
@@ -305,6 +314,87 @@ file \fCindex.html\fR contains:
.sp
.EE
.
+.SH "KNOWN LIMITATIONS"
+.
+.IP \[bu] 4
+Currently there is no way to determine where the paragraph inside a tag should
+begin and end without adding blank lines or using the \fC{p}{/p}\fR notation.
+For example, the code
+.EX
+.in +4
+.sp
+{tag}
+First paragraph
+
+Second paragraph
+{/tag}
+.in -4
+.sp
+.EE
+will produce
+.EX
+.in +4
+.sp
+<tag>
+First paragraph</p>
+
+<p>Second paragraph
+</tag>
+.in -4
+.sp
+.EE
+You can suppress the paragraph starting/ending tags by prepending blank lines
+with a backslash, like this:
+.EX
+.in +4
+.sp
+{tag}
+First paragraph
+\[rs]
+Second paragraph
+{/tag}
+.in -4
+.sp
+.EE
+which will produce
+.EX
+.in +4
+.sp
+<tag>
+First paragraph
+
+Second paragraph
+</tag>
+.in -4
+.sp
+.EE
+Adding blank lines helps, if paragraphs are desired:
+.EX
+.in +4
+.sp
+{tag}
+
+First paragraph
+
+Second paragraph
+
+{/tag}
+.in -4
+.sp
+.EE
+will produce
+.EX
+.in +4
+.sp
+<tag>
+<p>First paragraph</p>
+
+<p>Second paragraph</p>
+</tag>
+.in -4
+.sp
+.EE
+.
.SH BUGS
.
.PP
diff --git a/slweb.in b/slweb.in
@@ -90,10 +90,17 @@ function body()
-e's/^### \([^\n]*\)$/<h3>\1<\/h3>/g' \
-e's/^## \([^\n]*\)$/<h2>\1<\/h2>/g' \
-e's/^# \([^\n]*\)$/<h1>\1<\/h1>/g' | \
+ sed -z -e 's/^\n*>/<blockquote>\n>/g' \
+ -e 's/^\([^>\n][^\n]*\)\?\n>/\1\n<blockquote>\n/g' \
+ -e 's/\n\([^>\n][^\n]*\)\?\n>/\1\n<blockquote>\n>/g' \
+ -e 's/\n>\([^\n]*\)\n\([^>]\)/\n>\1\n<\/blockquote>\n\2/g' \
+ -e 's/\n>\([^\n]*\)\n$/\n>\1\n<\/blockquote>\n/g' \
+ -e 's/\n>/\n/g' | \
sed -e '1h;2,$H;$!d;g;s/\n\+\n```[^\n]*\n/\n\n<pre>\n/g' | \
sed -e 's/^```$/<\/pre>\n\n/g' | \
- sed -e '1h;2,$H;$!d;g;s/\n\n\([^<{\n]\+\)/\n\n<p>\1/g' | \
- sed -e '1h;2,$H;$!d;g;s/\([^>}\n]\)\n\n/\1<\/p>\n\n/g' | \
+ sed -e '1h;2,$H;$!d;g;s/^\([^<>{\n]\+\)/<p>\1/g' | \
+ sed -e '1h;2,$H;$!d;g;s/\n\n\([^<>{\n]\+\)/\n\n<p>\1/g' | \
+ sed -e '1h;2,$H;$!d;g;/\n\([^>\n][^\n]*\)\?\([^>}\n]\)\n\n/s/\([^\n]*[^>}\n]\)\n\n/\1<\/p>\n\n/g' | \
sed -e '1h;2,$H;$!d;g;s/\([^>}\n]\)$/\1<\/p>\n\n/g' | \
sed -e 's/^\*\*\([^*]*\)\*\*/<strong>\1<\/strong>/g' \
-e 's/\([^\\]\)\*\*\([^*]*\)\*\*/\1<strong>\2<\/strong>/g' \
@@ -250,7 +257,7 @@ INDIR=$(dirname $INFILE 2>/dev/null)
#if [ $BODY_ONLY -eq 0 ]; then
grep -- '^---' $INFILE 2>&1 >/dev/null \
- && DOC="$(echo; sed '0,/^---/d' $INFILE)" \
+ && DOC="$(sed '0,/^---/d' $INFILE)" \
|| DOC=$(cat $INFILE)
#else
#DOC=$(cat $INFILE)
@@ -330,7 +337,7 @@ if [ $BODY_ONLY -eq 0 ]; then
end_head
begin_body
fi
-[ -n "${VARS[title]}" ] && echo "<h2>${VARS[title]}</h2>"
+[ -n "${VARS[title]}" ] && DOC="## ${VARS[title]}$(echo; echo "$DOC")"
body "$DOC"
if [ $BODY_ONLY -eq 0 ]; then
end_body