чување 27db5f3b3baf3931ba3b519ced0b1907e68ef5fb
родитељ 2ac06532ee52ee9986d19addbb4d9d96491e50e0
Аутор: Страхиња Радић <contact@strahinja.org>
Датум: Fri, 11 Dec 2020 19:39:00 +0100
Removed the necessity for blank lines inside pre to be escaped
Signed-off-by: Страхиња Радић <contact@strahinja.org>
Diffstat:
измењених датотека: 3, додавања: 26(+), брисања: 22(-)
diff --git a/index.html b/index.html
@@ -21,13 +21,13 @@ $ make && sudo make install
site-name: Test website
site-desc: My first website in slweb
---
-\
-\{main}
-\# Hello world
-\
+
+{main}
+# Hello world
+
This is an \_example_ of a statically generated HTML.
-\
-\{/main}
+
+{/main}
</pre>
<p>after using the command:</p>
@@ -47,12 +47,12 @@ $ slweb index.slw > index.html
<meta name="generator" content="slweb" />
</head>
<body>
-\
+
<main>
<h1>Hello world</h1>
-\
+
<p>This is an <em>example</em> of a statically generated HTML.</p>
-\
+
</main>
</body>
</html>
diff --git a/index.slw b/index.slw
@@ -27,13 +27,13 @@ Given the file `index.slw` in the current directory:
site-name: Test website
site-desc: My first website in slweb
---
-\
-\{main}
-\# Hello world
-\
+
+{main}
+# Hello world
+
This is an \_example_ of a statically generated HTML.
-\
-\{/main}
+
+{/main}
```
after using the command:
@@ -55,12 +55,12 @@ file `index.html` contains:
<meta name="generator" content="slweb" />
</head>
<body>
-\
+
<main>
<h1>Hello world</h1>
-\
+
<p>This is an <em>example</em> of a statically generated HTML.</p>
-\
+
</main>
</body>
</html>
diff --git a/slweb.c b/slweb.c
@@ -150,7 +150,7 @@ process_tag(uint8_t* token, FILE* output, BOOL end_tag)
if (!token || u8_strlen(token) < 1)
return warning(1, (uint8_t*)"No tag\n");
- if (!strcmp(token, "made-by"))
+ if (!strcmp((char*)token, "made-by"))
{
fprintf(output, "<div id=\"made-by\">\n"
"Generated by <a href=\"https://github.com/Strahinja/slweb\">"
@@ -508,7 +508,8 @@ main(int argc, char** argv)
}
else {
- if (first_line_in_doc || previous_line_blank)
+ if (first_line_in_doc || previous_line_blank
+ && !(state & ST_PRE))
{
printf("<p>");
first_line_in_doc = FALSE;
@@ -521,7 +522,9 @@ main(int argc, char** argv)
}
else if (colno == 2)
{
- if (!previous_line_blank && (state & ST_PARA_OPEN))
+ if (!previous_line_blank
+ && (state & ST_PARA_OPEN)
+ && !(state & ST_PRE))
{
printf("</p>\n");
print_newline = FALSE;
@@ -532,7 +535,8 @@ main(int argc, char** argv)
else
previous_line_blank = FALSE;
- if (print_newline)
+ if (print_newline
+ || (state & ST_PRE))
{
printf("\n");
print_newline = FALSE;