commit d3fac2986de28275d7613c85c54243c9ffc58dc6
parent e28e93104ffd8cfa384111e17563c2aeec5b8b35
Author: Remy Noulin <loader2x@gmail.com>
Date: Wed, 29 Jul 2020 14:23:29 +0200
fix links to other articles by converting the url syntax in the md file instead of the html
forb.c | 49 ++++++++++++++++++++++++++++++-------------------
package.yml | 2 +-
2 files changed, 31 insertions(+), 20 deletions(-)
Diffstat:
2 files changed, 31 insertions(+), 20 deletions(-)
diff --git a/forb.c b/forb.c
@@ -375,6 +375,36 @@ bool generateAPageOrAPost(char *filename, smallJsont *cfg, smallArrayt *postsFee
cleanAllocateSmallJson(pCfg);
readFileWithFrontMatter(filename, pCfg, pf);
+ //lv(filename);
+
+ // process {% post_url 2015-12-22-test %}
+ // skip converting to URL in code blocks
+ enum {searchcodeblock, incodeblock};
+ int mdstatus = searchcodeblock;
+ iter(pf, L) {
+ castS(l,L);
+ // process {% post_url 2015-12-22-running-rocket-chat %}
+ // only outside code block, keep inside code blocks
+ // (keep this block after code highlighting to get the correct status from the first line
+ // in the code block)
+ if (mdstatus equals searchcodeblock and hasG(l, "{\% post_url ")) {
+ char *startp = hasG(l, "{\% post_url ");
+ char *endp = hasG(l, " \%}");
+ int start = startp - ssGet(l);
+ int end = endp - ssGet(l);
+ // post filename
+ char *postFilemane = startp + strlen("{\% post_url ");
+ *endp = 0;
+ //lv(postFilemane);
+ cleanCharP(url) = postToUrl(postFilemane);
+ delG(l, start, end+3);
+ insertG(l, start, url);
+ //lv(l);
+ setPG(pf, iterIndexG(pf), l);
+ }
+ if (startsWithG(l, "```"))
+ mdstatus is mdstatus equals searchcodeblock ? incodeblock : searchcodeblock;
+ }
//lv(pf);
// convert markdown to html
@@ -400,7 +430,6 @@ bool generateAPageOrAPost(char *filename, smallJsont *cfg, smallArrayt *postsFee
sliceG(pHtml, bodyStart, bodyEnd);
// add class in <code>
- // process {% post_url 2015-12-22-test %}
// add syntax highlighting
enum {searchCode, notspecified, bash, javascript, python, html, coffeescript};
int status = searchCode;
@@ -621,24 +650,6 @@ bool generateAPageOrAPost(char *filename, smallJsont *cfg, smallArrayt *postsFee
}
}
- // process {% post_url 2015-12-22-running-rocket-chat %}
- // only outside code block, keep inside code blocks
- // (keep this block after code highlighting to get the correct status from the first line
- // in the code block)
- if (status == searchCode and hasG(l, "{\% post_url ")) {
- char *startp = hasG(l, "{\% post_url ");
- char *endp = hasG(l, " \%}");
- int start = startp - ssGet(l);
- int end = endp - ssGet(l);
- // post filename
- char *postFilemane = startp + strlen("{\% post_url ");
- *endp = 0;
- //lv(postFilemane);
- cleanCharP(url) = postToUrl(postFilemane);
- delG(l, start, end+3);
- insertG(l, start, url);
- //lv(l);
- }
setPG(pHtml, iterIndexG(pHtml), l);
}
diff --git a/package.yml b/package.yml
@@ -1,6 +1,6 @@
---
name: forb
- version: 0.0.5
+ version: 0.0.6
description: static blog generator with configuration files inspired by jekyll
bin: ./forb.c
repository: