Skip to content

Draft: ignore include in a code block#718

Open
ejiektpobehuk wants to merge 1 commit intokovetskiy:masterfrom
ejiektpobehuk:include-in-a-code-block
Open

Draft: ignore include in a code block#718
ejiektpobehuk wants to merge 1 commit intokovetskiy:masterfrom
ejiektpobehuk:include-in-a-code-block

Conversation

@ejiektpobehuk
Copy link

@ejiektpobehuk ejiektpobehuk commented Jan 26, 2026

Addresses #717

Before the change:

  • processes all Include directives, even those inside code blocks

After the change:

  • finds all fenced code block positions
  • finds all Include directive positions
  • processes only Include directives that are outside of fenced code blocks

I'm not well versed in go so I took the liberty to generate most of the code and tests for this PR by opus 4.5.

They passed my initial sniff test so I'm posting it publicly.
The PR is marked as a draft since I want to take more responsibility for the change:

  • get more familiar with the code
  • test it in production
  • fix code blocks with the syntax highlight
  • make tests more readable
  • support for indented code block.

Mermaid tests were failing before the change in the exact same manner:

go test ./...
ok  	github.com/kovetskiy/mark	0.016s
ok  	github.com/kovetskiy/mark/attachment	0.003s
?   	github.com/kovetskiy/mark/confluence	[no test files]
ok  	github.com/kovetskiy/mark/d2	0.624s
?   	github.com/kovetskiy/mark/includes	[no test files]
?   	github.com/kovetskiy/mark/macro	[no test files]
ok  	github.com/kovetskiy/mark/markdown	0.043s
--- FAIL: TestExtractMermaidImage (0.62s)
    --- FAIL: TestExtractMermaidImage/example (0.62s)
        mermaid_test.go:45:
            	Error Trace:	/tmp/mark/mermaid/mermaid_test.go:45
            	Error:      	Not equal:
            	            	expected: "87"
            	            	actual  : "86"
            	            	
            	            	Diff:
            	            	--- Expected
            	            	+++ Actual
            	            	@@ -1 +1 @@
            	            	-87
            	            	+86
            	Test:       	TestExtractMermaidImage/example
            	Messages:   	processMermaidLocally(example, graph TD;
            	            	 A-->B;)
FAIL
FAIL	github.com/kovetskiy/mark/mermaid	0.629s
ok  	github.com/kovetskiy/mark/metadata	0.003s
ok  	github.com/kovetskiy/mark/page	0.003s
?   	github.com/kovetskiy/mark/parser	[no test files]
?   	github.com/kovetskiy/mark/renderer	[no test files]
?   	github.com/kovetskiy/mark/stdlib	[no test files]
?   	github.com/kovetskiy/mark/types	[no test files]
ok  	github.com/kovetskiy/mark/util	0.016s
?   	github.com/kovetskiy/mark/vfs	[no test files]
FAIL

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

Successfully merging this pull request may close these issues.

1 participant