Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to nest comment blocks, e.g. {# ... {# ... #} ... #} #42

Closed
DilumAluthge opened this issue Dec 18, 2024 · 4 comments
Closed

Unable to nest comment blocks, e.g. {# ... {# ... #} ... #} #42

DilumAluthge opened this issue Dec 18, 2024 · 4 comments

Comments

@DilumAluthge
Copy link

DilumAluthge commented Dec 18, 2024

Summary

It seems that I am unable to nest comment blocks inside each other.

Note: When I say "comment blocks", I am referring to comment blocks in the OteraEngine syntax, that is, {# ... #}.

I am not referring to Julia source code comments (# single line... or #= ... multi line ... #).

Steps to reproduce:

julia> import OteraEngine

julia> str_1 = """
       {#

       Hello world.

       #}
       """;

julia> str_2 = """
       {#

       Comments look something like this: {# foo #}

       #}
       """;

julia> str_3 = """
       {#

       Comments look something like this:

       {#

       bar

       #}

       #}
       """;

julia> template_1 = OteraEngine.Template(str_1; path = false)


julia> template_2 = OteraEngine.Template(str_2; path = false)


julia> template_3 = OteraEngine.Template(str_3; path = false)


julia>

Expected behavior

I had hoped that all three templates would work.

Actual behavior

template_1 works fine, but template_2 and template_3 throw errors.

julia> template_1 = OteraEngine.Template(str_1; path = false)
OteraEngine.Template(...)

julia> template_2 = OteraEngine.Template(str_2; path = false)
ERROR: ParserError: invalid end token: end of comment block without start of comment block
Stacktrace:
 [1] parse_meta(tokens::Vector{Union{…}}, config::OteraEngine.ParserConfig; parse_macro::Bool, include::Bool)
   @ OteraEngine ~/.julia/packages/OteraEngine/2VgF6/src/parser.jl:238
 [2] parse_meta(tokens::Vector{Union{AbstractString, Symbol}}, config::OteraEngine.ParserConfig)
   @ OteraEngine ~/.julia/packages/OteraEngine/2VgF6/src/parser.jl:152
 [3] parse_template(txt::String, config::OteraEngine.ParserConfig)
   @ OteraEngine ~/.julia/packages/OteraEngine/2VgF6/src/parser.jl:527
 [4] OteraEngine.Template(txt::String; path::Bool, config_path::String, config::Dict{String, Union{Bool, String}})
   @ OteraEngine ~/.julia/packages/OteraEngine/2VgF6/src/template.jl:61
 [5] top-level scope
   @ REPL[9]:1
Some type information was truncated. Use `show(err)` to see complete types.

julia> template_3 = OteraEngine.Template(str_3; path = false)
ERROR: ParserError: invalid end token: end of comment block without start of comment block
Stacktrace:
 [1] parse_meta(tokens::Vector{Union{…}}, config::OteraEngine.ParserConfig; parse_macro::Bool, include::Bool)
   @ OteraEngine ~/.julia/packages/OteraEngine/2VgF6/src/parser.jl:238
 [2] parse_meta(tokens::Vector{Union{AbstractString, Symbol}}, config::OteraEngine.ParserConfig)
   @ OteraEngine ~/.julia/packages/OteraEngine/2VgF6/src/parser.jl:152
 [3] parse_template(txt::String, config::OteraEngine.ParserConfig)
   @ OteraEngine ~/.julia/packages/OteraEngine/2VgF6/src/parser.jl:527
 [4] OteraEngine.Template(txt::String; path::Bool, config_path::String, config::Dict{String, Union{Bool, String}})
   @ OteraEngine ~/.julia/packages/OteraEngine/2VgF6/src/template.jl:61
 [5] top-level scope
   @ REPL[10]:1
Some type information was truncated. Use `show(err)` to see complete types.

Version info

I tested this with Julia 1.10.5 and OteraEngine 0.6.0 on macOS.

@DilumAluthge DilumAluthge changed the title Unable to nest comment blocks Unable to nest comment blocks, e.g. {# ... {# ... #} ... #} Dec 18, 2024
@MommaWatasu
Copy link
Owner

Hi @DilumAluthge

Thanks for your report.
I'll fix this soon, but let me ask you one thing. Your "expected behavior" is that all of three templates render nothing, right?

@DilumAluthge
Copy link
Author

Hi @MommaWatasu, thanks so much for such a quick response.

Yes, my expectation would be that all three of those templates render empty (i.e. all of the comments are removed).

@MommaWatasu
Copy link
Owner

I released v0.6.1 and now nested comment blocks are processed correctly.
Enjoy using my package!

@DilumAluthge
Copy link
Author

Thank you for such a quick fix, and for your continued maintenance of this package!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants