slweb

Једноставни генератор статичких веб страна
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување 74c391754d9b7016c3f3033791b061da249297a8
родитељ ffdbf5e0c54e551ec747101aa626090542f6abf7
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Wed, 25 Nov 2020 19:51:20 +0100

Rewrote tag code to allow both ids and classes

Signed-off-by: Страхиња Радић <contact@strahinja.org>

Diffstat:
MMakefile | 6+++---
Aexamples/tags/index.html | 23+++++++++++++++++++++++
Aexamples/tags/index.slw | 15+++++++++++++++
Mindex.html | 2+-
Mslweb.1.in | 35++++++++++++++++++++++++-----------
Mslweb.in | 54++++++++++++++++++++++++++++++++++++------------------
измењених датотека: 6, додавања: 102(+), брисања: 33(-)

diff --git a/Makefile b/Makefile @@ -1,9 +1,9 @@ -SLWVERSION = v0.2.2-beta -SLWDATE = 23 Nov 2020 +SLWVERSION = v0.2.3-beta +SLWDATE = 25 Nov 2020 BINDIR = /usr/local/bin MANDIR = /usr/local/share/man/man1 BROWSER = surf -EXAMPLE_PAGES = $(addsuffix /index.slw,examples/basic examples/includes) +EXAMPLE_PAGES = $(addsuffix /index.slw,examples/basic examples/includes examples/tags) #EXAMPLE_PAGES += $(addprefix examples/includes, EXAMPLE_PAGES_HTML = $(EXAMPLE_PAGES:.slw=.html) diff --git a/examples/tags/index.html b/examples/tags/index.html @@ -0,0 +1,23 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <title>Tag test</title> + <meta charset="utf8" /> + <meta name="viewport" content="width=device-width, initial-scale=1" /> + <meta name="generator" content="slweb" /> +</head> +<body> +<test>Tag test</test> + +<test class="class mysecondclass selected">Selected text</test> + +<test id="firstid">First id</test> + +<test id="secondid" class="class">Second id</test> + +<test id="thirdid" class="class"> + <div id="someid">Some id</div><!--#someid--> + <div class="someclass">Some class</div><!--.someclass--> +</test> +</body> +</html> diff --git a/examples/tags/index.slw b/examples/tags/index.slw @@ -0,0 +1,15 @@ +site-name: Tag test +--- +{test}Tag test{/test} + +{test.class mysecondclass selected}Selected text{/test} + +{test#firstid}First id{/test} + +{test#secondid.class}Second id{/test} + +{test.class#thirdid} + {#someid}Some id{/#someid} + {.someclass}Some class{/.someclass} +{/test} + diff --git a/index.html b/index.html @@ -97,7 +97,7 @@ this program. If not, see &lt;https://www.gnu.org/licenses/&gt;. </p> <div id="git-log"> Previous commit: -index.slw 254ad89 2020-11-24 13:02:50 +0100 (Страхиња Радић) (HEAD -> master, origin/master, origin/HEAD) +index.slw 254ad89 2020-11-24 13:02:50 +0100 (Страхиња Радић) </div><!--git-log--> diff --git a/slweb.1.in b/slweb.1.in @@ -102,21 +102,34 @@ Space followed by a newline will be turned into \fC<br />\fR. .BR "Directives " include: . .IP \[bu] 4 -.BR "Class divs" . -Directive \fC{.myclass}{/.myclass}\fR will be transformed into \fC<div -class="myclass"></div>\fR. -. -.IP \[bu] -.BR "Id divs" . -Directive \fC{#myid}{/#myid}\fR will be transformed into \fC<div -id="myid"></div>\fR. -. -.IP \[bu] .BR "General tags" . Directive \fC{sometag}{/sometag}\fR will be transformed into \fC<sometag></sometag>\fR. . -.IP \[bu] +.RS +.IP \- 4 +.BR "Class attributes" . +Directive \fC{tag.myclass mysecondclass}{/tag}\fR will be transformed into +\fC<tag class="myclass mysecondclass"></tag>\fR. Only one class attribute is +permitted per tag directive, but you can include multiple classes by separating +them with a space, just like in +.SM HTML, +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. +. +.IP \- 4 +.BR "Id attributes" . +Directive \fC{tag#myid}{/tag}\fR will be transformed into \fC<tag +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. +.RE +. +.IP \[bu] 4 .BR Includes . Directive \fC{include "somefile"}\fR will run \fCslweb -b\fR on .I somefile.slw diff --git a/slweb.in b/slweb.in @@ -105,30 +105,48 @@ function body() -e 's/\\$//g' \ -e 's/`\(.*\)`/<code>\1<\/code>/g' \ -e 's/\\`/`/g' \ - -e 's/^{\.\(.*\)}/<div class="\1">/' \ - -e 's/\([^\\]\){\.\(.*\)}/\1<div class="\2">/' \ - -e 's/\\\({\..*}\)/\1/' \ - -e 's/^{\/\.\(.*\)}/<\/div><!--\1-->/' \ - -e 's/\([^\\]\){\/\.\(.*\)}/\1<\/div><!--\2-->/' \ - -e 's/\\\({\/\..*}\)/\1/' \ - -e 's/^{#\(.*\)}/<div id="\1">/' \ - -e 's/\([^\\]\){#\(.*\)}/\1<div id="\2">/' \ - -e 's/\\\({#.*}\)/\1/' \ - -e 's/^{\/#\(.*\)}/<\/div><!--\1-->/' \ - -e 's/\([^\\]\){\/#\(.*\)}/\1<\/div><!--\2-->/' \ - -e 's/\\\({\/#.*}\)/\1/' \ -e "s/^{made-by}/$MADEBY/g" \ -e "s/\([^\\]\){made-by}/\1$MADEBY/g" \ -e 's/\\\({made-by}\)/\1/g' \ -e "s/^{git-log}/$GITLOG/g" \ -e "s/\([^\\]\){git-log}/\1$GITLOG/g" \ -e 's/\\\({git-log}\)/\1/g' \ - -e 's/^{\([a-z-]\+\)}/<\1>/g' \ - -e 's/\([^\\]\){\([a-z-]\+\)}/\1<\2>/g' \ - -e 's/\\\({[a-z-]\+}\)/\1/g' \ - -e 's/^{\/\([a-z-]\+\)}/<\/\1>/g' \ - -e 's/\([^\\]\){\/\([a-z-]\+\)}/\1<\/\2>/g' \ - -e 's/\\\({\/[a-z-]\+}\)/\1/g' \ + -e 's/^{\.\([a-z 0-9-]\+\)#\([a-z0-9-]\+\)}/<div id="\2" class="\1">/g' \ + -e 's/\([^\\]\){\.\([a-z 0-9-]\+\)#\([a-z0-9-]\+\)}/\1<div id="\3" class="\2">/g' \ + -e 's/\\\({\.[a-z0-9-]\+#[a-z0-9-]\+}\)/\1/g' \ + -e 's/^{#\([a-z0-9-]\+\)\.\([a-z 0-9-]\+\)}/<div id="\1" class="\2">/g' \ + -e 's/\([^\\]\){#\([a-z0-9-]\+\)\.\([a-z 0-9-]\+\)}/\1<div id="\2" class="\3">/g' \ + -e 's/\\\({#[a-z0-9-]\+\.[a-z0-9-]\+}\)/\1/g' \ + -e 's/^{\.\([a-z 0-9-]\+\)}/<div class="\1"/g' \ + -e 's/\([^\\]\){\.\([a-z0-9-]\+\)}/\1<div class="\2">/g' \ + -e 's/\\\({\.[a-z0-9-]\+}\)/\1/g' \ + -e 's/^{#\([a-z0-9-]\+\)}/<div id="\1">/g' \ + -e 's/\([^\\]\){#\([a-z0-9-]\+\)}/\1<div id="\2">/g' \ + -e 's/\\\({#[a-z0-9-]\+}\)/\1/g' \ + -e 's/^{\([a-z0-9-]\+\)\.\([a-z 0-9-]\+\)#\([a-z0-9-]\+\)}/<\1 id="\3" class="\2">/g' \ + -e 's/\([^\\]\){\([a-z0-9-]\+\)\.\([a-z 0-9-]\+\)#\([a-z0-9-]\+\)}/\1<\2 id="\4" class="\3">/g' \ + -e 's/\\\({[a-z0-9-]\+\.[a-z 0-9-]\+#[a-z0-9-]\+}\)/\1/g' \ + -e 's/^{\([a-z0-9-]\+\)#\([a-z0-9-]\+\)\.\([a-z 0-9-]\+\)}/<\1 id="\2" class="\3">/g' \ + -e 's/\([^\\]\){\([a-z0-9-]\+\)#\([a-z0-9-]\+\)\.\([a-z 0-9-]\+\)}/\1<\2 id="\3" class="\4">/g' \ + -e 's/\\\({[a-z0-9-]\+#[a-z0-9-]\+\.[a-z0-9-]\+}\)/\1/g' \ + -e 's/^{\([a-z0-9-]\+\)\.\([a-z 0-9-]\+\)}/<\1 class="\2">/g' \ + -e 's/\([^\\]\){\([a-z0-9-]\+\)\.\([a-z 0-9-]\+\)}/\1<\2 class="\3">/g' \ + -e 's/\\\({[a-z0-9-]\+\.[a-z0-9-]\+}\)/\1/g' \ + -e 's/^{\([a-z0-9-]\+\)#\([a-z0-9-]\+\)}/<\1 id="\2">/g' \ + -e 's/\([^\\]\){\([a-z0-9-]\+\)#\([a-z0-9-]\+\)}/\1<\2 id="\3">/g' \ + -e 's/\\\({[a-z0-9-]\+#[a-z0-9-]\+}\)/\1/g' \ + -e 's/^{\([a-z0-9-]\+\)}/<\1>/g' \ + -e 's/\([^\\]\){\([a-z0-9-]\+\)}/\1<\2>/g' \ + -e 's/\\\({[a-z0-9-]\+\)/\1/g' \ + -e 's/^{\/\([a-z0-9-]\+\)}/<\/\1>/g' \ + -e 's/\([^\\]\){\/\([a-z0-9-]\+\)}/\1<\/\2>/g' \ + -e 's/\\\({\/[a-z0-9-]\+}\)/\1/g' \ + -e 's/^{\/\.\([a-z0-9-]\+\)}/<\/div><!--.\1-->/g' \ + -e 's/\([^\\]\){\/\.\([a-z0-9-]\+\)}/\1<\/div><!--.\2-->/g' \ + -e 's/\\\({\/\.[a-z0-9-]\+}\)/\1/g' \ + -e 's/^{\/#\([a-z0-9-]\+\)}/<\/div><!--#\1-->/g' \ + -e 's/\([^\\]\){\/#\([a-z0-9-]\+\)}/\1<\/div><!--#\2-->/g' \ + -e 's/\\\({\/#[a-z0-9-]\+}\)/\1/g' \ -e 's/ $/<br \/>/g' \ -e "s/^\\[\\([^]]\\+\\)\\](\\([a-z]\+:\/\/[^)]\\+\\))/<a href=\"\\2\">\\1<\\/a>/" \ -e "s/\\([^\\\\]\\)\\[\\([^]]\\+\\)\\](\\([a-z]\+:\/\/[^)]\\+\\))/\\1<a href=\"\\3\">\\2<\\/a>/" \