From 88fd8adb0d370e63e3522c9544b06541f0209b31 Mon Sep 17 00:00:00 2001 From: Thibaut Lienart Date: Fri, 1 Oct 2021 12:00:06 +0200 Subject: [PATCH] closes #891 (#892) --- Project.toml | 2 +- src/Franklin.jl | 3 +++ src/converter/markdown/md.jl | 7 +++++++ src/converter/markdown/tags.jl | 1 + src/utils/vars.jl | 5 +++++ 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 3b1e71012..aeb11bef2 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Franklin" uuid = "713c75ef-9fc9-4b05-94a9-213340da978e" authors = ["Thibaut Lienart "] -version = "0.10.58" +version = "0.10.59" [deps] Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" diff --git a/src/Franklin.jl b/src/Franklin.jl index ca6247b54..3a0b55b2a 100644 --- a/src/Franklin.jl +++ b/src/Franklin.jl @@ -94,6 +94,9 @@ utils_symb() = Symbol(utils_name()) utils_module() = getproperty(Main, utils_symb()) utils_hash() = nothing +# HACK avoid stackoverflow for pagevar cycle (see juliacomputing issue #891) +const PAGEVAR_DEPTH = Ref{Int}(0) + # keep track of pages which need to be re-evaluated after the full-pass # to ensure that their h-fun are working with the fully-defined scope # (e.g. if need list of all tags) diff --git a/src/converter/markdown/md.jl b/src/converter/markdown/md.jl index bb5c700f4..963042acb 100644 --- a/src/converter/markdown/md.jl +++ b/src/converter/markdown/md.jl @@ -33,6 +33,13 @@ function convert_md( # instantiate page dictionaries isrecursive || isinternal || set_page_env() + # HACK avoid stackoverflow in pagevar loop see #891 + if pagevar + PAGEVAR_DEPTH[] += 1 + else + PAGEVAR_DEPTH[] = 0 + end + # # Parsing of the markdown string # (to find latex command, latex definitions, math envs etc.) diff --git a/src/converter/markdown/tags.jl b/src/converter/markdown/tags.jl index 3c86b1582..496dfac33 100644 --- a/src/converter/markdown/tags.jl +++ b/src/converter/markdown/tags.jl @@ -11,6 +11,7 @@ Note: the `clean_tags` cleans up orphan tags (tags that wouldn't be pointing to any page anymore). """ function generate_tag_pages(refresh_tags=Set{String}())::Nothing + globvar(:generate_tags)::Bool || return # if there are no page tags, cleanup and finish PAGE_TAGS = globvar("fd_page_tags") isnothing(PAGE_TAGS) && return clean_tags() diff --git a/src/utils/vars.jl b/src/utils/vars.jl index ef8bd0e3d..992c7b363 100644 --- a/src/utils/vars.jl +++ b/src/utils/vars.jl @@ -64,6 +64,8 @@ const GLOBAL_VARS_DEFAULT = [ "literate_mds" => dpair(false), # each cell runs a cd in/out OUT_PATH "auto_code_path" => dpair(false), + # don't generate tag pages + "generate_tags" => dpair(true), # ----------------------------------------------------- # LEGACY "div_content" => dpair(""), # see build_page @@ -239,6 +241,9 @@ processed yet so force a pass over that page. Return `default` (which is `nothing` if not specified) if the variable is not found. """ function pagevar(rpath::AS, name::Union{Symbol,String}; default=nothing) + # HACK avoid stackoverflow for pagevar cycle + PAGEVAR_DEPTH[] > 5 && return default + # only split extension if it's .md or .html (otherwise can cause trouble # if there's a dot in the page name... not recommended but happens.) rpc = splitext(rpath)