From 91a34681be05a8c91b8db6ae732212ddceb0183c Mon Sep 17 00:00:00 2001 From: Simon Petit <nomisp96@hotmail.fr> Date: Sun, 17 Nov 2024 17:46:42 +0100 Subject: [PATCH] replaceing * by * --- drafts/published/awk_for_static_site_generation.md | 12 ++++++------ posts/awk_for_static_site_generation.html | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drafts/published/awk_for_static_site_generation.md b/drafts/published/awk_for_static_site_generation.md index a9189e8..5a24c5b 100644 --- a/drafts/published/awk_for_static_site_generation.md +++ b/drafts/published/awk_for_static_site_generation.md @@ -158,19 +158,19 @@ Whenever the pattern is found, two global variables are filled : For the following, `line` represents the line processed by the function, as the following `while` loops are actually part of a single function. -This way `match(line, /\*([^*]+)\*/)` matches a string surrounded by two `*`, corresponding to an emphasis text. +This way `match(line, /\*([^*]+)\*/)` matches a string surrounded by two `*`, corresponding to an emphasis text. The `*` are espaced are thez are special characters, and the *group* is inside the parenthesis. To matche several instances of emphasis text within a line, a simple `while` will do the trick. -We now only have to insert html tags `<em>` are the right space around the matched text, and we are good to go. +We now only have to insert html tags `<em>` are the right space around the matched text, and we are good to go. We can save the global variables `RSTART` and `RLENGTH` for further use, in case they were to be change. Using them we also can extract the matched substrings and reconstruct the actual html string : - while (match(line, /\*([^*]+)\*/)) { + while (match(line, /\*([^*]+)\*/)) { start = RSTART end = RSTART + RLENGTH - 1 - # Build the result: before match, <em>, content, </em>, after match - line = substr(line, 1, start-1) "<em>" substr(line, start+1, RLENGTH-2) "</em>" substr(line, end+1) + # Build the result: before match, <em>, content, </em>, after match + line = substr(line, 1, start-1) "<em>" substr(line, start+1, RLENGTH-2) "</em>" substr(line, end+1) } We now can repeat the pattern for all inline fonctionnalities, e.g. strong and code. @@ -197,7 +197,7 @@ It is possible to apply the match fonction on this `matched` string, and extract As the link text and the url are stored, using the variables `start` and `end`, it is easy to reconstruct the html line : - line = substr(line, 1, start-1) "<a href=\"" matched_url "\">" matched_link "</a>" substr(line, end+1) + line = substr(line, 1, start-1) "<a href=\"" matched_url "\">" matched_link "</a>" substr(line, end+1) The inline parsing function is now complete, all we have to do it apply is systematically on the text within html tags and this finished the markdown parser. diff --git a/posts/awk_for_static_site_generation.html b/posts/awk_for_static_site_generation.html index 1f20d20..8fa26f2 100644 --- a/posts/awk_for_static_site_generation.html +++ b/posts/awk_for_static_site_generation.html @@ -158,17 +158,17 @@ function last() { <li>RLENGTH: the length of the matched *group*</li> </ul> <p>For the following, `line` represents the line processed by the function, as the following `while` loops are actually part of a single function.</p> -<p>This way `match(line, /\<em>([^</em>]+)\<em>/)` matches a string surrounded by two `</em>`, corresponding to an emphasis text.</p> +<p>This way `match(line, /*([^*]+)*/)` matches a string surrounded by two `*`, corresponding to an emphasis text.</p> <p>The `<em>` are espaced are thez are special characters, and the </em>group* is inside the parenthesis.</p> <p>To matche several instances of emphasis text within a line, a simple `while` will do the trick.</p> -<p>We now only have to insert html tags `<em>` are the right space around the matched text, and we are good to go.</p> +<p>We now only have to insert html tags `<em>` are the right space around the matched text, and we are good to go.</p> <p>We can save the global variables `RSTART` and `RLENGTH` for further use, in case they were to be change. Using them we also can extract the </p> <p>matched substrings and reconstruct the actual html string :</p> -<pre><code>while (match(line, /\*([^*]+)\*/)) { +<pre><code>while (match(line, /*([^*]+)*/)) { start = RSTART end = RSTART + RLENGTH - 1 - # Build the result: before match, <em>, content, </em>, after match - line = substr(line, 1, start-1) "<em>" substr(line, start+1, RLENGTH-2) "</em>" substr(line, end+1) + # Build the result: before match, <em>, content, </em>, after match + line = substr(line, 1, start-1) "<em>" substr(line, start+1, RLENGTH-2) "</em>" substr(line, end+1) } </code> </pre> @@ -192,7 +192,7 @@ if (match(matched, /\([^\)]+\)/)) { </code> </pre> <p>As the link text and the url are stored, using the variables `start` and `end`, it is easy to reconstruct the html line :</p> -<pre><code>line = substr(line, 1, start-1) "<a href="" matched_url "">" matched_link "</a>" substr(line, end+1) +<pre><code>line = substr(line, 1, start-1) "<a href="" matched_url "">" matched_link "</a>" substr(line, end+1) </code> </pre> <p>The inline parsing function is now complete, all we have to do it apply is systematically on the text within html tags and this finished the markdown parser.</p>