Repository: tlienart/Franklin.jl
Pull request #935 (2021-12-23 14:33:10)

Fix tag's RSS head templating
Currently a tag's RSS feed's head is not filled, e.g. https://cnx.srht.site/tag/fun/feed.xml


Patch:
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index f549eb7f..9005dc06 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -24,7 +24,7 @@ jobs:
     - name: Install Julia
       uses: julia-actions/setup-julia@v1
       with:
-        version: 1.6
+        version: 1.7
     - run: julia -e '
             using Pkg;
             Pkg.add(Pkg.PackageSpec(name="NodeJS"));
diff --git a/Project.toml b/Project.toml
index 0ab5cd6e..507d871e 100644
--- a/Project.toml
+++ b/Project.toml
@@ -1,7 +1,7 @@
 name = "Franklin"
 uuid = "713c75ef-9fc9-4b05-94a9-213340da978e"
 authors = ["Thibaut Lienart <tlienart@me.com>"]
-version = "0.10.65"
+version = "0.10.68"
 
 [deps]
 Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
@@ -19,16 +19,18 @@ OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
 Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
 REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
 Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
+TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
 
 [compat]
 DocStringExtensions = "0.8"
 ExprTools = "0.1"
 FranklinTemplates = "0.8.16"
 HTTP = "0.8, 0.9"
-Literate = "2.9"
+Literate = "2.8, 2.9"
 LiveServer = "0.4, 0.5, 0.6, 0.7"
 NodeJS = "0.6, 1"
 OrderedCollections = "1"
+TOML = "1.0"
 julia = "1.3"
 
 [extras]
diff --git a/demos/index.md b/demos/index.md
index 0bf2012d..e9a984be 100644
--- a/demos/index.md
+++ b/demos/index.md
@@ -70,7 +70,7 @@ How to make a section expand when clicked, so that content is initially hidden?
 <script>
   var coll = document.getElementsByClassName("collapsible");
   var i;
-  
+
   for (i = 0; i < coll.length; i++) {
     coll[i].addEventListener("click", function() {
       this.classList.toggle("active");
@@ -88,7 +88,7 @@ How to make a section expand when clicked, so that content is initially hidden?
 
 With these definitions, the expandible code sections could be added!
 
-\collaps{An additional example: **Press here to expand**}{In the content part you can have latex: $x^2$, 
+\collaps{An additional example: **Press here to expand**}{In the content part you can have latex: $x^2$,
 
 lists
 * Item 1
diff --git a/docs/_css/jtd.css b/docs/_css/jtd.css
index d8d174d7..7256baa8 100644
--- a/docs/_css/jtd.css
+++ b/docs/_css/jtd.css
@@ -538,6 +538,11 @@ body { counter-reset: eqnum; }
     float: right;
     padding-right: 5px; }
 
+.nonumber .katex-display::after {
+  counter-increment: nothing;
+  content: "";
+}
+
 /* ==================================================================
     CODE & HIGHLIGHT.JS
 ================================================================== */
diff --git a/docs/code/index.md b/docs/code/index.md
index f5266ff7..700cddec 100644
--- a/docs/code/index.md
+++ b/docs/code/index.md
@@ -275,6 +275,8 @@ savefig(joinpath(@OUTPUT, "sinc.svg")) # hide
 
 **Note**: observe that here everything is done with relative paths, `pyplot1` is placed in the  `/assets/` folder relatively to the path of the current page and the `\fig` since it's given a path that doesn't start with  `/` or `./` will also  look in  that folder to try to find a figure which starts with the name `sinc`. See also [more about paths](#more_on_paths).
 
+**Note**: If you wish to use `Plots.jl` and deploy to GitHub pages, you will need to modify the `.github/workflows/Deploy.yml` by adding `env: GKSwstype: "100"` before the ` - name: Build and Deploy` line. [Here](https://github.com/storopoli/Bayesian-Julia/blob/master/.github/workflows/Deploy.yml) is an example.
+
 ### Troubleshooting
 
 A few  things can go  wrong when attempting to use and evaluate code blocks.
diff --git a/docs/faq/technical.md b/docs/faq/technical.md
index 5f83d34f..9174d6db 100644
--- a/docs/faq/technical.md
+++ b/docs/faq/technical.md
@@ -56,41 +56,41 @@ so you can style the back-reference via the `.franklin-content fndef td.fndef-ba
 
 ### How to disable numbering of math in display mode?
 
-It is possible to specify in the CSS which Katex equations will be numbered or not by adjusting the
-`.katex-display::after` class.
-If you want to disable numbering in the entire site, just head to `_css/franklin.css` and remove the `.katex-display::after` block.
-You can also build a simple way to disable all numbering inside a specified `@@` div 
-(see [div blocks](/syntax/divs-commands/#div_blocks))
-
-```markdown
-This is numbered:
-$$ 1+1 = 2 $$
-
-This isn't:
-
-@@no-number
-$$ 2+2 = 4 $$
-and
-$$ 3+3 = 7-1 $$
-@@
-
-Numbered again:
-$$ 7 + 1 = 8 $$
-```
+\note{This is currently only available when you're using KaTeX for maths.}
+
+Use the environment `equation*`, `align*`, `aligned*` or `eqnarray*`. Alternatively, use `\nonumber{...your equation...}`.
+
+You will have to make sure that your CSS sheet contains the following rule:
 
-by adding in the CSS:
 ```css
-.no-number .katex-display::after {
+.nonumber .katex-display::after {
   counter-increment: nothing;
   content: "";
 }
 ```
 
-And possibly [define a command](/syntax/divs-commands/#latex-like_commands) in `config.md`:\
-```markdown
-\newcommand{\nalign}[1]{@@no-number \begin{align}#1\end{align}@@}
-```
-if you feel it is more convenient to write `\nalign{3+3 = 6}`.
+So for instance using `\begin{align*}...\end{align*}`:
+
+\begin{align*}
+    x &= 3 \\
+    y &= 4
+\end{align*}
+
+Or using `\nonumber{$$ ... $$}`:
+
+\nonumber{
+$$
+    x = 5
+$$
+}
+
+Recall that numbered equations can be referred to via `\eqref`:
+
+$$
+x = 14 \label{eqabc}
+$$
+
+like this: \eqref{eqabc}.
 
 
 ## Code
diff --git a/src/Franklin.jl b/src/Franklin.jl
index 3a0b55b2..1d29d60b 100644
--- a/src/Franklin.jl
+++ b/src/Franklin.jl
@@ -10,6 +10,7 @@ using DelimitedFiles: readdlm
 using OrderedCollections
 using Pkg
 using DocStringExtensions: SIGNATURES, TYPEDEF
+using TOML
 
 import Logging
 import LiveServer
@@ -86,7 +87,8 @@ const FD_ENV = LittleDict(
     :SHOW_WARNINGS     => true,     # franklin-specific warnings
     :FAIL_ON_WARNING   => false,    # turn warnings into fatal errors
     :UTILS_COUNTER     => 0,        # counter for utils module
-    :UTILS_HASH        => nothing   # hash of the utils
+    :UTILS_HASH        => nothing,  # hash of the utils
+    :LITERATE_VERSION  => VersionNumber(TOML.parsefile(joinpath(dirname(dirname(pathof(Literate))), "Project.toml"))["version"]),
     )
 
 utils_name()   = "Utils_$(FD_ENV[:UTILS_COUNTER]::Int)"
diff --git a/src/converter/latex/io.jl b/src/converter/latex/io.jl
index 22271d8b..829034b6 100644
--- a/src/converter/latex/io.jl
+++ b/src/converter/latex/io.jl
@@ -206,7 +206,7 @@ function lx_tableinput(lxc::LxCom, _)
 end
 
 """
-    \\liteate{...}
+    \\literate{...}
 
 Resolve a `\\literate{rpath}` (find a literate script and insert it).
 """
@@ -223,3 +223,13 @@ function lx_literate(lxc::LxCom, lxd::Vector{LxDef})
     # then reprocess
     return reprocess(read(opath, String), lxd, nostripp=true)
 end
+
+"""
+    \\nonumber{...}
+
+Suppress the displaying of a number.
+"""
+function lx_nonumber(c, lxd)
+    PAGE_EQREFS[PAGE_EQREFS_COUNTER] -= 1
+    return reprocess("@@nonumber " * content(c.braces[1]) * "@@", lxd)
+end
diff --git a/src/converter/latex/objects.jl b/src/converter/latex/objects.jl
index e125d5cc..9722eac8 100644
--- a/src/converter/latex/objects.jl
+++ b/src/converter/latex/objects.jl
@@ -32,6 +32,9 @@ const LX_INTERNAL_COMMANDS = [
     lxd("style",           2, "~~~<span style=\"!#1\">~~~!#2~~~</span>~~~"),
     lxd("tableofcontents", 0, "\\toc"),
     lxd("codeoutput",      1, "\\output{#1}"), # \codeoutput{rpath}
+    # ------------------
+    # other
+    lxd("nonumber", 1),
     ]
 
 """
@@ -42,10 +45,14 @@ Convenience function to create pairs (envdname => simple envdef)
 lxe(n, k, d=Pair("", "")) = n => LxDef(n, k, d)
 
 const LX_INTERNAL_ENVIRONMENTS = [
-    lxe("equation", 0, raw"\[" => raw"\]"),
-    lxe("align",    0, raw"\[\begin{aligned}"    => raw"\end{aligned}\]"),
-    lxe("aligned",  0, raw"\[\begin{aligned}"    => raw"\end{aligned}\]"),
-    lxe("eqnarray", 0, raw"\[\begin{array}{rcl}" => raw"\end{array}\]"),
+    lxe("equation",  0, raw"\["           => raw"\]"),
+    lxe("equation*", 0, raw"\nonumber{\[" => raw"\]}"),
+    lxe("align",     0, raw"\[\begin{aligned}"              => raw"\end{aligned}\]"),
+    lxe("align*",    0, raw"\nonumber{\[\begin{aligned}"    => raw"\end{aligned}\]}"),
+    lxe("aligned",   0, raw"\[\begin{aligned}"              => raw"\end{aligned}\]"),
+    lxe("aligned*",  0, raw"\nonumber{\[\begin{aligned}"    => raw"\end{aligned}\]}"),
+    lxe("eqnarray",  0, raw"\[\begin{array}{rcl}"           => raw"\end{array}\]"),
+    lxe("eqnarray*", 0, raw"\nonumber{\[\begin{array}{rcl}" => raw"\end{array}\]}")
     ]
 
 
diff --git a/src/eval/codeblock.jl b/src/eval/codeblock.jl
index 8d4356c7..93a6f591 100644
--- a/src/eval/codeblock.jl
+++ b/src/eval/codeblock.jl
@@ -21,7 +21,8 @@ function parse_fenced_block(ss::SubString, shortcut=false)::Tuple
         # * ```lang ... ``` where lang can be something like julia-repl
         # * ```lang:path ... ``` where path is a relative path like "this/path"
         # group 1 => lang; group 2 => path; group 3 => code
-        reg   = ifelse(startswith(ss, "`````"), CODE_5_PAT, CODE_3_PAT)
+        reg = startswith(ss, "`````") ? CODE_5_PAT :
+              startswith(ss, "````")  ? CODE_4_PAT : CODE_3_PAT
         m     = match(reg, ss)
         lang  = m.captures[1]
         rpath = m.captures[2]
diff --git a/src/eval/literate.jl b/src/eval/literate.jl
index e5f7f5e4..3ac48c83 100644
--- a/src/eval/literate.jl
+++ b/src/eval/literate.jl
@@ -1,8 +1,13 @@
 const LITERATE_FENCER        = "julialit"
-const LITERATE_JULIA_FENCE   = "```$LITERATE_FENCER"
+const LITERATE_JULIA_REPLACE = ifelse(FD_ENV[:LITERATE_VERSION] < v"2.9.0",
+                                      "```", "````")
+const LITERATE_JULIA_FENCE   = "$LITERATE_JULIA_REPLACE$LITERATE_FENCER"
 const LITERATE_JULIA_FENCE_L = length(LITERATE_JULIA_FENCE)
 const LITERATE_JULIA_FENCE_R = Regex(LITERATE_JULIA_FENCE)
 
+const LITERATE_FLAVOR = ifelse(FD_ENV[:LITERATE_VERSION] < v"2.9.0",
+                                Literate.CommonMarkFlavor(),
+                                Literate.FranklinFlavor())
 
 """
 $SIGNATURES
@@ -42,9 +47,9 @@ function literate_to_franklin(rpath::AS)::Tuple{String,Bool}
     # >> output the markdown
     Literate.markdown(
         fpath, outpath;
-        flavor=Literate.CommonMarkFlavor(),
+        flavor=LITERATE_FLAVOR,
         mdstrings=locvar(:literate_mds)::Bool,
-        config=Dict("codefence" => (LITERATE_JULIA_FENCE => "```")),
+        config=Dict("codefence" => (LITERATE_JULIA_FENCE => LITERATE_JULIA_REPLACE)),
         preprocess=s->replace(s, r"#hide\s*?\n" => "# hide\n"),
         postprocess=literate_post_process,
         credit=false
@@ -52,7 +57,7 @@ function literate_to_franklin(rpath::AS)::Tuple{String,Bool}
     # >> output the script
     Literate.script(
         fpath, outpath;
-        flavor=Literate.CommonMarkFlavor(),
+        flavor=LITERATE_FLAVOR,
         mdstrings=locvar(:literate_mds)::Bool,
         postprocess=s->(MESSAGE_FILE_GEN_LIT * s),
         name=fname * "_script",
@@ -82,7 +87,7 @@ function literate_post_process(s::String)::String
     c    = 1
     for m in em
         write(buf, SubString(s, head, prevind(s, m.offset)))
-        write(buf, "```julia:ex$c\n")
+        write(buf, "$(LITERATE_JULIA_REPLACE)julia:ex$c\n")
         head = nextind(s, m.offset + LITERATE_JULIA_FENCE_L)
         c   += 1
     end
diff --git a/src/manager/rss_generator.jl b/src/manager/rss_generator.jl
index e8dff546..d1e08181 100644
--- a/src/manager/rss_generator.jl
+++ b/src/manager/rss_generator.jl
@@ -104,7 +104,7 @@ function rss_generator()::Nothing
             if isfile(tag_feed_head_cand)
                 tag_feed_head = read(tag_feed_head_cand)
             end
-            write(io, tag_feed_head)
+            write(io, convert_html(tag_feed_head))
             for item in sorted_items
                 tag ∈ item.tags || continue
                 write(io, item.item)
diff --git a/src/regexes.jl b/src/regexes.jl
index 86d67150..804c1934 100644
--- a/src/regexes.jl
+++ b/src/regexes.jl
@@ -80,7 +80,9 @@ const CODE_3_PAT = Regex(
         ")|(?:\\n|\\s))" *
         "\\s*\\n?((?:.|\\n)*)```") # rest of the code
 
-const CODE_5_PAT = Regex("``" * CODE_3_PAT.pattern * "``")
+const CODE_4_PAT = Regex("`" * CODE_3_PAT.pattern * "`")
+
+const CODE_5_PAT = Regex("`" * CODE_4_PAT.pattern * "`")
 
 const CODE_HIDE_PAT = Regex(raw"(?:^|[^\S\r\n]*?)#(\s)*?(?i)hide(all)?")
 


Test patch:
diff --git a/test/integration/literate.jl b/test/integration/literate.jl
index 974c9f13..554b846a 100644
--- a/test/integration/literate.jl
+++ b/test/integration/literate.jl
@@ -67,17 +67,17 @@ end
         In julia rational numbers can be constructed with the `//` operator.
         Lets define two rational numbers, `x` and `y`:
 
-        ```julia:ex1
+        ````julia:ex1
         # Define variable x and y
         x = 1//3
         y = 2//5
-        ```
+        ````
 
         When adding `x` and `y` together we obtain a new rational number:
 
-        ```julia:ex2
+        ````julia:ex2
         z = x + y
-        ```
+        ````
 
         """
 
@@ -110,9 +110,9 @@ end
     # Literate to Franklin
     s = raw"""
         # # Rational numbers
-        # ```julia
+        # ````julia
         # const a = 1
-        # ```
+        # ````
         a = 5
         """
     path = joinpath(F.path(:literate), "tutorial.jl")
@@ -123,13 +123,13 @@ end
     @test out // """
         <!--This file was generated, do not modify it.-->
         # Rational numbers
-        ```julia
+        ````julia
         const a = 1
-        ```
+        ````
 
-        ```julia:ex1
+        ````julia:ex1
         a = 5
-        ```
+        ````
         """
 
     # Use of `\literate` command
diff --git a/test/parser/markdown-extra.jl b/test/parser/markdown-extra.jl
index e2edf142..11deb059 100644
--- a/test/parser/markdown-extra.jl
+++ b/test/parser/markdown-extra.jl
@@ -208,3 +208,12 @@ end
     s = "abc :joi: def" |> fd2html
     @test s // "<p>abc :joi: def</p>"
 end
+
+@testset "quad-backticks" begin
+    s = """
+        ````julia
+        1+1
+        ````
+        """ |> fd2html
+    @test s // """<pre><code class="language-julia">1&#43;1</code></pre>"""
+end