@@ -26,6 +26,26 @@ describe('looksLikeHtml', () => {
2626 it ( 'returns false for markdown' , ( ) => {
2727 expect ( looksLikeHtml ( '# Hello\n\nThis is **markdown**.' ) ) . toBe ( false ) ;
2828 } ) ;
29+
30+ it ( 'ignores HTML tags inside fenced code blocks' , ( ) => {
31+ const md = '# Example\n\n```html\n<!DOCTYPE html>\n<html>\n<body>Hello</body>\n</html>\n```\n' ;
32+ expect ( looksLikeHtml ( md ) ) . toBe ( false ) ;
33+ } ) ;
34+
35+ it ( 'ignores HTML tags inside inline code spans' , ( ) => {
36+ const md = '# Setup\n\nAdd the script before the closing `</body>` tag.\n' ;
37+ expect ( looksLikeHtml ( md ) ) . toBe ( false ) ;
38+ } ) ;
39+
40+ it ( 'ignores HTML tags inside tilde fenced code blocks' , ( ) => {
41+ const md = '# Example\n\n~~~html\n<html>\n<head><title>Test</title></head>\n</html>\n~~~\n' ;
42+ expect ( looksLikeHtml ( md ) ) . toBe ( false ) ;
43+ } ) ;
44+
45+ it ( 'still detects real HTML outside of code blocks' , ( ) => {
46+ const html = '<!DOCTYPE html>\n<html>\n```not a code block\n```\n</html>' ;
47+ expect ( looksLikeHtml ( html ) ) . toBe ( true ) ;
48+ } ) ;
2949} ) ;
3050
3151describe ( 'looksLikeMarkdown' , ( ) => {
@@ -48,4 +68,10 @@ describe('looksLikeMarkdown', () => {
4868 it ( 'returns false for plain text with no markdown signals' , ( ) => {
4969 expect ( looksLikeMarkdown ( 'Just some plain text without any formatting.' ) ) . toBe ( false ) ;
5070 } ) ;
71+
72+ it ( 'returns true for markdown containing HTML examples in code' , ( ) => {
73+ const md =
74+ '# Web API\n\nAdd the script before `</body>`.\n\n```html\n<html><body>Hello</body></html>\n```\n' ;
75+ expect ( looksLikeMarkdown ( md ) ) . toBe ( true ) ;
76+ } ) ;
5177} ) ;
0 commit comments