kovetskiy / mark

Sync your markdown files with Confluence pages.
https://samizdat.dev
Other
988 stars 147 forks source link

Bugfix/issu362 #363

Open Skeeve opened 11 months ago

Skeeve commented 11 months ago

This is a fix for issue #362 I found today

mrueg commented 10 months ago

Could you add a test for this that shows that it's failing? https://pkg.go.dev/text/template#Template.Delims shows that the default is "{{" and "}}", so no need to set this explicitly.

Skeeve commented 10 months ago

Could you add a test for this that shows that it's failing? https://pkg.go.dev/text/template#Template.Delims shows that the default is "{{" and "}}", so no need to set this explicitly.

Do you mean some testdata files? I'd love to, but it seems macros are not covered by tests at all since they are never expanded. See what the actual output of CompileMarkdown is when I put a simple

<!-- Macro: ::test::
     Template: #inline
     inline: |
          HiHo
     -->

::test::

as a testfile into testdata:

                                +<!-- Macro: ::test::
                                +     Template: #inline
                                +     inline: |
                                +          HiHo
                                +     -->
                                +<p>::test::</p>

So the macro was never touched it seemed.

Skeeve commented 10 months ago

So here is the test for you to reproduce:

% mark --compile-only -f issue362-without-include.md 
2023-10-17 09:57:39.009 INFO  processing issue362-without-include.md
2023-10-17 09:57:39.010 INFO  the leading H1 heading will be excluded from the Confluence output
<p>Hiho Manuel.</p>

So without the include it was fine.

% mark --compile-only -f issue362-with-include.md 
2023-10-17 09:58:14.339 INFO  processing issue362-with-include.md
2023-10-17 09:58:14.340 INFO  the leading H1 heading will be excluded from the Confluence output
<p>Hiho {{ .title }}</p>
<p>SELECT NOW()</p>

With the include, {{ .title }} is not expanded.

% mark2 --compile-only -f issue362-with-include.md
2023-10-17 09:58:50.245 INFO  processing issue362-with-include.md
2023-10-17 09:58:50.246 INFO  the leading H1 heading will be excluded from the Confluence output
<p>Hiho Manuel.</p>
<p>SELECT NOW()</p>

With my patched version (mark2) the expansion is done.

issue362-without-include.md issue362-with-include.md sql.txt

Skeeve commented 10 months ago

Do you have any clue, why include macros are not executed when running make test?

These files I have put into pkg/mark/testdata

Archiv.zip