чување ff27c92420f5cd4574b17b14a5a91dcc9394c901
родитељ cc20f5d32bfa7b2bd4cbd2861fcbe74a4f6ae2bc
Аутор: Страхиња Радић <contact@strahinja.org>
Датум: Mon, 28 Dec 2020 17:38:45 +0100
Various small fixes
Signed-off-by: Страхиња Радић <contact@strahinja.org>
Diffstat:
измењених датотека: 9, додавања: 65(+), брисања: 87(-)
diff --git a/Makefile b/Makefile
@@ -1,60 +0,0 @@
-SLWVERSION = v0.3.0
-SLWDATE = 14 Dec 2020
-BINDIR = /usr/local/bin
-MANDIR = /usr/local/share/man/man1
-CFLAGS=-g
-LIBS=-lunistring
-BROWSER = surf
-EXAMPLE_PAGES = $(addsuffix /index.slw,$(addprefix examples/,\
- basic blockquote includes links macros tags))
-#EXAMPLE_PAGES += $(addprefix examples/includes,
-EXAMPLE_PAGES_HTML = $(EXAMPLE_PAGES:.slw=.html)
-
-%.html: %.slw
- ./slweb $< > $@
-
-%.gz: %
- gzip -kf $<
-
-%.ps: %.1
- groff -mandoc -t -T ps $< > $@
-
-%.pdf: %.1
- groff -mandoc -t -T pdf $< > $@
-
-%: %.in
- cat $< | sed -e "s/%VERSION%/${SLWVERSION}/g" \
- -e "s/%DATE%/${SLWDATE}/g" > $@
-
-all: in examples doc index.html
-
-in: slweb slweb.1
-
-index.html: slweb index.slw
-
-slweb: slweb.o
- $(CC) $(CFLAGS) $(LIBS) -o $@ $<
-
-examples: ${EXAMPLE_PAGES_HTML} slweb
-
-view: index.html
- $(BROWSER) index.html
-
-doc: slweb.pdf slweb.1.gz
-
-install: all
- mkdir -p $(BINDIR) $(MANDIR)
- cp slweb $(BINDIR)
- chmod 0755 $(BINDIR)/slweb
- cp slweb.1.gz $(MANDIR)
-
-uninstall:
- rm -f $(BINDIR)/slweb $(MANDIR)/slweb.1.gz 2>/dev/null
-
-clean:
- rm -f *.o slweb.1.gz slweb.pdf index.html $(EXAMPLE_PAGES_HTML) slweb slweb.1 2>/dev/null
-
-rebuild: clean all
-
-.PHONY: in examples view doc install uninstall clean rebuild
-
diff --git a/all.do b/all.do
@@ -1,2 +1,3 @@
-redo-ifchange slweb slweb.1.gz index.html
+redo-ifchange slweb slweb.1.gz slweb.pdf index.html \
+ examples/{basic,blockquote,includes,links,macros,tags}/index.html
diff --git a/clean.do b/clean.do
@@ -1,3 +1,3 @@
redo-always
-rm -f slweb slweb.1 slweb.1.gz *.o *~ *.pdf *.html
+rm -f slweb slweb.1 slweb.1.gz *.o *~ *.pdf *.html examples/*/*.html
diff --git a/default.pdf.do b/default.pdf.do
@@ -0,0 +1,3 @@
+redo-ifchange $2.1
+groff -mandoc -t -T pdf $2.1 >$3
+
diff --git a/examples/macros/index.slw b/examples/macros/index.slw
@@ -1,7 +1,11 @@
+---
+stylesheet: style.css
+---
+
{=copyright}Copyright © John Doe. <br />
All rights reserved.{/=copyright}
-{header}{=copyright}{/header}
+{header}Header: {=copyright}{/header}
{main}
# Title
@@ -16,5 +20,5 @@ Some more text.
{/main}
-{footer}{=copyright}{/footer}
+{footer}Footer: {=copyright}{/footer}
diff --git a/examples/macros/style.css b/examples/macros/style.css
@@ -0,0 +1,12 @@
+header
+{
+ background-color: #bbf;
+ padding: 1ex;
+}
+
+footer
+{
+ background-color: #bbf;
+ padding: 1ex;
+}
+
diff --git a/index.html b/index.html
@@ -114,7 +114,7 @@ this program. If not, see <<a href="https://www.gnu.org/licenses">https://www
<div id="git-log">
Previous commit:
-index.slw b85f203 2020-12-25 13:37:35 +0100 (Страхиња Радић) (HEAD -> master, origin/master, origin/HEAD)
+index.slw cc20f5d 2020-12-27 21:56:43 +0100 (Страхиња Радић) (HEAD -> redo-instead-of-make, origin/redo-instead-of-make)
</div><!--git-log-->
diff --git a/slweb.1.in b/slweb.1.in
@@ -74,13 +74,14 @@ Text surrounded by newlines will be put inside \fC<p></p>\fR tags.
.BR Headings .
A line starting with \fC#\fR followed by space will be put inside
\fC<h?></h?>\fR, where \fC?\fR stands for 1-4, depending on the number of
-hashtags.
+hash signs.
.
.IP \[bu]
.BR Bold/italic .
Text inside \fC*asterisks*\fR or \fC_underlines_\fR will be put inside
\fC<em></em>\fR. Text inside \fC**double asterisks**\fR or \fC__double
-underlines__\fR will be put inside \fC<strong></strong>\fR.
+underlines__\fR will be put inside \fC<strong></strong>\fR. \fC***More than
+two*** of the ___same symbol___\fR should be avoided.
.
.IP \[bu]
.BR Backticks .
@@ -100,7 +101,17 @@ href="https://example.com">A link</a>\fR.
Special case is the form \fC[=somemacro Link title](https://anything)\fR which
prepends the body of a macro
.I somemacro
-into the \fC<a></a>\fR tag. See
+into the \fC<a></a>\fR tag (here broken into multiple lines for clarity):
+.EX
+.in +4
+<a href="https://anything">
+<!-- contents of somemacro -->
+Link title</a>
+.EE
+.in -4
+This can, for example, be used to add
+.SM SVG
+icons to links. See
.BR Macros .
Also, the form \fC[(Link title)](http://asite.com)\fR will surround the link
@@ -119,7 +130,14 @@ macro-form:
.in -4
It will prepend the body of a macro
.I somemacro
-outside of the \fC<span></span>\fR.
+outside of the \fC<span></span>\fR:
+.EX
+.in +4
+<a href="http://asite.com">
+<!-- contents of somemacro -->
+<span>Link title</span></a>
+.EE
+.in -4
.
.IP \[bu]
.BR "Line breaks" .
@@ -144,7 +162,7 @@ them with a space, just like in
and you can have both a class attribute and an id attribute per tag.
A variation of this is to use a special form \fC{.myclass}{/.myclass}\fR, which
-will be transformed into \fC<div class="myclass"></div><!--.myclass-->\fR.
+will be transformed into \fC<div class="myclass"></div>\fR.
.
.IP \- 4
.BR "Id attributes" .
@@ -153,7 +171,7 @@ id="myid"></tag>\fR. Only one id attribute is permitted per tag directive, and
you can have both an id attribute and a class attribute per tag.
A variation of this is to use a special form \fC{#myid}{/#myid}\fR, which will
-be transformed into \fC<div id="myid"></div><!--#myid-->\fR.
+be transformed into \fC<div id="myid"></div>\fR.
.RE
.
.IP \[bu] 4
@@ -163,7 +181,6 @@ Directive \fC{include "somefile"}\fR will run \fCslweb -b\fR on
(related to the directory containing the file containing the directive) and
include the resulting
.SM HTML.
-Directive needs to start at the beginning of the line.
.
.IP \[bu] 4
.BR Macros .
@@ -250,12 +267,13 @@ attribute of the \fC<meta name="description">\fR tag.
.BR stylesheet .
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.
+file name to be included using the \fC<link rel="stylesheet" />\fR tag. You can
+have more than one \fCstylesheet\fR declaration per \fI.slw\fR file.
.
.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).
+level heading (\fCtitle: Some title\fR becomes \fC<h2>Some title</h2>\fR).
.
.SH "SEE ALSO"
.BR sed (1)
diff --git a/slweb.c b/slweb.c
@@ -225,9 +225,9 @@ process_tag(uint8_t* token, FILE* output, KeyValue** macros,
uint8_t* ptoken = u8_strchr(token, (ucs4_t)' ');
uint8_t* include_filename = NULL;
uint8_t* pinclude_filename = NULL;
- uint8_t* include_basedir = NULL;
- uint8_t* pinclude_basedir = NULL;
- size_t include_basedir_len = 0;
+ uint8_t* include_dirname = NULL;
+ uint8_t* pinclude_dirname = NULL;
+ size_t include_dirname_len = 0;
uint8_t* pfilename = filename;
if (!ptoken)
@@ -238,18 +238,18 @@ process_tag(uint8_t* token, FILE* output, KeyValue** macros,
}
ptoken++;
CALLOC(include_filename, uint8_t, BUFSIZE)
- CALLOC(include_basedir, uint8_t, BUFSIZE)
- pinclude_basedir = include_basedir;
+ CALLOC(include_dirname, uint8_t, BUFSIZE)
+ pinclude_dirname = include_dirname;
if (slash)
while (pfilename && *pfilename && pfilename != slash)
- *pinclude_basedir++ = *pfilename++;
+ *pinclude_dirname++ = *pfilename++;
else
- *pinclude_basedir++ = '.';
- *pinclude_basedir = '\0';
- include_basedir_len = u8_strlen(include_basedir);
- u8_strncpy(include_filename, include_basedir, include_basedir_len);
- *(include_filename + include_basedir_len) = '/';
- pinclude_filename = include_filename + include_basedir_len + 1;
+ *pinclude_dirname++ = '.';
+ *pinclude_dirname = '\0';
+ include_dirname_len = u8_strlen(include_dirname);
+ u8_strncpy(include_filename, include_dirname, include_dirname_len);
+ *(include_filename + include_dirname_len) = '/';
+ pinclude_filename = include_filename + include_dirname_len + 1;
while (ptoken && *ptoken)
if (*ptoken != '"')
*pinclude_filename++ = *ptoken++;
@@ -281,7 +281,7 @@ process_tag(uint8_t* token, FILE* output, KeyValue** macros,
pclose(cmd_output);
free(cmd_output_line);
- free(include_basedir);
+ free(include_dirname);
free(include_filename);
free(command);
}